deno.land / x / gesso@v0.1.2 / src / Groups.ts
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349import { BaseApi } from "./BaseApi.ts";import { Configuration } from "./Configuration.ts";import { Account, Group, Scope, User } from "../types/models.ts";import { CreateGroupParams, CreateMembershipParams, EditGroupParams, GetSingleGroupParams, InviteOthersToGroupParams, ListGroupMembershipsParams, ListGroupsParams, ListGroupsUsersParams, ListTheGroupsAvailableInContextParams, PermissionsParams, PreviewProcessedHtmlParams, UpdateMembershipParams,} from "../types/params.ts";
export class Groups extends BaseApi { constructor(config: Configuration) { super(config); }
public async listGroups( params?: ListGroupsParams, body?: unknown, ): Promise<Group[]> { const endpoint = "/api/v1/users/self/groups"; 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 Group[]; }
return Promise.reject(response); }
public async listTheGroupsAvailableInContext( account_id: string, params?: ListTheGroupsAvailableInContextParams, body?: unknown, ): Promise<Group[]> { const endpoint = `/api/v1/accounts/${account_id}/groups`; 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 Group[]; }
return Promise.reject(response); }
public async getSingleGroup( group_id: string, params?: GetSingleGroupParams, body?: unknown, ): Promise<Group> { const endpoint = `/api/v1/groups/${group_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 Group; }
return Promise.reject(response); }
public async createGroup( params?: CreateGroupParams, body?: unknown, ): Promise<Group> { const endpoint = "/api/v1/groups"; 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 Group; }
return Promise.reject(response); }
public async editGroup( group_id: string, params?: EditGroupParams, body?: unknown, ): Promise<Group> { const endpoint = `/api/v1/groups/${group_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 Group; }
return Promise.reject(response); }
public async deleteGroup(group_id: string, body?: unknown): Promise<Group> { const endpoint = `/api/v1/groups/${group_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 Group; }
return Promise.reject(response); }
public async inviteOthersToGroup( group_id: string, params?: InviteOthersToGroupParams, body?: unknown, ): Promise<Scope> { const endpoint = `/api/v1/groups/${group_id}/invite`; 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 Scope; }
return Promise.reject(response); }
public async listGroupsUsers( group_id: string, params?: ListGroupsUsersParams, body?: unknown, ): Promise<User[]> { const endpoint = `/api/v1/groups/${group_id}/users`; 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 User[]; }
return Promise.reject(response); }
public async uploadFile(group_id: string, body?: unknown): Promise<Scope> { const endpoint = `/api/v1/groups/${group_id}/files`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.post(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Scope; }
return Promise.reject(response); }
public async previewProcessedHtml( group_id: string, params?: PreviewProcessedHtmlParams, body?: unknown, ): Promise<Scope> { const endpoint = `/api/v1/groups/${group_id}/preview_html`; 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 Scope; }
return Promise.reject(response); }
public async groupActivityStream( group_id: string, body?: unknown, ): Promise<unknown> { const endpoint = `/api/v1/groups/${group_id}/activity_stream`; 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 unknown; }
return Promise.reject(response); }
public async groupActivityStreamSummary( group_id: string, body?: unknown, ): Promise<unknown> { const endpoint = `/api/v1/groups/${group_id}/activity_stream/summary`; 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 unknown; }
return Promise.reject(response); }
public async permissions( group_id: string, params?: PermissionsParams, body?: unknown, ): Promise<Account> { const endpoint = `/api/v1/groups/${group_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 Account; }
return Promise.reject(response); }
public async listGroupMemberships( group_id: string, params?: ListGroupMembershipsParams, body?: unknown, ): Promise<Group[]> { const endpoint = `/api/v1/groups/${group_id}/memberships`; 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 Group[]; }
return Promise.reject(response); }
public async getSingleGroupMembership( group_id: string, membership_id: string, body?: unknown, ): Promise<Group> { const endpoint = `/api/v1/groups/${group_id}/memberships/${membership_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 Group; }
return Promise.reject(response); }
public async createMembership( group_id: string, params?: CreateMembershipParams, body?: unknown, ): Promise<Group> { const endpoint = `/api/v1/groups/${group_id}/memberships`; 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 Group; }
return Promise.reject(response); }
public async updateMembership( group_id: string, membership_id: string, params?: UpdateMembershipParams, body?: unknown, ): Promise<Group> { const endpoint = `/api/v1/groups/${group_id}/memberships/${membership_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 Group; }
return Promise.reject(response); }
public async leaveGroup( group_id: string, membership_id: string, body?: unknown, ): Promise<Scope> { const endpoint = `/api/v1/groups/${group_id}/memberships/${membership_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 Scope; }
return Promise.reject(response); }}
Version Info