Skip to content

Commit

Permalink
types: added itinerary price metrics types
Browse files Browse the repository at this point in the history
  • Loading branch information
darseen committed Aug 17, 2024
1 parent 9842c29 commit 9d563d6
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/amadeus/namespaces/analytics/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Client from "../../client";
import ItineraryPriceMetrics from "./itenrary-price-metrics";
import ItineraryPriceMetrics from "./itinerary-price-metrics";

/**
* A namespaced client for the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import {
ItineraryPriceMetricsParams,
ItineraryPriceMetricsResult,
ItineraryPriceMetricsReturnedResponse,
} from "../../../types/amadeus/namespaces/analytics/itinerary-price-metrics";
import Client from "../../client";

/**
Expand Down Expand Up @@ -37,7 +42,12 @@ export default class ItineraryPriceMetrics {
* });
* ```
*/
public get(params = {}) {
return this.client.get("/v1/analytics/itinerary-price-metrics", params);
public get(
params: ItineraryPriceMetricsParams
): Promise<ItineraryPriceMetricsReturnedResponse> {
return this.client.get<
ItineraryPriceMetricsResult,
ItineraryPriceMetricsResult["data"]
>("/v1/analytics/itinerary-price-metrics", params);
}
}
40 changes: 40 additions & 0 deletions src/types/amadeus/namespaces/analytics/itinerary-price-metrics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { ReturnedResponseSuccess } from "../../client/response";
import { CollectionMetaLink, CurrencyCode, Issue } from "../shared";

export interface ItineraryPriceMetric {
type?: string;
origin?: {
iataCode?: string;
};
destination?: {
iataCode?: string;
};
departureDate?: string;
transportType?: "FLIGHT";
currencyCode?: CurrencyCode;
oneWay?: boolean;
priceMetrics?: {
amount?: string;
quartileRanking?: "MINIMUM" | "FIRST" | "MEDIUM" | "THIRD" | "MAXIMUM";
}[];
}

// Types used in class
export type ItineraryPriceMetricsParams = {
originIataCode: string;
destinationIataCode: string;
departureDate: string;
currencyCode?: CurrencyCode;
oneWay?: boolean;
};

export type ItineraryPriceMetricsResult = {
warnings?: Issue[];
data: ItineraryPriceMetric[];
meta?: CollectionMetaLink;
};

export type ItineraryPriceMetricsReturnedResponse = ReturnedResponseSuccess<
ItineraryPriceMetricsResult,
ItineraryPriceMetricsResult["data"]
>;
37 changes: 36 additions & 1 deletion src/types/amadeus/namespaces/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,41 @@ export interface OperatingFlight {
carrierCode?: string;
}

export type CurrencyCode =
| "CAD"
| "HKD"
| "ISK"
| "PHP"
| "DKK"
| "HUF"
| "CZK"
| "AUD"
| "RON"
| "SEK"
| "IDR"
| "INR"
| "BRL"
| "RUB"
| "HRK"
| "JPY"
| "THB"
| "EUR"
| "CHF"
| "SGD"
| "PLN"
| "BGN"
| "TRY"
| "CNY"
| "NOK"
| "NZD"
| "ZAR"
| "USD"
| "MXN"
| "ILS"
| "GBP"
| "KRW"
| "MYR";

export interface Price {
currency?: string;
total?: string;
Expand Down Expand Up @@ -346,7 +381,7 @@ export interface BaseName {

export interface ElementaryPrice {
amount?: string;
currencyCode?: string;
currencyCode?: CurrencyCode;
}

export type Traveler = Stakeholder & {
Expand Down
5 changes: 3 additions & 2 deletions src/types/amadeus/namespaces/shopping/flight-offers-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ReturnedResponseSuccess } from "../../client/response";
import {
CollectionMeta,
CollectionMetaLink,
CurrencyCode,
Dictionaries,
FlightOffer,
FlightOfferSource,
Expand Down Expand Up @@ -113,7 +114,7 @@ export type Coverage =

// Types used in class
export type FlightOffersSearchPostParams = {
currencyCode?: string;
currencyCode?: CurrencyCode;
originDestinations: OriginDestination[];
travelers: ExtendedTravelerInfo[];
sources: FlightOfferSource[];
Expand All @@ -139,7 +140,7 @@ export type FlightOffersSearchGetParams = {
includedAirlineCodes?: string;
excludedAirlineCodes?: string;
nonStop?: boolean;
currencyCode?: string;
currencyCode?: CurrencyCode;
maxPrice?: number;
max?: number;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface CollectionMetaUpsell {
}[];
}

// Types used in class
export type FlightOffersUpsellingParams = {
data: FlightOfferUpsellIn;
};
Expand Down
2 changes: 1 addition & 1 deletion tests/amadeus/namespaces.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ describe("Namespaces", () => {

it(".amadeus.analytics.itineraryPriceMetrics.get", () => {
amadeus["client"].get = vi.fn();
amadeus.analytics.itineraryPriceMetrics.get();
amadeus.analytics.itineraryPriceMetrics.get({} as any);
expect(amadeus["client"].get).toHaveBeenCalledWith(
"/v1/analytics/itinerary-price-metrics",
{}
Expand Down

0 comments on commit 9d563d6

Please sign in to comment.