UNPKG

@crowdin/crowdin-api-client

Version:
76 lines (75 loc) 3.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StringComments = void 0; const core_1 = require("../core"); /** * Use API to list, add, get, edit or delete string comments. */ class StringComments extends core_1.CrowdinApi { listStringComments(projectId, options, deprecatedType, deprecatedTargetLanguageId, deprecatedIssueType, deprecatedIssueStatus) { let url = `${this.url}/projects/${projectId}/comments`; if ((0, core_1.isOptionalNumber)(options, '1' in arguments)) { options = { stringId: options, type: deprecatedType, targetLanguageId: deprecatedTargetLanguageId, issueStatus: deprecatedIssueStatus, issueType: deprecatedIssueType, }; } url = this.addQueryParam(url, 'stringId', options.stringId); url = this.addQueryParam(url, 'type', options.type); url = this.addQueryParam(url, 'targetLanguageId', options.targetLanguageId); url = this.addQueryParam(url, 'issueType', options.issueType); url = this.addQueryParam(url, 'issueStatus', options.issueStatus); 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.comments.post */ addStringComment(projectId, request) { const url = `${this.url}/projects/${projectId}/comments`; return this.post(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param stringCommentId string comment identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.comments.get */ getStringComment(projectId, stringCommentId) { const url = `${this.url}/projects/${projectId}/comments/${stringCommentId}`; return this.get(url, this.defaultConfig()); } /** * @param projectId project identifier * @param stringCommentId string comment identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.comments.delete */ deleteStringComment(projectId, stringCommentId) { const url = `${this.url}/projects/${projectId}/comments/${stringCommentId}`; return this.delete(url, this.defaultConfig()); } /** * @param projectId project identifier * @param stringCommentId string comment identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.comments.patch */ editStringComment(projectId, stringCommentId, request) { const url = `${this.url}/projects/${projectId}/comments/${stringCommentId}`; return this.patch(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.comments.batchPatch */ stringCommentBatchOperations(projectId, request) { const url = `${this.url}/projects/${projectId}/comments`; return this.patch(url, request, this.defaultConfig()); } } exports.StringComments = StringComments;