import { AppcondaException, Client, Models, Payload } from "../../client"; import { ServiceClient } from "../../service-client"; export type TenantSimple = { id: string; name: string; slug: string; icon: string | null; deactivatedReason: string | null; types: any[]; active: boolean; }; export class _TenantService extends ServiceClient { public getServiceName(): string { return 'com.appconda.service.tenant'; } async get(tenantId: string): Promise { if (typeof tenantId === 'undefined') { throw new AppcondaException('Missing required parameter: "tenantId"'); } const apiPath = '/tenants/{tenantId}'.replace('{tenantId}', tenantId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', } return await this.client.call( 'get', uri, apiHeaders, payload, ); } /** * Create account * * Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appconda.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appconda.io/docs/references/cloud/client-web/account#createEmailSession). * * @param {string} tenantId * @param {string} name * @param {string} slug * @throws {AppcondaException} * @returns {Promise>} */ async create({ $id, name, slug }: Models.Tenant): Promise { if (typeof $id === 'undefined') { throw new AppcondaException('Missing required parameter: "tenantId"'); } if (typeof name === 'undefined') { throw new AppcondaException('Missing required parameter: "name"'); } if (typeof slug === 'undefined') { throw new AppcondaException('Missing required parameter: "slug"'); } const apiPath = '/tenants'; const payload: Payload = {}; if (typeof $id !== 'undefined') { payload['tenantId'] = $id; } if (typeof name !== 'undefined') { payload['name'] = name; } if (typeof slug !== 'undefined') { payload['slug'] = slug; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', } return await this.client.call( 'post', uri, apiHeaders, payload, ); } async list(queries?: string[], search?: string): Promise { const apiPath = '/tenants'; const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } if (typeof search !== 'undefined') { payload['search'] = search; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', } return await this.client.call( 'get', uri, apiHeaders, payload, ); } async listUserTenants(userId: string, queries?: string[], search?: string): Promise { const apiPath = `/tenants/${userId}/tenants`; const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } if (typeof search !== 'undefined') { payload['search'] = search; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', } return await this.client.call( 'get', uri, apiHeaders, payload, ); } async listTenantUsers(tenantId: string, queries?: string[], search?: string): Promise { const apiPath = `/tenants/${tenantId}/users`; const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } if (typeof search !== 'undefined') { payload['search'] = search; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', } return await this.client.call( 'get', uri, apiHeaders, payload, ); } async createTenantUser({ tenantId, userId }: Models.TenantUser): Promise { if (typeof tenantId === 'undefined') { throw new AppcondaException('Missing required parameter: "tenantId"'); } if (typeof userId === 'undefined') { throw new AppcondaException('Missing required parameter: "userId"'); } const apiPath = `/tenants/${tenantId}/users`; const payload: Payload = {}; if (typeof userId !== 'undefined') { payload['userId'] = userId; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', } return await this.client.call( 'post', uri, apiHeaders, payload, ); } public async adminGetAllTenantsIdsAndNames(): Promise { const payload: Payload = {}; return await this.actionCall('AdminGetAllTenantsIdsAndNames', payload); } }