@findhotel/sapi 1.5.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@ export interface AppConfig {
9
9
  offers: string;
10
10
  roomsOffers: string;
11
11
  addressSuggests: string;
12
+ availability: string;
12
13
  };
13
14
  };
14
15
  saf: {
@@ -0,0 +1,45 @@
1
+ import { HotelId, Options, RateBreakdown, AvailabilitySearchParameters, AvailabilityResults, SapiResponseOffer, OffersRooms, AvailabilityDate } from './types';
2
+ import { AppConfig } from './app-config';
3
+ export declare type AvailabilityHandler = (parameters: AvailabilitySearchParameters, callbacks: {
4
+ onStart?: (result: AvailabilitySearchParameters) => void;
5
+ onAvailabilityReceived?: (result: AvailabilityResults) => void;
6
+ onComplete?: (result: AvailabilityResults) => void;
7
+ }) => Promise<AvailabilityResults | undefined>;
8
+ /**
9
+ * Sapi backend availability response
10
+ */
11
+ export interface AvailabilityResponse {
12
+ availability: Record<HotelId, Record<AvailabilityDate, {
13
+ hotelID: HotelId;
14
+ cheapestRate: RateBreakdown;
15
+ offers: SapiResponseOffer[];
16
+ rooms: OffersRooms;
17
+ }>>;
18
+ status: {
19
+ complete: boolean;
20
+ nextToken: string;
21
+ };
22
+ }
23
+ /**
24
+ * Converts Sapi backend response to SDK result
25
+ *
26
+ * @param response - backend response
27
+ * @returns AvailabilityResults - SDK results
28
+ */
29
+ export declare function responseToResults(response: AvailabilityResponse): AvailabilityResults;
30
+ /**
31
+ * Creates availability request string
32
+ */
33
+ export declare function createRequestString(parameters: AvailabilitySearchParameters, options: Options, nextToken?: string): string;
34
+ export interface Parameters {
35
+ appConfig: AppConfig;
36
+ options: Options;
37
+ }
38
+ /**
39
+ * Creates hotel's availability function with configuration object
40
+ *
41
+ * @param configuration - Configuration for offers initialization
42
+ *
43
+ * @returns function for fetching hotel's availability
44
+ */
45
+ export declare function hotelAvailability({ appConfig, options, }: Parameters): AvailabilityHandler;
@@ -1,61 +1,4 @@
1
- import { CugDeals, HotelId, HotelOfferEntity, Currency, RoomId, Amenities, Options as ClientOptions, UserTier, Discount, RateBreakdown } from './types';
2
- interface V3RateBreakdown {
3
- base: number;
4
- hotelFees: number;
5
- taxes: number;
6
- }
7
- interface CancellationPenalty {
8
- amount: number;
9
- currency: string;
10
- end: string;
11
- start: string;
12
- }
13
- declare type OfferTag = 'top_offer' | 'anchor_price' | 'exclusive_cheapest_offer';
14
- interface SapiResponseOffer {
15
- accessTier: string;
16
- availableRooms: number;
17
- cancellationPenalties: CancellationPenalty[];
18
- currency: Currency;
19
- id: string;
20
- intermediaryProvider: string;
21
- metadata: {
22
- feedID: string;
23
- providerRateType?: string;
24
- };
25
- occupancy: string | number | null;
26
- package: {
27
- amenities: Amenities[];
28
- canPayLater: boolean;
29
- };
30
- providerCode: string;
31
- rate: V3RateBreakdown;
32
- roomID: RoomId;
33
- tags: OfferTag[] | null;
34
- url: string;
35
- }
36
- declare type Rooms = Record<RoomId, {
37
- name: string;
38
- }>;
39
- interface SapiSplitBookingOffer {
40
- offer: SapiResponseOffer;
41
- checkIn: string;
42
- checkOut: string;
43
- }
44
- interface SapiSplitBookingEntity {
45
- offers: SapiSplitBookingOffer[];
46
- tags?: string[];
47
- totalRate: RateBreakdown;
48
- }
49
- export interface SapiResponseOfferEntity {
50
- anchorRate: V3RateBreakdown;
51
- availableOffersCount: number;
52
- id: HotelId;
53
- offers: SapiResponseOffer[];
54
- rooms: Rooms;
55
- discount?: Discount;
56
- roomsConfig?: string;
57
- splitBooking?: SapiSplitBookingEntity;
58
- }
1
+ import { CugDeals, HotelId, HotelOfferEntity, Offer, Options as ClientOptions, UserTier, SapiResponseOffer, SapiResponseOfferEntity, OffersRooms } from './types';
59
2
  export interface GetOffersParameters {
60
3
  anchorHotelId?: HotelId;
61
4
  hotelIds?: HotelId[];
@@ -91,6 +34,7 @@ export interface OffersClient {
91
34
  getOffers: (parameters: GetOffersParameters, onOffersReceived?: (response: OffersResponse) => void) => Promise<OffersResponse>;
92
35
  }
93
36
  export declare function createRequest(parameters: GetOffersParameters, options: ClientOptions, clientRequestId: string): string | undefined;
37
+ export declare function sapiResponseOfferToOffer(offer: SapiResponseOffer, rooms: OffersRooms): Offer;
94
38
  export declare function sapiResponseToHotelOfferEntity(offerEntity: SapiResponseOfferEntity): HotelOfferEntity;
95
39
  interface Config {
96
40
  baseUrl: string;
@@ -4,6 +4,7 @@ import { SuggestHandler } from './suggest';
4
4
  import { RoomsHandler } from './rooms';
5
5
  import { HotelHandler, HotelsHandler } from './hotel';
6
6
  import { OffersHandler } from './offers';
7
+ import { AvailabilityHandler } from './hotel-availability';
7
8
  import { ClientOptions } from './types';
8
9
  /**
9
10
  * Converts map of A/B tests variations to array of string
@@ -22,6 +23,7 @@ export interface SapiClient {
22
23
  hotel: HotelHandler;
23
24
  hotels: HotelsHandler;
24
25
  offers: OffersHandler;
26
+ hotelAvailability: AvailabilityHandler;
25
27
  }
26
28
  /**
27
29
  * SAPI constructor
@@ -0,0 +1,31 @@
1
+ import { HotelId, CugDeals, UserTier } from './types';
2
+ import { Offer, RateBreakdown } from './offers';
3
+ /**
4
+ * Availability search parameters
5
+ */
6
+ export interface AvailabilitySearchParameters {
7
+ hotelIds: HotelId | HotelId[];
8
+ startDate: string;
9
+ endDate: string;
10
+ nights: number;
11
+ rooms: string;
12
+ cugDeals?: CugDeals;
13
+ tier?: UserTier;
14
+ originId?: string;
15
+ }
16
+ /**
17
+ * Availability entity
18
+ */
19
+ export interface AvailabilityEntity {
20
+ hotelID: HotelId;
21
+ cheapestRate: RateBreakdown;
22
+ offers: Offer[];
23
+ }
24
+ /**
25
+ * The date of the availability calendar
26
+ */
27
+ export declare type AvailabilityDate = string;
28
+ /**
29
+ * Availability results
30
+ */
31
+ export declare type AvailabilityResults = Record<HotelId, Record<AvailabilityDate, AvailabilityEntity>>;
@@ -6,3 +6,4 @@ export * from './config';
6
6
  export * from './logger';
7
7
  export * from './errors';
8
8
  export * from './search';
9
+ export * from './availability';
@@ -1,4 +1,14 @@
1
- import { CancellationPenalties, Currency } from './types';
1
+ import { CancellationPenalties, Currency, RoomId, HotelId } from './types';
2
+ /**
3
+ * Offers rooms parameter
4
+ */
5
+ export declare type OffersRooms = Record<RoomId, {
6
+ name: string;
7
+ }>;
8
+ /**
9
+ * Possible offer's tags
10
+ */
11
+ export declare type OfferTag = 'top_offer' | 'anchor_price' | 'exclusive_cheapest_offer';
2
12
  /**
3
13
  * Object contains details about the price of the Offer, the rate is divided into 3 attributes:
4
14
  *
@@ -71,7 +81,7 @@ export interface HotelOfferEntity {
71
81
  /** Discount - meta information used in analytics */
72
82
  discount?: Discount;
73
83
  /** Id of the requested hotel */
74
- id: string;
84
+ id: HotelId;
75
85
  /** Hotel's offers */
76
86
  offers: Offer[];
77
87
  /** Room configuration of the offers */
@@ -79,3 +89,52 @@ export interface HotelOfferEntity {
79
89
  /** Split booking offers */
80
90
  splitBooking?: SplitBookingEntity;
81
91
  }
92
+ /**
93
+ * Sapi Backend offer type
94
+ */
95
+ export interface SapiResponseOffer {
96
+ accessTier: string;
97
+ availableRooms: number;
98
+ cancellationPenalties: CancellationPenalties[];
99
+ currency: Currency;
100
+ id: string;
101
+ intermediaryProvider: string;
102
+ metadata: {
103
+ feedID: string;
104
+ providerRateType?: string;
105
+ };
106
+ occupancy: string | number | null;
107
+ package: {
108
+ amenities: Amenities[];
109
+ canPayLater: boolean;
110
+ };
111
+ providerCode: string;
112
+ rate: RateBreakdown;
113
+ roomID: RoomId;
114
+ tags: OfferTag[] | null;
115
+ url: string;
116
+ }
117
+ export interface SapiSplitBookingOffer {
118
+ offer: SapiResponseOffer;
119
+ checkIn: string;
120
+ checkOut: string;
121
+ }
122
+ interface SapiSplitBookingEntity {
123
+ offers: SapiSplitBookingOffer[];
124
+ tags?: string[];
125
+ totalRate: RateBreakdown;
126
+ }
127
+ /**
128
+ * Sapi Backend offer entity type
129
+ */
130
+ export interface SapiResponseOfferEntity {
131
+ anchorRate: RateBreakdown;
132
+ availableOffersCount: number;
133
+ id: HotelId;
134
+ offers: SapiResponseOffer[];
135
+ rooms: OffersRooms;
136
+ discount?: Discount;
137
+ roomsConfig?: string;
138
+ splitBooking?: SapiSplitBookingEntity;
139
+ }
140
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@findhotel/sapi",
3
- "version": "1.5.0",
3
+ "version": "1.6.1",
4
4
  "description": "FindHotel Search API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/packages/core/src",