From 8ad5ea7cabfc65c1a6b292576033012d6ae1b43c Mon Sep 17 00:00:00 2001 From: Craig Paul Date: Tue, 11 Jun 2019 16:36:05 -0600 Subject: [PATCH] Adds timezone filter to time slot resource --- src/resources/time-slot.test.ts | 11 +++++++++++ src/resources/time-slot.ts | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/src/resources/time-slot.test.ts b/src/resources/time-slot.test.ts index f915d35..ebb4fb9 100644 --- a/src/resources/time-slot.test.ts +++ b/src/resources/time-slot.test.ts @@ -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); diff --git a/src/resources/time-slot.ts b/src/resources/time-slot.ts index ba85b5f..6059afa 100644 --- a/src/resources/time-slot.ts +++ b/src/resources/time-slot.ts @@ -8,6 +8,7 @@ export interface TimeSlotFilter { location?: number; services?: number | number[]; start?: string; + timezone?: string; user?: number; } @@ -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 { @@ -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; + } }