@datocms/cma-client
Version:
JS client for DatoCMS REST Content Management API
155 lines • 5.52 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import * as Utils from '@datocms/rest-client-utils';
import BaseResource from '../../BaseResource';
var UploadTrack = /** @class */ (function (_super) {
__extends(UploadTrack, _super);
function UploadTrack() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Create a new upload track
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/upload-track/create
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
UploadTrack.prototype.create = function (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(function (body) {
return 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}
*/
UploadTrack.prototype.rawCreate = function (uploadId, body) {
return this.client.request({
method: 'POST',
url: "/uploads/".concat(uploadId, "/tracks"),
body: body,
});
};
/**
* List upload tracks
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/upload-track/instances
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
UploadTrack.prototype.list = function (uploadId) {
return this.rawList(Utils.toId(uploadId)).then(function (body) {
return Utils.deserializeResponseBody(body);
});
};
/**
* List upload tracks
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/upload-track/instances
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
UploadTrack.prototype.rawList = function (uploadId) {
return this.client.request({
method: 'GET',
url: "/uploads/".concat(uploadId, "/tracks"),
});
};
/**
* Delete an upload track
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/upload-track/destroy
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
UploadTrack.prototype.destroy = function (uploadId, uploadTrackId) {
return this.rawDestroy(Utils.toId(uploadId), Utils.toId(uploadTrackId)).then(function (body) {
return 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}
*/
UploadTrack.prototype.rawDestroy = function (uploadId, uploadTrackId) {
return this.client.request({
method: 'DELETE',
url: "/uploads/".concat(uploadId, "/tracks/").concat(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
*/
UploadTrack.prototype.generateSubtitles = function (uploadId, body) {
return this.rawGenerateSubtitles(Utils.toId(uploadId), Utils.serializeRequestBody(body, {
type: 'upload_track',
attributes: ['name', 'language_code'],
relationships: [],
})).then(function (body) {
return 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
*/
UploadTrack.prototype.rawGenerateSubtitles = function (uploadId, body) {
return this.client.request({
method: 'POST',
url: "/uploads/".concat(uploadId, "/tracks/generate-subtitles"),
body: body,
});
};
UploadTrack.TYPE = 'upload_track';
return UploadTrack;
}(BaseResource));
export default UploadTrack;
//# sourceMappingURL=UploadTrack.js.map