Skip to content

Commit

Permalink
Adds slot accessor and test
Browse files Browse the repository at this point in the history
  • Loading branch information
coconutcraig committed Nov 16, 2018
1 parent 39152d7 commit a8f1e81
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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';

it('will be constructed properly', async () => {
const instance = new OpenApi('admin');
Expand Down Expand Up @@ -46,3 +47,10 @@ it('can access the location resource', async () => {
expect(instance).toHaveProperty('locations');
expect(instance.locations).toBeInstanceOf(Location.prototype.constructor);
});

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

expect(instance).toHaveProperty('slots');
expect(instance.slots).toBeInstanceOf(TimeSlot.prototype.constructor);
});
16 changes: 15 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ import Location from './resources/location';
import Question from './resources/question';
import Service from './resources/service';
import Setting from './resources/setting';
import TimeSlot from './resources/time-slot';
import User from './resources/user';
import { LocationResource, QuestionResource, Resource, ServiceResource, UserResource } from './types/resources';
import {
LocationResource,
QuestionResource,
Resource,
ServiceResource,
TimeSlotResource,
UserResource
} from './types/resources';

export default class OpenApi {
protected client: AxiosInstance;
Expand All @@ -15,6 +23,7 @@ export default class OpenApi {
protected question: QuestionResource;
protected service: ServiceResource;
protected setting: Resource;
protected slot: TimeSlotResource;
protected user: UserResource;

constructor(domain: string) {
Expand All @@ -24,6 +33,7 @@ export default class OpenApi {
this.question = new Question(this.client);
this.service = new Service(this.client);
this.setting = new Setting(this.client);
this.slot = new TimeSlot(this.client);
this.user = new User(this.client);
}

Expand All @@ -43,6 +53,10 @@ export default class OpenApi {
return this.setting;
}

get slots(): TimeSlotResource {
return this.slot;
}

get users(): UserResource {
return this.user;
}
Expand Down

0 comments on commit a8f1e81

Please sign in to comment.