From 2151c0b9ccba5c4624fca2b0dbe4379586c4f977 Mon Sep 17 00:00:00 2001 From: Craig Paul Date: Wed, 12 Jun 2019 09:37:22 -0600 Subject: [PATCH] Adds group and individual filters to service resource --- src/resources/service.test.ts | 16 ++++++++++++++++ src/resources/service.ts | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/resources/service.test.ts b/src/resources/service.test.ts index 5776a11..491f9c1 100644 --- a/src/resources/service.test.ts +++ b/src/resources/service.test.ts @@ -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); diff --git a/src/resources/service.ts b/src/resources/service.ts index 7a94804..1701bcf 100644 --- a/src/resources/service.ts +++ b/src/resources/service.ts @@ -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; @@ -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; } @@ -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;