@odynn/awayz-hotels 0.12.6 → 0.13.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.
@@ -47,9 +47,10 @@ export interface IHotelDetails {
47
47
  standardPointsAvailable: boolean;
48
48
  liveScrapingCheckNeeded: boolean;
49
49
  partners: IHotelPartner[];
50
- hotelProgram: IHotelProgram;
50
+ hotelProgram?: IHotelProgram;
51
+ pointsProgramDisplay?: string;
51
52
  bestValue: string;
52
- pointsAsCash: IHotelPointsAsCash;
53
+ pointsAsCash?: IHotelPointsAsCash;
53
54
  imagesS3?: string[];
54
55
  colour?: string;
55
56
  distance: number;
@@ -1,7 +1,7 @@
1
1
  import { ITransferPartner } from '@type-op/shared';
2
- import { IHotelDetails, ILiveHotelCheck } from '../../components/HotelResult/HotelResult.types';
2
+ import { ICashBookingOffers, IHotelDetails, ILiveHotelCheck } from '../../components/HotelResult/HotelResult.types';
3
3
  import { IAmenity, IRate, IRoom } from '../booking/BookingService.types';
4
- import { IHotelResultResponse, ILiveHotelCheckResponse, IRateResponse, IRoomResponse, ITransferPartnerResponse } from './HotelService.types';
4
+ import { ICashBookingOffersResponse, IHotelResultResponse, ILiveHotelCheckResponse, IRateResponse, IRoomResponse, ITransferPartnerResponse } from './HotelService.types';
5
5
  /**
6
6
  * Map API rate response to IRate.
7
7
  */
@@ -10,6 +10,10 @@ export declare const mapRateResponse: (rate: IRateResponse) => IRate;
10
10
  * Map API room response to IRoom.
11
11
  */
12
12
  export declare const mapRoomResponse: (room: IRoomResponse) => IRoom;
13
+ /**
14
+ * Map API cash booking offers response to ICashBookingOffers.
15
+ */
16
+ export declare const mapCashBookingOffersResponse: (cbo?: ICashBookingOffersResponse) => ICashBookingOffers | undefined;
13
17
  /**
14
18
  * Map API hotel response to IHotelDetails.
15
19
  */
@@ -77,11 +77,13 @@ export interface IHotelResultResponse {
77
77
  standard_points_available: boolean;
78
78
  live_scraping_check_needed: boolean;
79
79
  partners: IHotelPartnerResponse[];
80
- hotel_program: IHotelProgramResponse & {
80
+ hotel_program?: IHotelProgramResponse & {
81
81
  logo: string;
82
82
  };
83
+ points_program_display?: string;
83
84
  best_value: string;
84
- points_as_cash: IPointsAsCashResponse;
85
+ points_as_cash?: IPointsAsCashResponse;
86
+ cash_booking_offers?: ICashBookingOffersResponse;
85
87
  }
86
88
  interface IHotelPartnerResponse {
87
89
  program: string;
@@ -114,6 +116,60 @@ interface IPointsAsCashResponse {
114
116
  total_points_used: number;
115
117
  award_program: string | number;
116
118
  }
119
+ export interface ICashBookingOffersResponse {
120
+ search_room_rate_id: string;
121
+ accommodation_id: string;
122
+ matched_type: string;
123
+ rooms: IRoomResponse[];
124
+ ratings: {
125
+ source: string;
126
+ value: number;
127
+ }[];
128
+ rating: number;
129
+ review_score: number;
130
+ review_count?: number | string | undefined;
131
+ photos: {
132
+ url: string;
133
+ }[];
134
+ phone_number: string;
135
+ name: string;
136
+ location: {
137
+ geographic_coordinates: {
138
+ latitude: number;
139
+ longitude: number;
140
+ };
141
+ address: {
142
+ region: any;
143
+ postal_code: string;
144
+ line_one: string;
145
+ country_code: string;
146
+ city_name: string;
147
+ };
148
+ };
149
+ id: string;
150
+ email: string | null;
151
+ description: string;
152
+ check_in_information: {
153
+ check_in_after_time: string;
154
+ check_out_before_time: string;
155
+ check_in_before_time: string;
156
+ };
157
+ matched_score: number;
158
+ key_collection: any;
159
+ cheapest_rate_total_amount: number;
160
+ cheapest_rate_currency: string;
161
+ chain: {
162
+ name: string;
163
+ };
164
+ brand: {
165
+ name: string;
166
+ };
167
+ supported_loyalty_programme: any;
168
+ amenities: {
169
+ description: string;
170
+ type: string;
171
+ }[];
172
+ }
117
173
  export interface IPlaceResponse {
118
174
  mapbox_id: string;
119
175
  type: string;
@@ -6,7 +6,7 @@ const n = (e) => {
6
6
  return isNaN(a) ? 0 : a;
7
7
  }
8
8
  return 0;
9
- }, p = (e) => {
9
+ }, d = (e) => {
10
10
  if (e != null) {
11
11
  if (typeof e == "number") return e;
12
12
  if (typeof e == "string") {
@@ -14,16 +14,16 @@ const n = (e) => {
14
14
  return isNaN(a) ? void 0 : a;
15
15
  }
16
16
  }
17
- }, y = (e) => {
17
+ }, w = (e) => {
18
18
  var a;
19
19
  return {
20
20
  publicCurrency: e.public_currency,
21
21
  dueAtAccommodationCurrency: e.due_at_accommodation_currency,
22
- dueAtAccommodationAmount: p(
22
+ dueAtAccommodationAmount: d(
23
23
  e.due_at_accommodation_amount
24
24
  ),
25
25
  quantityAvailable: n(e.quantity_available),
26
- publicAmount: p(e.public_amount),
26
+ publicAmount: d(e.public_amount),
27
27
  dealTypes: e.deal_types ?? void 0,
28
28
  cancellationTimeline: ((a = e.cancellation_timeline) == null ? void 0 : a.map((t) => ({
29
29
  before: t.before,
@@ -46,11 +46,11 @@ const n = (e) => {
46
46
  source: e.source,
47
47
  id: e.id
48
48
  };
49
- }, d = (e) => {
50
- var a, t, o, i;
49
+ }, p = (e) => {
50
+ var a, t, i, s;
51
51
  return {
52
52
  roomId: e.room_id,
53
- rates: ((a = e.rates) == null ? void 0 : a.map(y)) ?? [],
53
+ rates: ((a = e.rates) == null ? void 0 : a.map(w)) ?? [],
54
54
  roomTitle: e.room_title,
55
55
  roomType: e.room_type,
56
56
  roomCategory: e.room_category,
@@ -60,19 +60,19 @@ const n = (e) => {
60
60
  lowestAwardPointsRate: n(e.lowest_award_points_rate),
61
61
  lowestCashRate: {
62
62
  currency: ((t = e.lowest_cash_rate) == null ? void 0 : t.currency) ?? "",
63
- cashAmount: n((o = e.lowest_cash_rate) == null ? void 0 : o.cash_amount)
63
+ cashAmount: n((i = e.lowest_cash_rate) == null ? void 0 : i.cash_amount)
64
64
  },
65
- roomRatePlans: ((i = e.room_rate_plans) == null ? void 0 : i.map((s) => {
65
+ roomRatePlans: ((s = e.room_rate_plans) == null ? void 0 : s.map((o) => {
66
66
  var _, m;
67
67
  return {
68
- ratePlanId: s.rate_plan_id,
69
- ratePlanName: s.rate_plan_name,
70
- ratePlanType: s.rate_plan_type,
71
- ratePlanCategory: s.rate_plan_category,
72
- ratePlanPoints: n(s.rate_plan_points),
68
+ ratePlanId: o.rate_plan_id,
69
+ ratePlanName: o.rate_plan_name,
70
+ ratePlanType: o.rate_plan_type,
71
+ ratePlanCategory: o.rate_plan_category,
72
+ ratePlanPoints: n(o.rate_plan_points),
73
73
  ratePlanCash: {
74
- cashAmount: n((_ = s.rate_plan_cash) == null ? void 0 : _.cash_amount),
75
- currency: ((m = s.rate_plan_cash) == null ? void 0 : m.currency) ?? ""
74
+ cashAmount: n((_ = o.rate_plan_cash) == null ? void 0 : _.cash_amount),
75
+ currency: ((m = o.rate_plan_cash) == null ? void 0 : m.currency) ?? ""
76
76
  }
77
77
  };
78
78
  })) ?? [],
@@ -80,34 +80,85 @@ const n = (e) => {
80
80
  name: e.name,
81
81
  beds: e.beds
82
82
  };
83
- }, l = (e) => ({
83
+ }, T = (e) => {
84
+ var a, t, i, s, o, _, m, c, u, r, l, y, g, f, h, C, v, b, k, P;
85
+ if (e)
86
+ return {
87
+ searchRoomRateId: e.search_room_rate_id,
88
+ accommodationId: e.accommodation_id,
89
+ matchedType: e.matched_type,
90
+ rooms: ((a = e.rooms) == null ? void 0 : a.map(p)) ?? [],
91
+ ratings: e.ratings ?? [],
92
+ rating: n(e.rating),
93
+ reviewScore: n(e.review_score),
94
+ reviewCount: d(e.review_count),
95
+ photos: e.photos ?? [],
96
+ phoneNumber: e.phone_number ?? "",
97
+ name: e.name ?? "",
98
+ location: {
99
+ geographicCoordinates: {
100
+ latitude: n((i = (t = e.location) == null ? void 0 : t.geographic_coordinates) == null ? void 0 : i.latitude),
101
+ longitude: n((o = (s = e.location) == null ? void 0 : s.geographic_coordinates) == null ? void 0 : o.longitude)
102
+ },
103
+ address: {
104
+ region: ((m = (_ = e.location) == null ? void 0 : _.address) == null ? void 0 : m.region) ?? null,
105
+ postalCode: ((u = (c = e.location) == null ? void 0 : c.address) == null ? void 0 : u.postal_code) ?? "",
106
+ lineOne: ((l = (r = e.location) == null ? void 0 : r.address) == null ? void 0 : l.line_one) ?? "",
107
+ countryCode: ((g = (y = e.location) == null ? void 0 : y.address) == null ? void 0 : g.country_code) ?? "",
108
+ cityName: ((h = (f = e.location) == null ? void 0 : f.address) == null ? void 0 : h.city_name) ?? ""
109
+ }
110
+ },
111
+ id: e.id,
112
+ email: e.email,
113
+ description: e.description ?? "",
114
+ checkInInformation: {
115
+ checkInAfterTime: ((C = e.check_in_information) == null ? void 0 : C.check_in_after_time) ?? "",
116
+ checkOutBeforeTime: ((v = e.check_in_information) == null ? void 0 : v.check_out_before_time) ?? "",
117
+ checkInBeforeTime: ((b = e.check_in_information) == null ? void 0 : b.check_in_before_time) ?? ""
118
+ },
119
+ matchedScore: n(e.matched_score),
120
+ keyCollection: e.key_collection,
121
+ cheapestRateTotalAmount: n(e.cheapest_rate_total_amount),
122
+ cheapestRateCurrency: e.cheapest_rate_currency ?? "",
123
+ chain: { name: ((k = e.chain) == null ? void 0 : k.name) ?? "" },
124
+ brand: { name: ((P = e.brand) == null ? void 0 : P.name) ?? "" },
125
+ supportedLoyaltyProgramme: e.supported_loyalty_programme,
126
+ amenities: e.amenities ?? []
127
+ };
128
+ }, A = (e) => ({
84
129
  bonus: (e == null ? void 0 : e.bonus) ?? 0,
85
130
  stepThreshold: (e == null ? void 0 : e.step_threshold) ?? 0
86
- }), b = (e) => ({
87
- program: e.program,
88
- ratio: e.ratio,
89
- bonus: e.bonus,
90
- transferMinutes: e.transfer_minutes,
91
- minimumTransfer: e.minimum_transfer,
92
- transferDenominator: e.transfer_denominator,
93
- stepBonus: l(e.step_bonus)
94
- }), g = (e) => ({
131
+ }), R = (e) => ({
95
132
  program: e.program,
96
133
  ratio: e.ratio,
97
134
  bonus: e.bonus,
98
135
  transferMinutes: e.transfer_minutes,
99
136
  minimumTransfer: e.minimum_transfer,
100
137
  transferDenominator: e.transfer_denominator,
101
- stepBonus: l(e.step_bonus),
102
- valueCent: e.value_cent,
103
- logo: e.logo
104
- }), f = (e) => ({
105
- pointsAsCashRequired: e.points_as_cash_required,
106
- pointsAsCashAvailable: e.points_as_cash_available,
107
- totalPointsUsed: e.total_points_used,
108
- awardProgram: e.award_program
109
- }), C = (e, a) => {
110
- var o, i, s, _, m, c, u;
138
+ stepBonus: A(e.step_bonus)
139
+ }), N = (e) => {
140
+ if (e)
141
+ return {
142
+ program: e.program,
143
+ ratio: e.ratio,
144
+ bonus: e.bonus,
145
+ transferMinutes: e.transfer_minutes,
146
+ minimumTransfer: e.minimum_transfer,
147
+ transferDenominator: e.transfer_denominator,
148
+ stepBonus: A(e.step_bonus),
149
+ valueCent: e.value_cent,
150
+ logo: e.logo
151
+ };
152
+ }, I = (e) => {
153
+ if (e)
154
+ return {
155
+ pointsAsCashRequired: e.points_as_cash_required,
156
+ pointsAsCashAvailable: e.points_as_cash_available,
157
+ totalPointsUsed: e.total_points_used,
158
+ awardProgram: e.award_program
159
+ };
160
+ }, L = (e, a) => {
161
+ var i, s, o, _, m, c, u;
111
162
  const t = a ?? ((r) => ({
112
163
  description: r,
113
164
  type: r.toLowerCase().replace(/\s/g, "_")
@@ -115,15 +166,15 @@ const n = (e) => {
115
166
  return {
116
167
  hotelId: e.hotel_id,
117
168
  address: e.address,
118
- amenities: ((o = e.amenities) == null ? void 0 : o.map(
169
+ amenities: ((i = e.amenities) == null ? void 0 : i.map(
119
170
  (r) => typeof r == "string" ? t(r) : r
120
171
  )) ?? [],
121
172
  bookingLink: e.booking_link,
122
173
  bookingLinkCash: e.booking_link_cash,
123
174
  bookingLinkPoints: e.booking_link_points,
124
175
  cashValue: {
125
- currency: ((i = e.cash_value) == null ? void 0 : i.currency) ?? "",
126
- amount: n((s = e.cash_value) == null ? void 0 : s.amount)
176
+ currency: ((s = e.cash_value) == null ? void 0 : s.currency) ?? "",
177
+ amount: n((o = e.cash_value) == null ? void 0 : o.amount)
127
178
  },
128
179
  chainRating: 0,
129
180
  // Not in API response
@@ -155,23 +206,25 @@ const n = (e) => {
155
206
  hasCalendarCash: e.has_calendar_cash,
156
207
  cashAvailable: e.cash_available,
157
208
  awardPoints: e.award_points,
158
- rooms: (c = e.rooms) == null ? void 0 : c.map(d),
209
+ rooms: (c = e.rooms) == null ? void 0 : c.map(p),
159
210
  hasCalendarPoints: e.has_calendar_points,
160
211
  pointsType: e.points_type,
161
212
  premiumPointsAvailable: e.premium_points_available,
162
213
  standardPointsAvailable: e.standard_points_available,
163
214
  liveScrapingCheckNeeded: e.live_scraping_check_needed,
164
- partners: ((u = e.partners) == null ? void 0 : u.map(b)) ?? [],
165
- hotelProgram: g(e.hotel_program),
215
+ partners: ((u = e.partners) == null ? void 0 : u.map(R)) ?? [],
216
+ hotelProgram: N(e.hotel_program),
217
+ pointsProgramDisplay: e.points_program_display,
166
218
  bestValue: e.best_value,
167
- pointsAsCash: f(e.points_as_cash),
219
+ pointsAsCash: I(e.points_as_cash),
220
+ cashBookingOffers: T(e.cash_booking_offers),
168
221
  distance: 0,
169
222
  // Calculated separately
170
223
  pointsCalculated: 0
171
224
  // Calculated separately
172
225
  };
173
- }, v = (e) => {
174
- var a, t, o, i, s;
226
+ }, x = (e) => {
227
+ var a, t, i, s, o;
175
228
  return {
176
229
  hotelName: e.hotel_name,
177
230
  hotelNameKey: e.hotel_name_key,
@@ -182,12 +235,12 @@ const n = (e) => {
182
235
  points: {
183
236
  pointsType: ((a = e.points) == null ? void 0 : a.points_type) ?? "",
184
237
  pointsValue: n((t = e.points) == null ? void 0 : t.points_value),
185
- awardPointsValue: n((o = e.points) == null ? void 0 : o.award_points_value),
186
- availability: ((i = e.points) == null ? void 0 : i.availability) ?? !1
238
+ awardPointsValue: n((i = e.points) == null ? void 0 : i.award_points_value),
239
+ availability: ((s = e.points) == null ? void 0 : s.availability) ?? !1
187
240
  },
188
- rooms: ((s = e.rooms) == null ? void 0 : s.map(d)) ?? []
241
+ rooms: ((o = e.rooms) == null ? void 0 : o.map(p)) ?? []
189
242
  };
190
- }, P = (e) => {
243
+ }, D = (e) => {
191
244
  var a, t;
192
245
  return {
193
246
  partnerProgram: e.partner_program,
@@ -210,9 +263,10 @@ const n = (e) => {
210
263
  };
211
264
  };
212
265
  export {
213
- C as mapHotelResponse,
214
- v as mapLiveHotelCheckResponse,
215
- y as mapRateResponse,
216
- d as mapRoomResponse,
217
- P as mapTransferPartnerResponse
266
+ T as mapCashBookingOffersResponse,
267
+ L as mapHotelResponse,
268
+ x as mapLiveHotelCheckResponse,
269
+ w as mapRateResponse,
270
+ p as mapRoomResponse,
271
+ D as mapTransferPartnerResponse
218
272
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@odynn/awayz-hotels",
3
3
  "private": false,
4
- "version": "0.12.6",
4
+ "version": "0.13.1",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -56,6 +56,7 @@
56
56
  "vite": "^6.0.5",
57
57
  "vite-plugin-dts": "^4.5.0",
58
58
  "vite-plugin-lib-inject-css": "^2.2.1",
59
+ "vitest": "^4.0.18",
59
60
  "zustand": "^5.0.3"
60
61
  },
61
62
  "sideEffects": [