@crowdin/crowdin-api-client
Version:
JavaScript library for Crowdin API
57 lines (56 loc) • 2.32 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.Webhooks = void 0;
const core_1 = require("../core");
/**
* Webhooks allow you to collect information about events that happen in your Crowdin projects.
*
* You can select the request type, content type, and add a custom payload, which allows you to create integrations with other systems on your own.
*/
class Webhooks extends core_1.CrowdinApi {
listWebhooks(projectId, options, deprecatedOffset) {
if ((0, core_1.isOptionalNumber)(options, '1' in arguments)) {
options = { limit: options, offset: deprecatedOffset };
}
const url = `${this.url}/projects/${projectId}/webhooks`;
return this.getList(url, options.limit, options.offset);
}
/**
* @param projectId project identifier
* @param request request body
* @see https://developer.crowdin.com/api/v2/#operation/api.projects.webhooks.post
*/
addWebhook(projectId, request) {
const url = `${this.url}/projects/${projectId}/webhooks`;
return this.post(url, request, this.defaultConfig());
}
/**
* @param projectId project identifier
* @param webhookId webhook identifier
* @see https://developer.crowdin.com/api/v2/#operation/api.projects.webhooks.get
*/
getWebhook(projectId, webhookId) {
const url = `${this.url}/projects/${projectId}/webhooks/${webhookId}`;
return this.get(url, this.defaultConfig());
}
/**
* @param projectId project identifier
* @param webhookId webhook identifier
* @see https://developer.crowdin.com/api/v2/#operation/api.projects.webhooks.delete
*/
deleteWebhook(projectId, webhookId) {
const url = `${this.url}/projects/${projectId}/webhooks/${webhookId}`;
return this.delete(url, this.defaultConfig());
}
/**
* @param projectId project identifier
* @param webhookId webhook identifier
* @param request request body
* @see https://developer.crowdin.com/api/v2/#operation/api.projects.webhooks.patch
*/
editWebhook(projectId, webhookId, request) {
const url = `${this.url}/projects/${projectId}/webhooks/${webhookId}`;
return this.patch(url, request, this.defaultConfig());
}
}
exports.Webhooks = Webhooks;
;