deno.land / x / gesso@v0.1.2 / src / Accounts.ts
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269import { BaseApi } from "./BaseApi.ts";import { Configuration } from "./Configuration.ts";import { Account, Course, HelpLink, TermsOfService, User,} from "../types/models.ts";import { CreateNewSubaccountParams, GetTheSubaccountsOfAnAccountParams, ListAccountsParams, ListActiveCoursesInAnAccountParams, PermissionsParams, UpdateAnAccountParams,} from "../types/params.ts";
export class Accounts extends BaseApi { constructor(config: Configuration) { super(config); }
public async listAccounts( params?: ListAccountsParams, body?: unknown, ): Promise<Account[]> { const endpoint = "/api/v1/accounts"; 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 Account[]; }
return Promise.reject(response); }
public async getAccountsThatAdminsCanManage( body?: unknown, ): Promise<Account[]> { const endpoint = "/api/v1/manageable_accounts"; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Account[]; }
return Promise.reject(response); }
public async listAccountsForCourseAdmins(body?: unknown): Promise<Account[]> { const endpoint = "/api/v1/course_accounts"; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Account[]; }
return Promise.reject(response); }
public async getSingleAccount(id: string, body?: unknown): Promise<Account> { const endpoint = `/api/v1/accounts/${id}`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Account; }
return Promise.reject(response); }
public async settings(account_id: string, body?: unknown): Promise<Account> { const endpoint = `/api/v1/accounts/${account_id}/settings`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Account; }
return Promise.reject(response); }
public async permissions( account_id: string, params?: PermissionsParams, body?: unknown, ): Promise<Course> { const endpoint = `/api/v1/accounts/${account_id}/permissions`; 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 Course; }
return Promise.reject(response); }
public async getTheSubaccountsOfAnAccount( account_id: string, params?: GetTheSubaccountsOfAnAccountParams, body?: unknown, ): Promise<Account[]> { const endpoint = `/api/v1/accounts/${account_id}/sub_accounts`; 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 Account[]; }
return Promise.reject(response); }
public async getTheTermsOfService( account_id: string, body?: unknown, ): Promise<TermsOfService> { const endpoint = `/api/v1/accounts/${account_id}/terms_of_service`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as TermsOfService; }
return Promise.reject(response); }
public async getHelpLinks( account_id: string, body?: unknown, ): Promise<HelpLink> { const endpoint = `/api/v1/accounts/${account_id}/help_links`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as HelpLink; }
return Promise.reject(response); }
public async getTheManuallycreatedCoursesSubaccountForTheDomainRootAccount( body?: unknown, ): Promise<Account> { const endpoint = "/api/v1/manually_created_courses_account"; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Account; }
return Promise.reject(response); }
public async listActiveCoursesInAnAccount( account_id: string, params?: ListActiveCoursesInAnAccountParams, body?: unknown, ): Promise<Course[]> { const endpoint = `/api/v1/accounts/${account_id}/courses`; 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 Course[]; }
return Promise.reject(response); }
public async updateAnAccount( id: string, params?: UpdateAnAccountParams, body?: unknown, ): Promise<Account> { const endpoint = `/api/v1/accounts/${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 Account; }
return Promise.reject(response); }
public async deleteUserFromTheRootAccount( account_id: string, user_id: string, body?: unknown, ): Promise<User> { const endpoint = `/api/v1/accounts/${account_id}/users/${user_id}`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.delete(url, JSON.stringify(body)); if (response.ok) { return await response.json() as User; }
return Promise.reject(response); }
public async createNewSubaccount( account_id: string, params?: CreateNewSubaccountParams, body?: unknown, ): Promise<Account> { const endpoint = `/api/v1/accounts/${account_id}/sub_accounts`; 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 Account; }
return Promise.reject(response); }
public async deleteSubaccount( account_id: string, id: string, body?: unknown, ): Promise<Account> { const endpoint = `/api/v1/accounts/${account_id}/sub_accounts/${id}`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.delete(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Account; }
return Promise.reject(response); }}
Version Info