UNPKG

@crowdin/crowdin-api-client

Version:
338 lines (337 loc) 16.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Reports = void 0; const core_1 = require("../core"); /** * Reports help to estimate costs, calculate translation costs, and identify the top members. * * Use API to generate Cost Estimate, Translation Cost, and Top Members reports. * You can then export reports in .xlsx or .csv file formats. * Report generation is an asynchronous operation and shall be completed with a sequence of API methods. */ class Reports extends core_1.CrowdinApi { /** * @param options optional parameters for the request * @see https://developer.crowdin.com/enterprise/api/v2/#operation/api.reports.archives.getMany */ listOrganizationReportArchives(options) { let url = `${this.url}/reports/archives`; url = this.addQueryParam(url, 'scopeId', options === null || options === void 0 ? void 0 : options.scopeId); url = this.addQueryParam(url, 'scopeType', options === null || options === void 0 ? void 0 : options.scopeType); return this.getList(url, options === null || options === void 0 ? void 0 : options.limit, options === null || options === void 0 ? void 0 : options.offset); } /** * @param archiveId archive identifier * @see https://developer.crowdin.com/enterprise/api/v2/#operation/api.reports.archives.get */ getOrganizationReportArchive(archiveId) { const url = `${this.url}/reports/archives/${archiveId}`; return this.get(url, this.defaultConfig()); } /** * @param archiveId archive identifier * @see https://developer.crowdin.com/enterprise/api/v2/#operation/api.reports.archives.delete */ deleteOrganizationReportArchive(archiveId) { const url = `${this.url}/reports/archives/${archiveId}`; return this.delete(url, this.defaultConfig()); } /** * @param archiveId archive identifier * @see https://developer.crowdin.com/enterprise/api/v2/#operation/api.reports.archives.exports.post */ exportOrganizationReportArchive(archiveId, request = {}) { const url = `${this.url}/reports/archives/${archiveId}/exports`; return this.post(url, request, this.defaultConfig()); } /** * @param archiveId archive identifier * @param exportId export identifier * @see https://developer.crowdin.com/enterprise/api/v2/#operation/api.reports.archives.exports.get */ checkOrganizationReportArchiveStatus(archiveId, exportId) { const url = `${this.url}/reports/archives/${archiveId}/exports/${exportId}`; return this.get(url, this.defaultConfig()); } /** * @param archiveId archive identifier * @param exportId export identifier * @see https://developer.crowdin.com/enterprise/api/v2/#operation/api.reports.archives.exports.download.get */ downloadOrganizationReportArchive(archiveId, exportId) { const url = `${this.url}/reports/archives/${archiveId}/exports/${exportId}/download`; return this.get(url, this.defaultConfig()); } /** * @param userId user identifier * @param options optional parameters for the request * @see https://developer.crowdin.com/api/v2/#operation/api.reports.archives.getMany */ listUserReportArchives(userId, options) { let url = `${this.url}/users/${userId}/reports/archives`; url = this.addQueryParam(url, 'scopeId', options === null || options === void 0 ? void 0 : options.scopeId); url = this.addQueryParam(url, 'scopeType', options === null || options === void 0 ? void 0 : options.scopeType); return this.getList(url, options === null || options === void 0 ? void 0 : options.limit, options === null || options === void 0 ? void 0 : options.offset); } /** * @param userId user identifier * @param archiveId archive identifier * @see https://developer.crowdin.com/api/v2/#operation/api.users.reports.archives.get */ getUserReportArchive(userId, archiveId) { const url = `${this.url}/users/${userId}/reports/archives/${archiveId}`; return this.get(url, this.defaultConfig()); } /** * @param userId user identifier * @param archiveId archive identifier * @see https://developer.crowdin.com/api/v2/#operation/api.users.reports.archives.delete */ deleteUserReportArchive(userId, archiveId) { const url = `${this.url}/users/${userId}/reports/archives/${archiveId}`; return this.delete(url, this.defaultConfig()); } /** * @param userId user identifier * @param archiveId archive identifier * @see https://developer.crowdin.com/api/v2/#operation/api.reports.archives.exports.post */ exportUserReportArchive(userId, archiveId, request = {}) { const url = `${this.url}/users/${userId}/reports/archives/${archiveId}/exports`; return this.post(url, request, this.defaultConfig()); } /** * @param userId user identifier * @param archiveId archive identifier * @param exportId export identifier * @see https://developer.crowdin.com/api/v2/#operation/api.users.reports.archives.exports.get */ checkUserReportArchiveStatus(userId, archiveId, exportId) { const url = `${this.url}/users/${userId}/reports/archives/${archiveId}/exports/${exportId}`; return this.get(url, this.defaultConfig()); } /** * @param userId user identifier * @param archiveId archive identifier * @param exportId export identifier * @see https://developer.crowdin.com/api/v2/#operation/api.users.reports.archives.exports.download.get */ downloadUserReportArchive(userId, archiveId, exportId) { const url = `${this.url}/users/${userId}/reports/archives/${archiveId}/exports/${exportId}/download`; return this.get(url, this.defaultConfig()); } /** * @param groupId group identifier * @param request request body * @see https://support.crowdin.com/enterprise/api/#operation/api.groups.reports.post */ generateGroupReport(groupId, request) { const url = `${this.url}/groups/${groupId}/reports`; return this.post(url, request, this.defaultConfig()); } /** * @param groupId group identifier * @param reportId report identifier * @see https://support.crowdin.com/enterprise/api/#operation/api.groups.reports.get */ checkGroupReportStatus(groupId, reportId) { const url = `${this.url}/groups/${groupId}/reports/${reportId}`; return this.get(url, this.defaultConfig()); } /** * @param groupId group identifier * @param reportId report identifier * @see https://support.crowdin.com/enterprise/api/#operation/api.groups.reports.download.download */ downloadGroupReport(groupId, reportId) { const url = `${this.url}/groups/${groupId}/reports/${reportId}/download`; return this.get(url, this.defaultConfig()); } /** * @param options optional parameters for the request * @see https://support.crowdin.com/developer/enterprise/api/v2/#tag/Reports/operation/api.reports.settings-templates.getMany */ listOrganizationReportSettingsTemplates(options) { let url = `${this.url}/reports/settings-templates`; url = this.addQueryParam(url, 'projectId', options === null || options === void 0 ? void 0 : options.projectId); url = this.addQueryParam(url, 'groupId', options === null || options === void 0 ? void 0 : options.groupId); return this.getList(url, options === null || options === void 0 ? void 0 : options.limit, options === null || options === void 0 ? void 0 : options.offset); } /** * @param request request body * @see https://support.crowdin.com/developer/enterprise/api/v2/#tag/Reports/operation/api.reports.settings-templates.post */ addOrganizationReportSettingsTemplate(request) { const url = `${this.url}/reports/settings-templates`; return this.post(url, request, this.defaultConfig()); } /** * @param reportSettingsTemplateId report settings template identifier * @see https://support.crowdin.com/developer/enterprise/api/v2/#tag/Reports/operation/api.reports.settings-templates.get */ getOrganizationReportSettingsTemplate(reportSettingsTemplateId) { const url = `${this.url}/reports/settings-templates/${reportSettingsTemplateId}`; return this.get(url, this.defaultConfig()); } /** * @param reportSettingsTemplateId report settings template identifier * @param request request body * @see https://support.crowdin.com/developer/enterprise/api/v2/#tag/Reports/operation/api.reports.settings-templates.patch */ editOrganizationReportSettingsTemplate(reportSettingsTemplateId, request) { const url = `${this.url}/reports/settings-templates/${reportSettingsTemplateId}`; return this.patch(url, request, this.defaultConfig()); } /** * @param reportSettingsTemplateId report settings template identifier * @see https://support.crowdin.com/developer/enterprise/api/v2/#tag/Reports/operation/api.reports.settings-templates.delete */ deleteOrganizationReportSettingsTemplate(reportSettingsTemplateId) { const url = `${this.url}/reports/settings-templates/${reportSettingsTemplateId}`; return this.delete(url, this.defaultConfig()); } /** * @param request request body * @see https://support.crowdin.com/enterprise/api/#operation/api.reports.post */ generateOrganizationReport(request) { const url = `${this.url}/reports`; return this.post(url, request, this.defaultConfig()); } /** * @param reportId report identifier * @see https://support.crowdin.com/enterprise/api/#operation/api.reports.get */ checkOrganizationReportStatus(reportId) { const url = `${this.url}/reports/${reportId}`; return this.get(url, this.defaultConfig()); } /** * @param reportId report identifier * @see https://support.crowdin.com/enterprise/api/#operation/api.reports.download.download */ downloadOrganizationReport(reportId) { const url = `${this.url}/reports/${reportId}/download`; return this.get(url, this.defaultConfig()); } /** * @param projectId project identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.reports.post */ generateReport(projectId, request) { const url = `${this.url}/projects/${projectId}/reports`; return this.post(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param reportId report identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.reports.get */ checkReportStatus(projectId, reportId) { const url = `${this.url}/projects/${projectId}/reports/${reportId}`; return this.get(url, this.defaultConfig()); } /** * @param projectId project identifier * @param reportId report identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.reports.download.download */ downloadReport(projectId, reportId) { const url = `${this.url}/projects/${projectId}/reports/${reportId}/download`; return this.get(url, this.defaultConfig()); } /** * @param projectId project identifier * @param options optional parameters for the request * @see https://developer.crowdin.com/api/v2/#operation/api.projects.reports.settings-templates.getMany */ listReportSettingsTemplates(projectId, options) { const url = `${this.url}/projects/${projectId}/reports/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.reports.settings-templates.post */ addReportSettingsTemplate(projectId, request) { const url = `${this.url}/projects/${projectId}/reports/settings-templates`; return this.post(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param reportSettingsTemplateId report settings template identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.reports.settings-templates.get */ getReportSettingsTemplate(projectId, reportSettingsTemplateId) { const url = `${this.url}/projects/${projectId}/reports/settings-templates/${reportSettingsTemplateId}`; return this.get(url, this.defaultConfig()); } /** * @param projectId project identifier * @param reportSettingsTemplateId report settings template identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.reports.settings-templates.patch */ editReportSettingsTemplate(projectId, reportSettingsTemplateId, request) { const url = `${this.url}/projects/${projectId}/reports/settings-templates/${reportSettingsTemplateId}`; return this.patch(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param reportSettingsTemplateId report settings template identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.settings-templates.delete */ deleteReportSettingsTemplate(projectId, reportSettingsTemplateId) { const url = `${this.url}/projects/${projectId}/reports/settings-templates/${reportSettingsTemplateId}`; return this.delete(url, this.defaultConfig()); } /** * @param userId user identifier * @param options optional parameters for the request * @see https://support.crowdin.com/developer/api/v2/#tag/Reports/operation/api.users.reports.settings-templates.getMany */ listUserReportSettingsTemplates(userId, options) { const url = `${this.url}/users/${userId}/reports/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 userId user identifier * @param request request body * @see https://support.crowdin.com/developer/api/v2/#tag/Reports/operation/api.users.reports.settings-templates.post */ addUserReportSettingsTemplate(userId, request) { const url = `${this.url}/users/${userId}/reports/settings-templates`; return this.post(url, request, this.defaultConfig()); } /** * @param userId user identifier * @param reportSettingsTemplateId report settings template identifier * @see https://support.crowdin.com/developer/api/v2/#tag/Reports/operation/api.users.reports.settings-templates.get */ getUserReportSettingsTemplate(userId, reportSettingsTemplateId) { const url = `${this.url}/users/${userId}/reports/settings-templates/${reportSettingsTemplateId}`; return this.get(url, this.defaultConfig()); } /** * @param userId user identifier * @param reportSettingsTemplateId report settings template identifier * @param request request body * @see https://support.crowdin.com/developer/api/v2/#tag/Reports/operation/api.users.reports.settings-templates.patch */ editUserReportSettingsTemplate(userId, reportSettingsTemplateId, request) { const url = `${this.url}/users/${userId}/reports/settings-templates/${reportSettingsTemplateId}`; return this.patch(url, request, this.defaultConfig()); } /** * @param userId user identifier * @param reportSettingsTemplateId report settings template identifier * @see https://support.crowdin.com/developer/api/v2/#tag/Reports/operation/api.users.reports.settings-templates.delete */ deleteUserReportSettingsTemplate(userId, reportSettingsTemplateId) { const url = `${this.url}/users/${userId}/reports/settings-templates/${reportSettingsTemplateId}`; return this.delete(url, this.defaultConfig()); } } exports.Reports = Reports;