Skip to content

Commit

Permalink
Adds timezone filter to time slot resource
Browse files Browse the repository at this point in the history
  • Loading branch information
coconutcraig committed Jun 11, 2019
1 parent cf97b44 commit 8ad5ea7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/resources/time-slot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ it('will set service filter using an array of numbers', async () => {
});
});

it('will set timezone filter', async () => {
const resource = new TimeSlot(mockAxios);

const timezones = ['America/Chicago', 'America/Toronto', 'Europe/Amsterdam', 'Europe/Paris'];
const timezone = timezones[Math.floor(Math.random() * timezones.length)];

expect(resource.in(timezone)).toHaveProperty('filters', {
timezone,
});
});

it('can string all filterable options together', async () => {
const resource = new TimeSlot(mockAxios);

Expand Down
9 changes: 9 additions & 0 deletions src/resources/time-slot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface TimeSlotFilter {
location?: number;
services?: number | number[];
start?: string;
timezone?: string;
user?: number;
}

Expand All @@ -27,6 +28,8 @@ export interface TimeSlotResource extends Resource, ConditionalResource {
by(user: number): this;

for(services: number | number[]): this;

in(timezone: string): this;
}

export default class TimeSlot extends Conditional implements TimeSlotResource {
Expand Down Expand Up @@ -79,4 +82,10 @@ export default class TimeSlot extends Conditional implements TimeSlotResource {

return await this.client.get('times', { params });
}

public in(timezone: string): this {
this.filters.timezone = timezone;

return this;
}
}

0 comments on commit 8ad5ea7

Please sign in to comment.