import { AppcondaException, Client, Models, Payload } from "../client"; export class Roles { client: Client; constructor(client: Client) { this.client = client; } async get(roleId: string): Promise { if (typeof roleId === 'undefined') { throw new AppcondaException('Missing required parameter: "tenantId"'); } const apiPath = '/roles/{roleId}'.replace('{roleId}', roleId); 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, description}: Models.Role): Promise { if (typeof $id === 'undefined') { throw new AppcondaException('Missing required parameter: "roleId"'); } if (typeof name === 'undefined') { throw new AppcondaException('Missing required parameter: "name"'); } if (typeof description === 'undefined') { throw new AppcondaException('Missing required parameter: "description"'); } const apiPath = '/roles'; const payload: Payload = {}; if (typeof $id !== 'undefined') { payload['roleId'] = $id; } if (typeof name !== 'undefined') { payload['name'] = name; } if (typeof description !== 'undefined') { payload['description'] = description; } 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 = '/roles'; 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, ); } }