UNPKG

@datocms/cma-client

Version:
69 lines 2.1 kB
import * as Utils from '@datocms/rest-client-utils'; import BaseResource from '../../BaseResource.js'; export default class Session extends BaseResource { /** * Create a new session * * Read more: https://www.datocms.com/docs/content-management-api/resources/session/create * * @throws {ApiError} * @throws {TimeoutError} * * @deprecated This API call is to be considered private and might change without notice */ create(body) { return this.rawCreate(Utils.serializeRequestBody(body, { type: 'email_credentials', attributes: ['email', 'password', 'otp_code'], relationships: [], })).then((body) => Utils.deserializeResponseBody(body)); } /** * Create a new session * * Read more: https://www.datocms.com/docs/content-management-api/resources/session/create * * @throws {ApiError} * @throws {TimeoutError} * * @deprecated This API call is to be considered private and might change without notice */ rawCreate(body) { return this.client.request({ method: 'POST', url: '/sessions', body, }); } /** * Destroy the current session * * Read more: https://www.datocms.com/docs/content-management-api/resources/session/destroy * * @throws {ApiError} * @throws {TimeoutError} * * @deprecated This API call is to be considered private and might change without notice */ destroy() { return this.rawDestroy(); } /** * Destroy the current session * * Read more: https://www.datocms.com/docs/content-management-api/resources/session/destroy * * @throws {ApiError} * @throws {TimeoutError} * * @deprecated This API call is to be considered private and might change without notice */ rawDestroy() { return this.client.request({ method: 'DELETE', url: '/session', }); } } Session.TYPE = 'session'; //# sourceMappingURL=Session.js.map