Skip to content

Commit

Permalink
Ensures group filters are sent with request when provided
Browse files Browse the repository at this point in the history
  • Loading branch information
coconutcraig committed Jun 12, 2019
1 parent 2151c0b commit 632ace3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/resources/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ it('can string all filterable options together', async () => {
.by(2)
.in(3)
.invitable()
.individual()
.sortBy('created')
.take(5)
.on(1),
Expand All @@ -126,6 +127,7 @@ it('can string all filterable options together', async () => {
expected.toHaveProperty('filters', {
assigned: true,
category: 3,
group: 0,
invitable: 1,
location: 1,
user: 2,
Expand Down Expand Up @@ -153,6 +155,7 @@ it('can get services with additional parameters', async () => {
.by(2)
.in(3)
.invitable()
.individual()
.sortBy('created')
.take(5)
.on(1)
Expand All @@ -163,6 +166,7 @@ it('can get services with additional parameters', async () => {
params: {
'filter[assignments]': true,
'filter[category]': 3,
'filter[group]': 0,
'filter[invite_only]': 1,
'filter[location]': 1,
'filter[user]': 2,
Expand Down
5 changes: 5 additions & 0 deletions src/resources/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface ServiceFilter {
export interface ServiceParameters {
assignments?: boolean;
category?: number | string;
group?: number;
invite_only?: number;
location?: number | string;
user?: number | string;
Expand Down Expand Up @@ -148,6 +149,10 @@ export default class Service extends Conditional implements ServiceResource {
params.category = this.filters.category;
}

if (typeof this.filters.group !== 'undefined') {
params.group = this.filters.group;
}

if (typeof this.filters.invitable !== 'undefined') {
params.invite_only = this.filters.invitable;
}
Expand Down

0 comments on commit 632ace3

Please sign in to comment.