UNPKG

@starsched/sdk

Version:

ABA clinic control and management service API SDK

58 lines (57 loc) 1.67 kB
export class Accounts { httpClient; constructor(httpClient) { this.httpClient = httpClient; } async requestCompanySignUp(input, options) { const response = await this.httpClient.post('/v1/accounts/request', input, options); if (!response.ok) { return { data: null, error: response.body }; } return { data: null, error: null }; } async getCompanySignUpRequest(input, options) { try { const response = await this.httpClient.get(`/v1/accounts/${input.token}`, options); if (!response.ok) { return { data: null, error: response.body }; } return { data: response.body, error: null }; } catch (error) { return { data: null, error: { code: 'internal', message: 'Internal server error. We are unable to process your request right now, please try again later.' } }; } } async finalizeCompanySignUpRequest(input, options) { const { token, ...inputBody } = input; const response = await this.httpClient.post(`/v1/accounts/${token}/finalize`, inputBody, options); if (!response.ok) { return { data: null, error: response.body }; } return { data: response.body, error: null }; } }