UNPKG

@datocms/cma-client

Version:
177 lines 5.62 kB
import * as Utils from '@datocms/rest-client-utils'; import BaseResource from '../../BaseResource'; export default class SchemaMenuItem extends BaseResource { /** * Create a new schema menu item * * Read more: https://www.datocms.com/docs/content-management-api/resources/schema-menu_item/create * * @throws {ApiError} * @throws {TimeoutError} */ create(body) { return this.rawCreate(Utils.serializeRequestBody(body, { type: 'schema_menu_item', attributes: ['label', 'position', 'kind'], relationships: ['item_type', 'parent'], })).then((body) => Utils.deserializeResponseBody(body)); } /** * Create a new schema menu item * * Read more: https://www.datocms.com/docs/content-management-api/resources/schema-menu_item/create * * @throws {ApiError} * @throws {TimeoutError} */ rawCreate(body) { return this.client.request({ method: 'POST', url: '/schema-menu-items', body, }); } /** * Update a schema menu item * * Read more: https://www.datocms.com/docs/content-management-api/resources/schema-menu_item/update * * @throws {ApiError} * @throws {TimeoutError} */ update(schemaMenuItemId, body) { return this.rawUpdate(Utils.toId(schemaMenuItemId), Utils.serializeRequestBody(body, { id: Utils.toId(schemaMenuItemId), type: 'schema_menu_item', attributes: ['label', 'position', 'kind'], relationships: ['item_type', 'parent', 'children'], })).then((body) => Utils.deserializeResponseBody(body)); } /** * Update a schema menu item * * Read more: https://www.datocms.com/docs/content-management-api/resources/schema-menu_item/update * * @throws {ApiError} * @throws {TimeoutError} */ rawUpdate(schemaMenuItemId, body) { return this.client.request({ method: 'PUT', url: `/schema-menu-items/${schemaMenuItemId}`, body, }); } /** * List all schema menu items * * Read more: https://www.datocms.com/docs/content-management-api/resources/schema-menu_item/instances * * @throws {ApiError} * @throws {TimeoutError} */ list(queryParams) { return this.rawList(queryParams).then((body) => Utils.deserializeResponseBody(body)); } /** * List all schema menu items * * Read more: https://www.datocms.com/docs/content-management-api/resources/schema-menu_item/instances * * @throws {ApiError} * @throws {TimeoutError} */ rawList(queryParams) { return this.client.request({ method: 'GET', url: '/schema-menu-items', queryParams, }); } /** * Retrieve a schema menu item * * Read more: https://www.datocms.com/docs/content-management-api/resources/schema-menu_item/self * * @throws {ApiError} * @throws {TimeoutError} */ find(schemaMenuItemId) { return this.rawFind(Utils.toId(schemaMenuItemId)).then((body) => Utils.deserializeResponseBody(body)); } /** * Retrieve a schema menu item * * Read more: https://www.datocms.com/docs/content-management-api/resources/schema-menu_item/self * * @throws {ApiError} * @throws {TimeoutError} */ rawFind(schemaMenuItemId) { return this.client.request({ method: 'GET', url: `/schema-menu-items/${schemaMenuItemId}`, }); } /** * Delete a schema menu item * * Read more: https://www.datocms.com/docs/content-management-api/resources/schema-menu_item/destroy * * @throws {ApiError} * @throws {TimeoutError} */ destroy(schemaMenuItemId) { return this.rawDestroy(Utils.toId(schemaMenuItemId)).then((body) => Utils.deserializeResponseBody(body)); } /** * Delete a schema menu item * * Read more: https://www.datocms.com/docs/content-management-api/resources/schema-menu_item/destroy * * @throws {ApiError} * @throws {TimeoutError} */ rawDestroy(schemaMenuItemId) { return this.client.request({ method: 'DELETE', url: `/schema-menu-items/${schemaMenuItemId}`, }); } /** * Reorders a set of schema menu items * * Read more: https://www.datocms.com/docs/content-management-api/resources/schema-menu_item/reorder * * @throws {ApiError} * @throws {TimeoutError} * * @deprecated This API call is to be considered private and might change without notice */ reorder(body) { return this.rawReorder(Utils.serializeRequestBody(body, { type: 'schema_menu_item', attributes: ['position'], relationships: ['parent'], })).then((body) => Utils.deserializeResponseBody(body)); } /** * Reorders a set of schema menu items * * Read more: https://www.datocms.com/docs/content-management-api/resources/schema-menu_item/reorder * * @throws {ApiError} * @throws {TimeoutError} * * @deprecated This API call is to be considered private and might change without notice */ rawReorder(body) { return this.client.request({ method: 'POST', url: '/schema-menu-items/reorder', body, }); } } SchemaMenuItem.TYPE = 'schema_menu_item'; //# sourceMappingURL=SchemaMenuItem.js.map