@starsched/sdk
Version:
ABA clinic control and management service API SDK
48 lines (47 loc) • 1.51 kB
JavaScript
export class CompanyPatients {
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}/patients`, { 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}/patients`, inputBody, { ...options });
if (!response.ok) {
return {
data: null,
error: response.body
};
}
return {
data: response.body,
error: null
};
}
}