Skip to content

Commit

Permalink
Adds ability to fetch location details
Browse files Browse the repository at this point in the history
  • Loading branch information
coconutcraig committed Aug 21, 2019
1 parent 5533395 commit a9173c1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/resources/location.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,12 @@ it('can supply suggestions based on the provided query', async () => {
},
});
});

it('can fetch details for a given location identifier received from a suggestion', async () => {
const resource = new Location(mockAxios);

await resource.details('random_string_of_characters');

expect(mockAxios.get).toHaveBeenCalledTimes(1);
expect(mockAxios.get).toHaveBeenCalledWith('location-details/random_string_of_characters');
});
6 changes: 6 additions & 0 deletions src/resources/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export interface LocationResource extends Pageable, ConditionalResource {

containing(user: number | string): this;

details(identifier: string): Promise<any>;

invitable(): this;

located(details: LocatableLocationParameters): this;
Expand Down Expand Up @@ -80,6 +82,10 @@ export default class Location extends Conditional implements LocationResource {
return this;
}

public async details(identifier: string): Promise<any> {
return await this.client.get(`location-details/${identifier}`);
}

public async get(): Promise<any> {
const parameters = this.params();
let params: Filterable<LocationFilter> = {};
Expand Down

0 comments on commit a9173c1

Please sign in to comment.