Skip to content

Commit

Permalink
Adds accessors for appointment and wait list resources
Browse files Browse the repository at this point in the history
  • Loading branch information
coconutcraig committed Jan 14, 2019
1 parent 2bb8d7e commit 60a0618
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import OpenApi from './index';
import Appointment from './resources/appointment';
import Location from './resources/location';
import Question from './resources/question';
import Service from './resources/service';
import Setting from './resources/setting';
import User from './resources/user';
import TimeSlot from './resources/time-slot';
import User from './resources/user';
import WaitList from './resources/wait-list';

it('will be constructed properly', async () => {
const instance = new OpenApi('admin');
Expand Down Expand Up @@ -54,3 +56,17 @@ it('can access the slots resource', async () => {
expect(instance).toHaveProperty('slots');
expect(instance.slots).toBeInstanceOf(TimeSlot.prototype.constructor);
});

it('can access the wait list resource', async () => {
const instance = new OpenApi('admin');

expect(instance).toHaveProperty('lists');
expect(instance.lists).toBeInstanceOf(WaitList.prototype.constructor);
});

it('can access the appointment resource', async () => {
const instance = new OpenApi('admin');

expect(instance).toHaveProperty('appointments');
expect(instance.appointments).toBeInstanceOf(Appointment.prototype.constructor);
});
14 changes: 14 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { AxiosInstance } from 'axios';

import Client from './client';
import Appointment, { AppointmentResource } from './resources/appointment';
import Location, { LocationResource } from './resources/location';
import Question, { QuestionResource } from './resources/question';
import Service, { ServiceResource } from './resources/service';
import Setting from './resources/setting';
import TimeSlot, { TimeSlotResource } from './resources/time-slot';
import User, { UserResource } from './resources/user';
import WaitList, { WaitListResource } from './resources/wait-list';

export interface Filterable<T> {
filter?: T;
Expand Down Expand Up @@ -38,8 +40,10 @@ export interface Sortable extends Resource {
}

export default class OpenApi {
protected appointment: AppointmentResource;
protected client: AxiosInstance;
protected domain: string;
protected list: WaitListResource;
protected location: LocationResource;
protected question: QuestionResource;
protected service: ServiceResource;
Expand All @@ -50,6 +54,8 @@ export default class OpenApi {
constructor(domain: string) {
this.client = Client(domain);
this.domain = domain;
this.appointment = new Appointment(this.client);
this.list = new WaitList(this.client);
this.location = new Location(this.client);
this.question = new Question(this.client);
this.service = new Service(this.client);
Expand All @@ -58,6 +64,14 @@ export default class OpenApi {
this.user = new User(this.client);
}

get appointments(): AppointmentResource {
return this.appointment;
}

get lists(): WaitListResource {
return this.list;
}

get locations(): LocationResource {
return this.location;
}
Expand Down

0 comments on commit 60a0618

Please sign in to comment.