UNPKG

@datocms/cma-client

Version:
126 lines 4.05 kB
import * as Utils from '@datocms/rest-client-utils'; import BaseResource from '../../BaseResource'; export default class UploadTrack extends BaseResource { /** * Create a new upload track * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-track/create * * @throws {ApiError} * @throws {TimeoutError} */ create(uploadId, body) { return this.rawCreate(Utils.toId(uploadId), Utils.serializeRequestBody(body, { type: 'upload_track', attributes: [ 'url_or_upload_request_id', 'type', 'name', 'language_code', 'closed_captions', ], relationships: [], })).then((body) => Utils.deserializeResponseBody(body)); } /** * Create a new upload track * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-track/create * * @throws {ApiError} * @throws {TimeoutError} */ rawCreate(uploadId, body) { return this.client.request({ method: 'POST', url: `/uploads/${uploadId}/tracks`, body, }); } /** * List upload tracks * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-track/instances * * @throws {ApiError} * @throws {TimeoutError} */ list(uploadId) { return this.rawList(Utils.toId(uploadId)).then((body) => Utils.deserializeResponseBody(body)); } /** * List upload tracks * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-track/instances * * @throws {ApiError} * @throws {TimeoutError} */ rawList(uploadId) { return this.client.request({ method: 'GET', url: `/uploads/${uploadId}/tracks`, }); } /** * Delete an upload track * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-track/destroy * * @throws {ApiError} * @throws {TimeoutError} */ destroy(uploadId, uploadTrackId) { return this.rawDestroy(Utils.toId(uploadId), Utils.toId(uploadTrackId)).then((body) => Utils.deserializeResponseBody(body)); } /** * Delete an upload track * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-track/destroy * * @throws {ApiError} * @throws {TimeoutError} */ rawDestroy(uploadId, uploadTrackId) { return this.client.request({ method: 'DELETE', url: `/uploads/${uploadId}/tracks/${uploadTrackId}`, }); } /** * Automatically generate a subtitles track * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-track/generate_subtitles * * @throws {ApiError} * @throws {TimeoutError} * * @deprecated This API call is to be considered private and might change without notice */ generateSubtitles(uploadId, body) { return this.rawGenerateSubtitles(Utils.toId(uploadId), Utils.serializeRequestBody(body, { type: 'upload_track', attributes: ['name', 'language_code'], relationships: [], })).then((body) => Utils.deserializeResponseBody(body)); } /** * Automatically generate a subtitles track * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-track/generate_subtitles * * @throws {ApiError} * @throws {TimeoutError} * * @deprecated This API call is to be considered private and might change without notice */ rawGenerateSubtitles(uploadId, body) { return this.client.request({ method: 'POST', url: `/uploads/${uploadId}/tracks/generate-subtitles`, body, }); } } UploadTrack.TYPE = 'upload_track'; //# sourceMappingURL=UploadTrack.js.map