@odynn/awayz-hotels 0.12.6 → 0.13.0

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,9 @@ export interface IHotelDetails {
47
47
  standardPointsAvailable: boolean;
48
48
  liveScrapingCheckNeeded: boolean;
49
49
  partners: IHotelPartner[];
50
- hotelProgram: IHotelProgram;
50
+ hotelProgram?: IHotelProgram;
51
51
  bestValue: string;
52
- pointsAsCash: IHotelPointsAsCash;
52
+ pointsAsCash?: IHotelPointsAsCash;
53
53
  imagesS3?: string[];
54
54
  colour?: string;
55
55
  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,12 @@ 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
83
  best_value: string;
84
- points_as_cash: IPointsAsCashResponse;
84
+ points_as_cash?: IPointsAsCashResponse;
85
+ cash_booking_offers?: ICashBookingOffersResponse;
85
86
  }
86
87
  interface IHotelPartnerResponse {
87
88
  program: string;
@@ -114,6 +115,60 @@ interface IPointsAsCashResponse {
114
115
  total_points_used: number;
115
116
  award_program: string | number;
116
117
  }
118
+ export interface ICashBookingOffersResponse {
119
+ search_room_rate_id: string;
120
+ accommodation_id: string;
121
+ matched_type: string;
122
+ rooms: IRoomResponse[];
123
+ ratings: {
124
+ source: string;
125
+ value: number;
126
+ }[];
127
+ rating: number;
128
+ review_score: number;
129
+ review_count?: number | string | undefined;
130
+ photos: {
131
+ url: string;
132
+ }[];
133
+ phone_number: string;
134
+ name: string;
135
+ location: {
136
+ geographic_coordinates: {
137
+ latitude: number;
138
+ longitude: number;
139
+ };
140
+ address: {
141
+ region: any;
142
+ postal_code: string;
143
+ line_one: string;
144
+ country_code: string;
145
+ city_name: string;
146
+ };
147
+ };
148
+ id: string;
149
+ email: string | null;
150
+ description: string;
151
+ check_in_information: {
152
+ check_in_after_time: string;
153
+ check_out_before_time: string;
154
+ check_in_before_time: string;
155
+ };
156
+ matched_score: number;
157
+ key_collection: any;
158
+ cheapest_rate_total_amount: number;
159
+ cheapest_rate_currency: string;
160
+ chain: {
161
+ name: string;
162
+ };
163
+ brand: {
164
+ name: string;
165
+ };
166
+ supported_loyalty_programme: any;
167
+ amenities: {
168
+ description: string;
169
+ type: string;
170
+ }[];
171
+ }
117
172
  export interface IPlaceResponse {
118
173
  mapbox_id: string;
119
174
  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, A;
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: ((A = e.brand) == null ? void 0 : A.name) ?? "" },
125
+ supportedLoyaltyProgramme: e.supported_loyalty_programme,
126
+ amenities: e.amenities ?? []
127
+ };
128
+ }, P = (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: P(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: P(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,24 @@ 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),
166
217
  bestValue: e.best_value,
167
- pointsAsCash: f(e.points_as_cash),
218
+ pointsAsCash: I(e.points_as_cash),
219
+ cashBookingOffers: T(e.cash_booking_offers),
168
220
  distance: 0,
169
221
  // Calculated separately
170
222
  pointsCalculated: 0
171
223
  // Calculated separately
172
224
  };
173
- }, v = (e) => {
174
- var a, t, o, i, s;
225
+ }, x = (e) => {
226
+ var a, t, i, s, o;
175
227
  return {
176
228
  hotelName: e.hotel_name,
177
229
  hotelNameKey: e.hotel_name_key,
@@ -182,12 +234,12 @@ const n = (e) => {
182
234
  points: {
183
235
  pointsType: ((a = e.points) == null ? void 0 : a.points_type) ?? "",
184
236
  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
237
+ awardPointsValue: n((i = e.points) == null ? void 0 : i.award_points_value),
238
+ availability: ((s = e.points) == null ? void 0 : s.availability) ?? !1
187
239
  },
188
- rooms: ((s = e.rooms) == null ? void 0 : s.map(d)) ?? []
240
+ rooms: ((o = e.rooms) == null ? void 0 : o.map(p)) ?? []
189
241
  };
190
- }, P = (e) => {
242
+ }, O = (e) => {
191
243
  var a, t;
192
244
  return {
193
245
  partnerProgram: e.partner_program,
@@ -210,9 +262,10 @@ const n = (e) => {
210
262
  };
211
263
  };
212
264
  export {
213
- C as mapHotelResponse,
214
- v as mapLiveHotelCheckResponse,
215
- y as mapRateResponse,
216
- d as mapRoomResponse,
217
- P as mapTransferPartnerResponse
265
+ T as mapCashBookingOffersResponse,
266
+ L as mapHotelResponse,
267
+ x as mapLiveHotelCheckResponse,
268
+ w as mapRateResponse,
269
+ p as mapRoomResponse,
270
+ O as mapTransferPartnerResponse
218
271
  };
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.0",
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": [