UNPKG

@bunnyapp/api-client

Version:
45 lines 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = tenantUpdate; const query = `mutation tenantUpdate ($id: ID!, $attributes: TenantAttributes!) { tenantUpdate (id: $id, attributes: $attributes) { tenant { code id name platform { id name code } } errors } }`; /** * Updates an existing tenant * @param {string} id The ID of the tenant to update * @param {string} code New code for the tenant * @param {string} name New name for the tenant * @returns {Promise<NonNullable<Mutation['tenantUpdate']>['tenant']>} The updated tenant */ async function tenantUpdate(id, code, name) { var _a, _b; const variables = { id, attributes: { code: code === null || code === void 0 ? void 0 : code.toString(), name, }, }; const res = await this.query(query, variables); const tenantUpdate = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.tenantUpdate; if (res === null || res === void 0 ? void 0 : res.errors) { throw new Error(res.errors.map((e) => e.message).join()); } if (tenantUpdate === null || tenantUpdate === void 0 ? void 0 : tenantUpdate.errors) { throw new Error(tenantUpdate.errors.join()); } return (_b = tenantUpdate === null || tenantUpdate === void 0 ? void 0 : tenantUpdate.tenant) !== null && _b !== void 0 ? _b : undefined; } //# sourceMappingURL=tenant-update.js.map