@datocms/cma-client
Version:
JS client for DatoCMS REST Content Management API
63 lines • 2.11 kB
JavaScript
import * as Utils from '@datocms/rest-client-utils';
import BaseResource from '../../BaseResource';
export default class ScheduledPublication extends BaseResource {
/**
* Create a new scheduled publication
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/scheduled-publication/create
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
create(itemId, body) {
return this.rawCreate(Utils.toId(itemId), Utils.serializeRequestBody(body, {
type: 'scheduled_publication',
attributes: ['publication_scheduled_at', 'selective_publication'],
relationships: [],
})).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Create a new scheduled publication
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/scheduled-publication/create
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawCreate(itemId, body) {
return this.client.request({
method: 'POST',
url: `/items/${itemId}/scheduled-publication`,
body,
});
}
/**
* Delete a scheduled publication
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/scheduled-publication/destroy
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
destroy(itemId) {
return this.rawDestroy(Utils.toId(itemId)).then((body) => Utils.deserializeResponseBody(body));
}
/**
* Delete a scheduled publication
*
* Read more: https://www.datocms.com/docs/content-management-api/resources/scheduled-publication/destroy
*
* @throws {ApiError}
* @throws {TimeoutError}
*/
rawDestroy(itemId) {
return this.client
.request({
method: 'DELETE',
url: `/items/${itemId}/scheduled-publication`,
})
.then(Utils.deserializeRawResponseBodyWithItems);
}
}
ScheduledPublication.TYPE = 'scheduled_publication';
//# sourceMappingURL=ScheduledPublication.js.map