deno.land / x / gesso@v0.1.2 / src / Roles.ts
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142import { BaseApi } from "./BaseApi.ts";import { Configuration } from "./Configuration.ts";import { Role } from "../types/models.ts";import { ActivateRoleParams, CreateNewRoleParams, DeactivateRoleParams, GetSingleRoleParams, ListRolesParams, UpdateRoleParams,} from "../types/params.ts";
export class Roles extends BaseApi { constructor(config: Configuration) { super(config); }
public async listRoles( account_id: string, params?: ListRolesParams, body?: unknown, ): Promise<Role[]> { const endpoint = `/api/v1/accounts/${account_id}/roles`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Role[]; }
return Promise.reject(response); }
public async getSingleRole( account_id: string, id: string, params?: GetSingleRoleParams, body?: unknown, ): Promise<Role> { const endpoint = `/api/v1/accounts/${account_id}/roles/${id}`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Role; }
return Promise.reject(response); }
public async createNewRole( account_id: string, params?: CreateNewRoleParams, body?: unknown, ): Promise<Role> { const endpoint = `/api/v1/accounts/${account_id}/roles`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.post(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Role; }
return Promise.reject(response); }
public async deactivateRole( account_id: string, id: string, params?: DeactivateRoleParams, body?: unknown, ): Promise<Role> { const endpoint = `/api/v1/accounts/${account_id}/roles/${id}`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.delete(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Role; }
return Promise.reject(response); }
public async activateRole( account_id: string, id: string, params?: ActivateRoleParams, body?: unknown, ): Promise<Role> { const endpoint = `/api/v1/accounts/${account_id}/roles/${id}/activate`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.post(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Role; }
return Promise.reject(response); }
public async updateRole( account_id: string, id: string, params?: UpdateRoleParams, body?: unknown, ): Promise<Role> { const endpoint = `/api/v1/accounts/${account_id}/roles/${id}`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.put(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Role; }
return Promise.reject(response); }}
Version Info