@bunnyapp/api-client
Version:
Node.js client for Bunny CRM
36 lines • 1.53 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = tenantMetricsUpdate;
const query = `mutation tenantMetricsUpdate ($code: String!, $attributes: TenantMetricsAttributes!){
tenantMetricsUpdate (code: $code, attributes: $attributes) {
errors
}
}`;
/**
* Update tenant metrics
* @param {string} code The code of the tenant
* @param {string} lastLogin The last login date of the tenant
* @param {number} userCount The number of users in the tenant
* @param {Record<string, any>} utilizationMetrics The utilization metrics of the tenant
**/
async function tenantMetricsUpdate(code, lastLogin, userCount, utilizationMetrics) {
var _a;
let variables = {
code: code === null || code === void 0 ? void 0 : code.toString(),
attributes: {
lastLogin: lastLogin,
userCount: userCount,
utilizationMetrics: utilizationMetrics,
},
};
const res = await this.query(query, variables);
const tenantMetricsUpdate = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.tenantMetricsUpdate;
if (res === null || res === void 0 ? void 0 : res.errors) {
throw new Error(res.errors.map((e) => e.message).join());
}
if (tenantMetricsUpdate === null || tenantMetricsUpdate === void 0 ? void 0 : tenantMetricsUpdate.errors) {
throw new Error(tenantMetricsUpdate.errors.join());
}
return true;
}
//# sourceMappingURL=tenant-metrics-update.js.map