UNPKG

@datocms/cma-client

Version:
173 lines 5.77 kB
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 UploadFilter = /** @class */ (function (_super) { __extends(UploadFilter, _super); function UploadFilter() { return _super !== null && _super.apply(this, arguments) || this; } /** * Create a new filter * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/create * * @throws {ApiError} * @throws {TimeoutError} */ UploadFilter.prototype.create = function (body) { return this.rawCreate(Utils.serializeRequestBody(body, { type: 'upload_filter', attributes: ['name', 'filter', 'shared'], relationships: [], })).then(function (body) { return Utils.deserializeResponseBody(body); }); }; /** * Create a new filter * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/create * * @throws {ApiError} * @throws {TimeoutError} */ UploadFilter.prototype.rawCreate = function (body) { return this.client.request({ method: 'POST', url: '/upload-filters', body: body, }); }; /** * Update a filter * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/update * * @throws {ApiError} * @throws {TimeoutError} */ UploadFilter.prototype.update = function (uploadFilterId, body) { return this.rawUpdate(Utils.toId(uploadFilterId), Utils.serializeRequestBody(body, { id: Utils.toId(uploadFilterId), type: 'upload_filter', attributes: ['name', 'shared', 'filter'], relationships: [], })).then(function (body) { return Utils.deserializeResponseBody(body); }); }; /** * Update a filter * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/update * * @throws {ApiError} * @throws {TimeoutError} */ UploadFilter.prototype.rawUpdate = function (uploadFilterId, body) { return this.client.request({ method: 'PUT', url: "/upload-filters/".concat(uploadFilterId), body: body, }); }; /** * List all filters * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/instances * * @throws {ApiError} * @throws {TimeoutError} */ UploadFilter.prototype.list = function () { return this.rawList().then(function (body) { return Utils.deserializeResponseBody(body); }); }; /** * List all filters * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/instances * * @throws {ApiError} * @throws {TimeoutError} */ UploadFilter.prototype.rawList = function () { return this.client.request({ method: 'GET', url: '/upload-filters', }); }; /** * Retrieve a filter * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/self * * @throws {ApiError} * @throws {TimeoutError} */ UploadFilter.prototype.find = function (uploadFilterId) { return this.rawFind(Utils.toId(uploadFilterId)).then(function (body) { return Utils.deserializeResponseBody(body); }); }; /** * Retrieve a filter * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/self * * @throws {ApiError} * @throws {TimeoutError} */ UploadFilter.prototype.rawFind = function (uploadFilterId) { return this.client.request({ method: 'GET', url: "/upload-filters/".concat(uploadFilterId), }); }; /** * Delete a filter * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/destroy * * @throws {ApiError} * @throws {TimeoutError} */ UploadFilter.prototype.destroy = function (uploadFilterId) { return this.rawDestroy(Utils.toId(uploadFilterId)).then(function (body) { return Utils.deserializeResponseBody(body); }); }; /** * Delete a filter * * Read more: https://www.datocms.com/docs/content-management-api/resources/upload-filter/destroy * * @throws {ApiError} * @throws {TimeoutError} */ UploadFilter.prototype.rawDestroy = function (uploadFilterId) { return this.client.request({ method: 'DELETE', url: "/upload-filters/".concat(uploadFilterId), }); }; UploadFilter.TYPE = 'upload_filter'; return UploadFilter; }(BaseResource)); export default UploadFilter; //# sourceMappingURL=UploadFilter.js.map