Skip to content

Commit

Permalink
Adds group and individual filters to service resource
Browse files Browse the repository at this point in the history
  • Loading branch information
coconutcraig committed Jun 12, 2019
1 parent bc412f2 commit 2151c0b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/resources/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ it('will set the invite only filter', async () => {
});
});

it('will set the group filter', async () => {
const resource = new Service(mockAxios);

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

it('will set the individual filter', async () => {
const resource = new Service(mockAxios);

expect(resource.individual()).toHaveProperty('filters', {
group: 0,
});
});

it('will set the page we are on', async () => {
const resource = new Service(mockAxios);

Expand Down
17 changes: 17 additions & 0 deletions src/resources/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Conditional, { ConditionalResource } from './conditional';
export interface ServiceFilter {
assigned?: boolean;
category?: number | string;
group?: number;
invitable?: number;
location?: number | string;
user?: number | string;
Expand All @@ -27,8 +28,12 @@ export interface ServiceResource extends Pageable, ConditionalResource {

by(user: number | string): this;

group(): this;

in(category: number | string): this;

individual(): this;

invitable(): this;
}

Expand Down Expand Up @@ -90,12 +95,24 @@ export default class Service extends Conditional implements ServiceResource {
return await this.client.get('services', { params });
}

public group(): this {
this.filters.group = 1;

return this;
}

public in(category: number | string): this {
this.filters.category = category;

return this;
}

public individual(): this {
this.filters.group = 0;

return this;
}

public invitable(): this {
this.filters.invitable = 1;

Expand Down

0 comments on commit 2151c0b

Please sign in to comment.