UNPKG

@starsched/sdk

Version:

ABA clinic control and management service API SDK

89 lines (88 loc) 2.8 kB
export class CompanyInvites { httpClient; constructor(httpClient) { this.httpClient = httpClient; } async list(input, options) { const { company_id, ...inputQueryParams } = input; const queryParams = {}; if (typeof inputQueryParams.limit === 'number') { queryParams.limit = inputQueryParams.limit; } if (typeof inputQueryParams.offset === 'number') { queryParams.offset = inputQueryParams.offset; } if (inputQueryParams.sort_by) { queryParams.sort_by = inputQueryParams.sort_by; } if (inputQueryParams.order_by) { queryParams.order_by = inputQueryParams.order_by; } const response = await this.httpClient.get(`/v1/companies/${company_id}/invites`, { queryParams, ...options }); if (!response.ok) { return { data: null, error: response.body }; } return { data: response.body, error: null }; } async create(input, options) { const { company_id, ...inputBody } = input; const response = await this.httpClient.post(`/v1/companies/${company_id}/invites`, inputBody, options); if (!response.ok) { return { data: null, error: response.body }; } return { data: response.body, error: null }; } async delete(input, options) { const response = await this.httpClient.delete(`/v1/companies/${input.company_id}/invites/${input.invite_id}`, options); if (!response.ok) { return { data: null, error: response.body }; } return { data: response.body, error: null }; } async updateRole(input, options) { const { company_id, invite_id, ...inputBody } = input; const response = await this.httpClient.patch(`/v1/companies/${company_id}/invites/${invite_id}/role`, inputBody, options); if (!response.ok) { return { data: null, error: response.body }; } return { data: response.body, error: null }; } async resend(input, options) { const { company_id, invite_id } = input; const response = await this.httpClient.post(`/v1/companies/${company_id}/invites/${invite_id}/resend`, undefined, options); if (!response.ok) { return { data: null, error: response.body }; } return { data: response.body, error: null }; } }