Skip to content

Commit

Permalink
Adds visibility flag to time slot resource
Browse files Browse the repository at this point in the history
  • Loading branch information
craigpaul committed Nov 22, 2019
1 parent 9d5e972 commit 16a7377
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/constants/visibilities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default class Visibilities {
static get PUBLIC() {
return 0;
}

static get ALL() {
return 1;
}
}
10 changes: 10 additions & 0 deletions src/resources/time-slot.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import mockAxios from 'axios';

import Visibilities from "../constants/visibilities";

import TimeSlot from './time-slot';

it('will set location filter using a number', async () => {
Expand Down Expand Up @@ -64,6 +66,14 @@ it('will set supported locales filter', async () => {
});
});

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

expect(resource.visibility(Visibilities.ALL)).toHaveProperty('filters', {
visibility: Visibilities.ALL,
});
});

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 @@ -11,6 +11,7 @@ export interface TimeSlotFilter {
timezone?: string;
locales?: string[];
user?: number;
visibility?: number;
}

export interface TimeSlotParameters {
Expand All @@ -35,6 +36,8 @@ export interface TimeSlotResource extends Resource, ConditionalResource {
in(timezone: string): this;

supporting(locales: string[]): this;

visibility(visibility: number): this;
}

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

return this;
}

public visibility(visibility: number): this {
this.filters.visibility = visibility;

return this;
}
}

0 comments on commit 16a7377

Please sign in to comment.