Skip to content

Commit

Permalink
Changes assignments filter to return a number to be more boolean safe…
Browse files Browse the repository at this point in the history
… over an http endpoint
  • Loading branch information
craigpaul committed Nov 28, 2019
1 parent d75b667 commit 459f602
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/resources/location.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ it('can get locations with additional parameters', async () => {
expect(mockAxios.get).toHaveBeenCalledTimes(1);
expect(mockAxios.get).toHaveBeenCalledWith('locations', {
params: {
'filter[assignments]': true,
'filter[assignments]': 1,
'filter[city]': 'Fake City',
'filter[country]': 'FC',
'filter[invite_only]': 1,
Expand Down
4 changes: 2 additions & 2 deletions src/resources/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface LocationFilter {
}

export interface LocationParameters {
assignments?: boolean;
assignments?: number;
city?: string;
country?: string;
invite_only?: number;
Expand Down Expand Up @@ -192,7 +192,7 @@ export default class Location extends Conditional implements LocationResource {
const params: LocationParameters = {};

if (typeof this.filters.assigned !== 'undefined') {
params.assignments = this.filters.assigned;
params.assignments = Number(this.filters.assigned);
}

if (typeof this.filters.city !== 'undefined') {
Expand Down
2 changes: 1 addition & 1 deletion src/resources/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ it('can get services with additional parameters', async () => {
expect(mockAxios.get).toHaveBeenCalledTimes(1);
expect(mockAxios.get).toHaveBeenCalledWith('services', {
params: {
'filter[assignments]': true,
'filter[assignments]': 1,
'filter[category]': 3,
'filter[group]': 0,
'filter[invite_only]': 1,
Expand Down
4 changes: 2 additions & 2 deletions src/resources/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface ServiceFilter {
}

export interface ServiceParameters {
assignments?: boolean;
assignments?: number;
category?: number | string;
group?: number;
invite_only?: number;
Expand Down Expand Up @@ -142,7 +142,7 @@ export default class Service extends Conditional implements ServiceResource {
const params: ServiceParameters = {};

if (typeof this.filters.assigned !== 'undefined') {
params.assignments = this.filters.assigned;
params.assignments = Number(this.filters.assigned);
}

if (typeof this.filters.category !== 'undefined') {
Expand Down

0 comments on commit 459f602

Please sign in to comment.