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