UNPKG

@datocms/cma-client

Version:
167 lines 5.04 kB
import * as Utils from '@datocms/rest-client-utils'; import BaseResource from '../../BaseResource'; export default class SiteInvitation extends BaseResource { /** * Invite a new user * * Read more: https://www.datocms.com/docs/content-management-api/resources/site-invitation/create * * @throws {ApiError} * @throws {TimeoutError} */ create(body) { return this.rawCreate(Utils.serializeRequestBody(body, { type: 'site_invitation', attributes: ['email'], relationships: ['role'], })).then((body) => Utils.deserializeResponseBody(body)); } /** * Invite a new user * * Read more: https://www.datocms.com/docs/content-management-api/resources/site-invitation/create * * @throws {ApiError} * @throws {TimeoutError} */ rawCreate(body) { return this.client.request({ method: 'POST', url: '/site-invitations', body, }); } /** * Update an invitation * * Read more: https://www.datocms.com/docs/content-management-api/resources/site-invitation/update * * @throws {ApiError} * @throws {TimeoutError} */ update(siteInvitationId, body) { return this.rawUpdate(Utils.toId(siteInvitationId), Utils.serializeRequestBody(body, { id: Utils.toId(siteInvitationId), type: 'site_invitation', attributes: [], relationships: ['role'], })).then((body) => Utils.deserializeResponseBody(body)); } /** * Update an invitation * * Read more: https://www.datocms.com/docs/content-management-api/resources/site-invitation/update * * @throws {ApiError} * @throws {TimeoutError} */ rawUpdate(siteInvitationId, body) { return this.client.request({ method: 'PUT', url: `/site-invitations/${siteInvitationId}`, body, }); } /** * List all invitations * * Read more: https://www.datocms.com/docs/content-management-api/resources/site-invitation/instances * * @throws {ApiError} * @throws {TimeoutError} */ list() { return this.rawList().then((body) => Utils.deserializeResponseBody(body)); } /** * List all invitations * * Read more: https://www.datocms.com/docs/content-management-api/resources/site-invitation/instances * * @throws {ApiError} * @throws {TimeoutError} */ rawList() { return this.client.request({ method: 'GET', url: '/site-invitations', }); } /** * Retrieve an invitation * * Read more: https://www.datocms.com/docs/content-management-api/resources/site-invitation/self * * @throws {ApiError} * @throws {TimeoutError} */ find(siteInvitationId) { return this.rawFind(Utils.toId(siteInvitationId)).then((body) => Utils.deserializeResponseBody(body)); } /** * Retrieve an invitation * * Read more: https://www.datocms.com/docs/content-management-api/resources/site-invitation/self * * @throws {ApiError} * @throws {TimeoutError} */ rawFind(siteInvitationId) { return this.client.request({ method: 'GET', url: `/site-invitations/${siteInvitationId}`, }); } /** * Delete an invitation * * Read more: https://www.datocms.com/docs/content-management-api/resources/site-invitation/destroy * * @throws {ApiError} * @throws {TimeoutError} */ destroy(siteInvitationId) { return this.rawDestroy(Utils.toId(siteInvitationId)).then((body) => Utils.deserializeResponseBody(body)); } /** * Delete an invitation * * Read more: https://www.datocms.com/docs/content-management-api/resources/site-invitation/destroy * * @throws {ApiError} * @throws {TimeoutError} */ rawDestroy(siteInvitationId) { return this.client.request({ method: 'DELETE', url: `/site-invitations/${siteInvitationId}`, }); } /** * Resend an invitation * * Read more: https://www.datocms.com/docs/content-management-api/resources/site-invitation/resend * * @throws {ApiError} * @throws {TimeoutError} */ resend(siteInvitationId) { return this.rawResend(Utils.toId(siteInvitationId)).then((body) => Utils.deserializeResponseBody(body)); } /** * Resend an invitation * * Read more: https://www.datocms.com/docs/content-management-api/resources/site-invitation/resend * * @throws {ApiError} * @throws {TimeoutError} */ rawResend(siteInvitationId) { return this.client.request({ method: 'POST', url: `/site-invitations/${siteInvitationId}/resend`, }); } } SiteInvitation.TYPE = 'site_invitation'; //# sourceMappingURL=SiteInvitation.js.map