Skip to content

Commit

Permalink
types: added upselling types
Browse files Browse the repository at this point in the history
  • Loading branch information
darseen committed Aug 17, 2024
1 parent 07eac56 commit 9842c29
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 27 deletions.
14 changes: 12 additions & 2 deletions src/amadeus/namespaces/shopping/flight_offers/upselling.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import {
FlightOffersUpsellingParams,
FlightOffersUpsellingResult,
FlightOffersUpsellingReturnedResponse,
} from "../../../../types/amadeus/namespaces/shopping/flight-offers/upselling";
import Client from "../../../client";

/**
Expand Down Expand Up @@ -30,7 +35,12 @@ export default class Upselling {
* amadeus.shopping.flightOffers.upselling.post(body);
* ```
*/
public post(params: Object = {}) {
return this.client.post("/v1/shopping/flight-offers/upselling", params);
public post(
params: FlightOffersUpsellingParams
): Promise<FlightOffersUpsellingReturnedResponse> {
return this.client.post<
FlightOffersUpsellingResult,
FlightOffersUpsellingResult["data"]
>("/v1/shopping/flight-offers/upselling", JSON.stringify(params));
}
}
23 changes: 14 additions & 9 deletions src/types/amadeus/namespaces/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export interface FlightEndPoint {
iataCode?: string;
terminal?: string;
at?: string;

}

export interface OriginalFlightStop {
Expand Down Expand Up @@ -471,7 +470,6 @@ export interface FlightOrder {
formOfIdentifications?: FormOfIdentification[];
}


export interface FormOfIdentification {
identificationType?:
| "DRIVERS_LICENSE"
Expand Down Expand Up @@ -503,17 +501,12 @@ export type AutomatedProcess = AutomatedProcessCommon & {

export type AutomatedProcessCode = "IMMEDIATE" | "DELAYED" | "ERROR";



export interface FormOfPayment {
b2bWallet?: B2BWallet;
creditCard?: CreditCard;
other?: OtherMethod;
}




export interface B2BWallet {
cardId?: string;
cardUsageName?: string;
Expand Down Expand Up @@ -551,8 +544,6 @@ export type CreditCardBrand =
| "DINERS"
| "EASYPAY";



export interface OtherMethod {
method?: OtherPaymentMethod;
flightOfferIds?: string[];
Expand Down Expand Up @@ -592,3 +583,17 @@ export interface TermAndCondition {
text?: string;
}[];
}

export type PaymentBrand =
| "VISA"
| "AMERICAN_EXPRESS"
| "MASTERCARD"
| "VISA_ELECTRON"
| "VISA_DEBIT"
| "MASTERCARD_DEBIT"
| "MAESTRO"
| "DINERS"
| "MASTERCARD_IXARIS"
| "VISA_IXARIS"
| "MASTERCARD_AIRPLUS"
| "UATP_AIRPLUS";
15 changes: 1 addition & 14 deletions src/types/amadeus/namespaces/shopping/flight-offers/pricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ElementaryPrice,
FlightOffer,
Issue,
PaymentBrand,
ServiceName,
TermAndCondition,
Traveler,
Expand Down Expand Up @@ -53,20 +54,6 @@ export interface CreditCardFee {
flightOfferId?: string;
}

export type PaymentBrand =
| "VISA"
| "AMERICAN_EXPRESS"
| "MASTERCARD"
| "VISA_ELECTRON"
| "VISA_DEBIT"
| "MASTERCARD_DEBIT"
| "MAESTRO"
| "DINERS"
| "MASTERCARD_IXARIS"
| "VISA_IXARIS"
| "MASTERCARD_AIRPLUS"
| "UATP_AIRPLUS";

export interface DetailedFareRules {
fareBasis?: string;
name?: string;
Expand Down
38 changes: 38 additions & 0 deletions src/types/amadeus/namespaces/shopping/flight-offers/upselling.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ReturnedResponseSuccess } from "../../../client/response";
import { Dictionaries, FlightOffer, Issue, PaymentBrand } from "../../shared";

export interface Payment {
brand?: PaymentBrand;
binNumber?: number;
flightOfferIds?: string[];
}

export interface FlightOfferUpsellIn {
type: "flight-offers-upselling";
flightOffers: FlightOffer[];
payments?: Payment[];
}

export interface CollectionMetaUpsell {
count?: number;
oneWayUpselledCombinations?: {
flightOfferId?: string;
upselledFlightOfferIds?: string[];
}[];
}

export type FlightOffersUpsellingParams = {
data: FlightOfferUpsellIn;
};

export type FlightOffersUpsellingResult = {
meta?: CollectionMetaUpsell;
warnings?: Issue[];
data: FlightOffer[];
dictionaries?: Dictionaries;
};

export type FlightOffersUpsellingReturnedResponse = ReturnedResponseSuccess<
FlightOffersUpsellingResult,
FlightOffersUpsellingResult["data"]
>;
4 changes: 2 additions & 2 deletions tests/amadeus/namespaces.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,10 @@ describe("Namespaces", () => {

it(".amadeus.shopping.flight_offers.upselling.post", () => {
amadeus["client"].post = vi.fn();
amadeus.shopping.flightOffers.upselling.post();
amadeus.shopping.flightOffers.upselling.post({} as any);
expect(amadeus["client"].post).toHaveBeenCalledWith(
"/v1/shopping/flight-offers/upselling",
{}
JSON.stringify({})
);
});

Expand Down

0 comments on commit 9842c29

Please sign in to comment.