Skip to content

Commit

Permalink
types: added reference data location types
Browse files Browse the repository at this point in the history
  • Loading branch information
darseen committed Aug 22, 2024
1 parent 002cd54 commit a05f8c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/amadeus/namespaces/reference-data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class ReferenceData {
* @param {string} [locationId] The ID of the location to search for
* @return {Location}
**/
public location(locationId: string) {
public location(locationId: string): Location {
return new Location(this.client, locationId);
}
}
20 changes: 13 additions & 7 deletions src/amadeus/namespaces/reference-data/location.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import {
ReferenceDataLocationsResult,
ReferenceDataLocationsReturnedResponse,
} from "../../../types/amadeus/namespaces/reference-data/locations";
import Client from "../../client";

/**
* A namespaced client for the
* `/v2/reference-data/locations/:location_id` endpoints
* `/v1/reference-data/locations/:location_id` endpoints
*
* Access via the {@link Amadeus} object
*
* ```ts
* const amadeus = new Amadeus();
* amadeus.referenceData.locations('ALHR');
* amadeus.referenceData.location('ALHR');
* ```
*
* @param {Client} client
Expand All @@ -35,10 +39,12 @@ export default class Location {
* amadeus.referenceData.location('ALHR').get();
* ```
*/
public get(params: Object = {}) {
return this.client.get(
`/v1/reference-data/locations/${this.locationId}`,
params
);
public get(
params: Object = {}
): Promise<ReferenceDataLocationsReturnedResponse> {
return this.client.get<
ReferenceDataLocationsResult,
ReferenceDataLocationsResult["data"]
>(`/v1/reference-data/locations/${this.locationId}`, params);
}
}

0 comments on commit a05f8c3

Please sign in to comment.