UNPKG

@bunnyapp/api-client

Version:
71 lines 2.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = accountUpdateByTenantCode; const query = `mutation accountUpdate ($id: ID!, $attributes: AccountAttributes!) { accountUpdate (id: $id, attributes: $attributes) { account { accountTypeId addressValidated annualRevenue billingCity billingContactId billingCountry billingDay billingState billingStreet billingZip code createdAt currencyId description duns employees entityUseCode fax groupId id industryId name netPaymentDays ownerUserId phone shippingCity shippingCountry shippingState shippingStreet shippingZip taxNumber timezone updatedAt website } errors } }`; /** * Update an account by tenant code * @param {string} tenantCode The unique code that represents the tenant * @param {AccountAttributes} attributes The attributes to update the account with * @returns {Promise<NonNullable<NonNullable<Mutation['accountUpdate']>['account']> | undefined>} The updated account */ async function accountUpdateByTenantCode(tenantCode, attributes) { var _a, _b; const tenant = await this.tenantByCode(tenantCode); if (!tenant) { throw new Error('Tenant not found'); } const variables = { id: tenant.account.id, attributes: attributes, }; const res = await this.query(query, variables); const accountUpdate = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.accountUpdate; if (res === null || res === void 0 ? void 0 : res.errors) { throw new Error(Array.isArray(res.errors) ? res.errors.map(e => e.message).join() : res.errors); } if (accountUpdate === null || accountUpdate === void 0 ? void 0 : accountUpdate.errors) { throw new Error(Array.isArray(accountUpdate.errors) ? accountUpdate.errors.join() : accountUpdate.errors); } return (_b = accountUpdate === null || accountUpdate === void 0 ? void 0 : accountUpdate.account) !== null && _b !== void 0 ? _b : undefined; } //# sourceMappingURL=account-update-by-tenant-code.js.map