@datocms/cma-client
Version:
JS client for DatoCMS REST Content Management API
69 lines • 2.1 kB
JavaScript
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