Skip to content

Commit

Permalink
Adds location, service and user filter to wait list resource
Browse files Browse the repository at this point in the history
  • Loading branch information
coconutcraig committed Nov 19, 2018
1 parent 285e39d commit 93401ed
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/resources/wait-list.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import mockAxios from 'axios';

import WaitList from './wait-list';

it('will set location filter using a number', async () => {
const resource = new WaitList(mockAxios);

expect(resource.at(1)).toHaveProperty('filters', {
location: 1,
});
});

it('will set location filter using a numeric string', async () => {
const resource = new WaitList(mockAxios);

expect(resource.at('1')).toHaveProperty('filters', {
location: '1',
});
});

it('will set service filter using a number', async () => {
const resource = new WaitList(mockAxios);

expect(resource.seeking(1)).toHaveProperty('filters', {
service: 1,
});
});

it('will set service filter using a numeric string', async () => {
const resource = new WaitList(mockAxios);

expect(resource.seeking('1')).toHaveProperty('filters', {
service: '1',
});
});

it('will set user filter using a number', async () => {
const resource = new WaitList(mockAxios);

expect(resource.with(1)).toHaveProperty('filters', {
user: 1,
});
});

it('will set user filter using a numeric string', async () => {
const resource = new WaitList(mockAxios);

expect(resource.with('1')).toHaveProperty('filters', {
user: '1',
});
});
17 changes: 17 additions & 0 deletions src/resources/wait-list.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import { AxiosInstance } from 'axios';

import { WaitListFilter } from '../types/filters';
import { AttendeeModel, PreferenceModel } from '../types/models';
import { WaitListResource } from '../types/resources';

export default class WaitList implements WaitListResource {
protected client: AxiosInstance;
protected filters: WaitListFilter;

constructor(client: AxiosInstance) {
this.client = client;
this.filters = {}
}

public async add(): Promise<any> {
//
}

public at(location: number | string): this {
this.filters.location = location;

return this;
}

Expand Down Expand Up @@ -35,6 +48,8 @@ export default class WaitList implements WaitListResource {
}

public seeking(service: number | string): this {
this.filters.service = service;

return this;
}

Expand All @@ -43,6 +58,8 @@ export default class WaitList implements WaitListResource {
}

public with(user: number | string): this {
this.filters.user = user;

return this;
}
}
6 changes: 6 additions & 0 deletions src/types/filters.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ export interface UserFilter {
services?: number | number[] | string | string[];
location?: number | string;
}

export interface WaitListFilter {
location?: number | string;
service?: number | string;
user?: number | string;
}

0 comments on commit 93401ed

Please sign in to comment.