UNPKG

@datocms/cma-client

Version:
196 lines 6.35 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Utils = __importStar(require("@datocms/rest-client-utils")); const BaseResource_1 = __importDefault(require("../../BaseResource")); class SiteInvitation extends BaseResource_1.default { /** * 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`, }); } } exports.default = SiteInvitation; SiteInvitation.TYPE = 'site_invitation'; //# sourceMappingURL=SiteInvitation.js.map