UNPKG

@crowdin/crowdin-api-client

Version:
162 lines (161 loc) 7.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TasksModel = exports.Tasks = void 0; const core_1 = require("../core"); /** * Create and assign tasks to get files translated or proofread by specific people. * You can set the due dates, split words between people, and receive notifications about the changes and updates on tasks. * Tasks are project-specific, so you’ll have to create them within a project. * * Use API to create, modify, and delete specific tasks. */ class Tasks extends core_1.CrowdinApi { listTasks(projectId, options, deprecatedOffset, deprecatedStatus) { if ((0, core_1.isOptionalNumber)(options, '1' in arguments)) { options = { limit: options, offset: deprecatedOffset, status: deprecatedStatus }; } let url = `${this.url}/projects/${projectId}/tasks`; url = this.addQueryParam(url, 'status', options.status); url = this.addQueryParam(url, 'assigneeId', options.assigneeId); url = this.addQueryParam(url, 'orderBy', options.orderBy); 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.tasks.post */ addTask(projectId, request) { const url = `${this.url}/projects/${projectId}/tasks`; return this.post(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param taskId task identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.exports.post */ exportTaskStrings(projectId, taskId) { const url = `${this.url}/projects/${projectId}/tasks/${taskId}/exports`; return this.post(url, {}, this.defaultConfig()); } /** * @param projectId project identifier * @param taskId task identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.get */ getTask(projectId, taskId) { const url = `${this.url}/projects/${projectId}/tasks/${taskId}`; return this.get(url, this.defaultConfig()); } /** * @param projectId project identifier * @param taskId task identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.delete */ deleteTask(projectId, taskId) { const url = `${this.url}/projects/${projectId}/tasks/${taskId}`; return this.delete(url, this.defaultConfig()); } /** * @param projectId project identifier * @param taskId task identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.patch */ editTask(projectId, taskId, request) { const url = `${this.url}/projects/${projectId}/tasks/${taskId}`; return this.patch(url, request, this.defaultConfig()); } listUserTasks(options, deprecatedOffset, deprecatedStatus, deprecatedIsArchived) { let url = `${this.url}/user/tasks`; if ((0, core_1.isOptionalNumber)(options, '0' in arguments)) { options = { limit: options, offset: deprecatedOffset, status: deprecatedStatus, isArchived: deprecatedIsArchived, }; } url = this.addQueryParam(url, 'status', options.status); url = this.addQueryParam(url, 'isArchived', options.isArchived); url = this.addQueryParam(url, 'orderBy', options.orderBy); return this.getList(url, options.limit, options.offset); } /** * @param projectId project identifier * @param taskId task identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.user.tasks.patch */ editTaskArchivedStatus(projectId, taskId, request) { let url = `${this.url}/user/tasks/${taskId}`; url = this.addQueryParam(url, 'projectId', projectId); return this.patch(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param options optional parameters for the request * @see https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.settings-templates.getMany */ listTaskSettingsTemplates(projectId, options) { const url = `${this.url}/projects/${projectId}/tasks/settings-templates`; return this.getList(url, options === null || options === void 0 ? void 0 : options.limit, options === null || options === void 0 ? void 0 : options.offset); } /** * @param projectId project identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.settings-templates.post */ addTaskSettingsTemplate(projectId, request) { const url = `${this.url}/projects/${projectId}/tasks/settings-templates`; return this.post(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param taskSettingsId task settings identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.settings-templates.get */ getTaskSettingsTemplate(projectId, taskSettingsId) { const url = `${this.url}/projects/${projectId}/tasks/settings-templates/${taskSettingsId}`; return this.get(url, this.defaultConfig()); } /** * @param projectId project identifier * @param taskSettingsId task settings identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.settings-templates.delete */ deleteTaskSettingsTemplate(projectId, taskSettingsId) { const url = `${this.url}/projects/${projectId}/tasks/settings-templates/${taskSettingsId}`; return this.delete(url, this.defaultConfig()); } /** * @param projectId project identifier * @param taskSettingsId task settings identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.settings-templates.patch */ editTaskSettingsTemplate(projectId, taskSettingsId, request) { const url = `${this.url}/projects/${projectId}/tasks/settings-templates/${taskSettingsId}`; return this.patch(url, request, this.defaultConfig()); } } exports.Tasks = Tasks; var TasksModel; (function (TasksModel) { let Type; (function (Type) { Type[Type["TRANSLATE"] = 0] = "TRANSLATE"; Type[Type["PROOFREAD"] = 1] = "PROOFREAD"; })(Type = TasksModel.Type || (TasksModel.Type = {})); let TypeVendor; (function (TypeVendor) { TypeVendor[TypeVendor["TRANSLATE_BY_VENDOR"] = 2] = "TRANSLATE_BY_VENDOR"; TypeVendor[TypeVendor["PROOFREAD_BY_VENDOR"] = 3] = "PROOFREAD_BY_VENDOR"; })(TypeVendor = TasksModel.TypeVendor || (TasksModel.TypeVendor = {})); let TranslatedExpertise; (function (TranslatedExpertise) { TranslatedExpertise["ECONOMY"] = "P"; TranslatedExpertise["PROFESSIONAL"] = "T"; TranslatedExpertise["PREMIUM"] = "R"; })(TranslatedExpertise = TasksModel.TranslatedExpertise || (TasksModel.TranslatedExpertise = {})); })(TasksModel = exports.TasksModel || (exports.TasksModel = {}));