Skip to content

Commit

Permalink
Ensures visibility filter will be sent along with request
Browse files Browse the repository at this point in the history
  • Loading branch information
craigpaul committed Nov 22, 2019
1 parent 16a7377 commit 70ad475
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/resources/time-slot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ it('can string all filterable options together', async () => {
.at(1)
.for([1, 2])
.by(1)
.supporting(['en']),
.supporting(['en'])
.visibility(Visibilities.ALL),
);

expected.toHaveProperty('filters', {
Expand All @@ -93,6 +94,7 @@ it('can string all filterable options together', async () => {
services: [1, 2],
start: '2018-01-01',
user: 1,
visibility: Visibilities.ALL,
});
});

Expand All @@ -108,6 +110,7 @@ it('can get time slots for no particular user', async () => {
.supporting(['fr', 'es'])
.for([1, 2])
.in(timezone)
.visibility(Visibilities.ALL)
.get();

expect(mockAxios.get).toHaveBeenCalledTimes(1);
Expand All @@ -119,6 +122,7 @@ it('can get time slots for no particular user', async () => {
start: '2018-01-01',
supported_locales: ['fr', 'es'],
timezone,
visibility: Visibilities.ALL,
},
});
});
Expand All @@ -136,6 +140,7 @@ it('can get time slots for a specified user', async () => {
.supporting(['en', 'es'])
.by(1)
.in(timezone)
.visibility(Visibilities.ALL)
.get();

expect(mockAxios.get).toHaveBeenCalledTimes(1);
Expand All @@ -148,6 +153,7 @@ it('can get time slots for a specified user', async () => {
start: '2018-01-01',
supported_locales: ['en', 'es'],
timezone,
visibility: Visibilities.ALL,
},
});
});
Expand Down
5 changes: 5 additions & 0 deletions src/resources/time-slot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface TimeSlotParameters {
start?: string;
supported_locales?: string[];
timezone?: string;
visibility?: number;
}

export interface TimeSlotResource extends Resource, ConditionalResource {
Expand Down Expand Up @@ -96,6 +97,10 @@ export default class TimeSlot extends Conditional implements TimeSlotResource {
params.staff_id = this.filters.user;
}

if (this.filters.visibility) {
params.visibility = this.filters.visibility;
}

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

Expand Down

0 comments on commit 70ad475

Please sign in to comment.