From 60a0618c896106744e83f4f27a06914894a303c7 Mon Sep 17 00:00:00 2001 From: Craig Paul Date: Mon, 14 Jan 2019 15:28:03 -0600 Subject: [PATCH] Adds accessors for appointment and wait list resources --- src/index.test.ts | 18 +++++++++++++++++- src/index.ts | 14 ++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/index.test.ts b/src/index.test.ts index 4460653..71de53d 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -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'); @@ -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); +}); diff --git a/src/index.ts b/src/index.ts index fc4a503..cd5b21c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 { filter?: T; @@ -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; @@ -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); @@ -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; }