@odynn/awayz-hotels 0.4.3 → 0.4.4

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.
@@ -0,0 +1,4 @@
1
+ var S = /* @__PURE__ */ ((R) => (R.LOCATIONS = "LOCATIONS", R.CHECK_USER = "CHECK_USER", R.USER_REGIONS = "USER_REGIONS", R.CONVERT_CURRENCY = "CONVERT_CURRENCY", R.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", R.SEARCH_LIMIT = "SEARCH_LIMIT", R.PROGRAMS = "PROGRAMS", R.USER_PROGRAMS = "USER_PROGRAMS", R.LINKED_USER_PROGRAMS = "LINKED_USER_PROGRAMS", R.BANKS = "BANKS", R.CARDS = "CARDS", R.USER_CARDS = "USER_CARDS", R.TRIPS = "TRIPS", R.UNCATEGORISED_BOOKINGS = "UNCATEGORISED_BOOKINGS", R.BOOKING = "BOOKING", R.VALUE_CENTS = "VALUE_CENTS", R))(S || {});
2
+ export {
3
+ S as E
4
+ };
@@ -5,7 +5,7 @@ import { HotelChains as s } from "../../definitions/HotelChains.js";
5
5
  import { h as a } from "../../moment-BGjjqtLQ.js";
6
6
  import P from "../../stores/useHotelsStore.js";
7
7
  import { g as T } from "../../dateUtils-C1hKW8MF.js";
8
- import { E as f } from "../../enums-DQwp1Z7V.js";
8
+ import { E as f } from "../../enums-B584l_96.js";
9
9
  import "../../arrayExtensions-CFEBYUok.js";
10
10
  import "react";
11
11
  import { checkNthNightFree as B } from "../../utilities/hotelUtils/freeNightUtils.js";
@@ -2,7 +2,7 @@ import { useQuery as u } from "@tanstack/react-query";
2
2
  import { HotelService as l } from "../../services/hotel/HotelService.js";
3
3
  import "../../moment-BGjjqtLQ.js";
4
4
  import "../../arrayExtensions-CFEBYUok.js";
5
- import { E as d } from "../../enums-DQwp1Z7V.js";
5
+ import { E as d } from "../../enums-B584l_96.js";
6
6
  import { useState as f, useEffect as L } from "react";
7
7
  import { defaultSimilarityThreshold as p, defaultLocationSortOrder as y, duffelTestHotelLocation as T } from "../../configs/defaults.js";
8
8
  import { sortLocationResults as E } from "../../utilities/hotelUtils/hotelUtils.js";
@@ -154,6 +154,14 @@ export interface IBestCheckout {
154
154
  * `IBestCheckoutResponse.main_program_daily_points_value`
155
155
  */
156
156
  nightlyCashCost: number;
157
+ /**
158
+ * ---
159
+ * ### The cents value of the main program.
160
+ *
161
+ * Maps to:
162
+ * `IBestCheckoutResponse.value_cents`
163
+ */
164
+ valueCents?: number;
157
165
  }
158
166
  export interface ITransferPartner {
159
167
  partnerProgram: string;
@@ -1,7 +1,7 @@
1
- import { IHotelPointsCheckArgs, ISearchByHotelIdRequest, ISearchHotelsParams, ISearchLocation } from './HotelService.types';
2
- import { IHotelDetails, ILiveHotelCheck } from '../../components/HotelResult/HotelResult.types';
3
1
  import { TServiceResponse } from '@type-op/shared';
2
+ import { IHotelDetails, ILiveHotelCheck } from '../../components/HotelResult/HotelResult.types';
4
3
  import { IBestCheckout, ITransferPartner } from '../../hooks/useHotelDetails/useHotelDetails.types';
4
+ import { IHotelPointsCheckArgs, ISearchByHotelIdRequest, ISearchHotelsParams, ISearchLocation } from './HotelService.types';
5
5
  declare class _HotelService {
6
6
  getLocations: (searchInputQuery: string) => Promise<TServiceResponse<ISearchLocation[]>>;
7
7
  searchByCoords: (request: ISearchHotelsParams) => Promise<TServiceResponse<IHotelDetails[]>>;
@@ -1,27 +1,27 @@
1
1
  var f = Object.defineProperty;
2
2
  var E = (i, s, e) => s in i ? f(i, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[s] = e;
3
3
  var n = (i, s, e) => E(i, typeof s != "symbol" ? s + "" : s, e);
4
- import { ESearchType as C } from "./HotelService.types.js";
5
- import { s as T } from "../../stringUtils-DFhHh7H1.js";
4
+ import { clientInstance as l } from "@odynn/awayz-core";
5
+ import { s as C } from "../../stringUtils-DFhHh7H1.js";
6
6
  import "../../moment-BGjjqtLQ.js";
7
7
  import "../../arrayExtensions-CFEBYUok.js";
8
8
  import { c as h } from "../../objectUtils-CyIaVmog.js";
9
9
  import { E as m } from "../../DateFormats-DZD30Nea.js";
10
10
  import "react";
11
- import { EHotelEndpoints as l } from "../../configs/endpoints.js";
12
- import { clientInstance as _ } from "@odynn/awayz-core";
11
+ import { EHotelEndpoints as _ } from "../../configs/endpoints.js";
13
12
  import { EBestCheckoutType as d } from "../../enums/EBestCheckoutType.js";
14
- import { EBestValueType as H } from "../../enums/EBestValueType.js";
15
- import { BestCheckoutHelper as P } from "./BestCheckoutHelper.js";
16
- class S {
13
+ import { EBestValueType as T } from "../../enums/EBestValueType.js";
14
+ import { BestCheckoutHelper as H } from "./BestCheckoutHelper.js";
15
+ import { ESearchType as v } from "./HotelService.types.js";
16
+ class P {
17
17
  constructor() {
18
18
  n(this, "getLocations", async (s) => {
19
19
  try {
20
- const { data: e } = await _.get(
21
- l.GET_LOCATIONS,
20
+ const { data: e } = await l.get(
21
+ _.GET_LOCATIONS,
22
22
  {
23
23
  params: {
24
- search: T(s)
24
+ search: C(s)
25
25
  }
26
26
  }
27
27
  );
@@ -30,15 +30,15 @@ class S {
30
30
  success: !1,
31
31
  message: (e == null ? void 0 : e.message) || "Error fetching location data"
32
32
  };
33
- const o = (a) => a.search_type === C.HOTEL;
33
+ const o = (a) => a.search_type === v.HOTEL;
34
34
  return {
35
35
  success: !0,
36
36
  data: e.data.cities.map(
37
37
  (a) => {
38
- const { search_id: c, search_type: p, description: r, coordinates: g, city: y } = a, u = {
39
- searchId: c,
38
+ const { search_id: r, search_type: p, description: c, coordinates: g, city: y } = a, u = {
39
+ searchId: r,
40
40
  searchType: p,
41
- description: r,
41
+ description: c,
42
42
  coordinates: g,
43
43
  city: y
44
44
  };
@@ -61,7 +61,7 @@ class S {
61
61
  n(this, "searchByCoords", async (s) => {
62
62
  var e, o;
63
63
  try {
64
- const { data: t } = await _.post(l.SEARCH_HOTELS, {
64
+ const { data: t } = await l.post(_.SEARCH_HOTELS, {
65
65
  ...s,
66
66
  use_duffel: !0
67
67
  });
@@ -84,7 +84,7 @@ class S {
84
84
  n(this, "searchByHotelId", async (s) => {
85
85
  var e, o;
86
86
  try {
87
- const { data: t } = await _.post(l.GET_HOTEL_DATA, {
87
+ const { data: t } = await l.post(_.GET_HOTEL_DATA, {
88
88
  ...s,
89
89
  use_duffel: !0
90
90
  });
@@ -106,8 +106,8 @@ class S {
106
106
  });
107
107
  n(this, "getTransferPartners", async (s) => {
108
108
  try {
109
- const { data: e } = await _.get(
110
- l.GET_TRANSFER_PARTNERS,
109
+ const { data: e } = await l.get(
110
+ _.GET_TRANSFER_PARTNERS,
111
111
  {
112
112
  params: {
113
113
  program: s
@@ -128,8 +128,8 @@ class S {
128
128
  check_out_date: s.checkoutDate.format(m.ServerDate)
129
129
  };
130
130
  try {
131
- const { data: t } = await _.post(
132
- l.HOTEL_POINTS_CHECK,
131
+ const { data: t } = await l.post(
132
+ _.HOTEL_POINTS_CHECK,
133
133
  e
134
134
  ), a = ((o = t.data) == null ? void 0 : o.length) > 0 ? t.data[0] : null;
135
135
  return {
@@ -148,45 +148,46 @@ class S {
148
148
  n(this, "getRecommendations", async (s) => {
149
149
  try {
150
150
  const t = {
151
- hotels: (await new P(s.hotels).getConvertedHotels(
151
+ hotels: (await new H(s.hotels).getConvertedHotels(
152
152
  s.userCurrency
153
- )).map((r) => ({
154
- hotel_id: r.hotelId,
155
- hotel_group: r.hotelGroup,
156
- cash_value: r.cashValue,
157
- currency: r.cashValue.currency,
158
- award_points: r.awardPoints,
159
- points: r.points
153
+ )).map((c) => ({
154
+ hotel_id: c.hotelId,
155
+ hotel_group: c.hotelGroup,
156
+ cash_value: c.cashValue,
157
+ currency: c.cashValue.currency,
158
+ award_points: c.awardPoints,
159
+ points: c.points
160
160
  })),
161
161
  days: s.days,
162
162
  cash_or_points: ["cash", "points"]
163
- }, { data: a } = await _.post(
164
- l.GET_BEST_CHECKOUT,
163
+ }, { data: a } = await l.post(
164
+ _.GET_BEST_CHECKOUT,
165
165
  t
166
- ), c = a.data[0];
166
+ ), r = a.data[0];
167
167
  return {
168
168
  success: !0,
169
169
  data: {
170
- totalPointsCost: c.total_hotel_points_cost,
171
- nightlyPointsCost: c.points,
172
- totalCashCost: c.total_cash_cost,
173
- nightlyCashCost: c.cash_value.amount,
174
- currency: c.cash_value.currency,
175
- sufficientPoints: c.user_has_sufficient_points,
176
- awardPoints: c.award_points,
177
- rewardsProgram: c.hotel_rewards_program,
178
- bestCheckoutMethod: c.best_user_checkout_method === H.CASH ? d.CASH : d.POINTS,
170
+ totalPointsCost: r.total_hotel_points_cost,
171
+ nightlyPointsCost: r.points,
172
+ totalCashCost: r.total_cash_cost,
173
+ nightlyCashCost: r.cash_value.amount,
174
+ currency: r.cash_value.currency,
175
+ sufficientPoints: r.user_has_sufficient_points,
176
+ awardPoints: r.award_points,
177
+ rewardsProgram: r.hotel_rewards_program,
178
+ valueCents: r.value_cents,
179
+ bestCheckoutMethod: r.best_user_checkout_method === T.CASH ? d.CASH : d.POINTS,
179
180
  optimalProgram: {
180
- totalProgramPointsValuation: c.optimal_user_program_checkout.total_program_points_valuation,
181
- remainingPointsBalance: c.optimal_user_program_checkout.primary_offer_remaining_points_balance,
182
- programs: c.optimal_user_program_checkout.programs.map(
183
- (r) => ({
184
- convertedPoints: r.converted_program_points,
185
- program: r.program,
186
- pointsUsed: r.program_points_used,
187
- transferRatio: r.program_transfer_ratio,
188
- centsPerPoint: r.program_value_cents,
189
- programPointsValue: r.program_points_value
181
+ totalProgramPointsValuation: r.optimal_user_program_checkout.total_program_points_valuation,
182
+ remainingPointsBalance: r.optimal_user_program_checkout.primary_offer_remaining_points_balance,
183
+ programs: r.optimal_user_program_checkout.programs.map(
184
+ (c) => ({
185
+ convertedPoints: c.converted_program_points,
186
+ program: c.program,
187
+ pointsUsed: c.program_points_used,
188
+ transferRatio: c.program_transfer_ratio,
189
+ centsPerPoint: c.program_value_cents,
190
+ programPointsValue: c.program_points_value
190
191
  })
191
192
  )
192
193
  }
@@ -202,7 +203,7 @@ class S {
202
203
  });
203
204
  }
204
205
  }
205
- const V = new S();
206
+ const V = new P();
206
207
  export {
207
208
  V as HotelService
208
209
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@odynn/awayz-hotels",
3
3
  "private": false,
4
- "version": "0.4.3",
4
+ "version": "0.4.4",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -62,7 +62,7 @@
62
62
  ]
63
63
  },
64
64
  "dependencies": {
65
- "@odynn/awayz-core": "^0.4.1",
65
+ "@odynn/awayz-core": "^0.4.2",
66
66
  "@tanstack/react-query": "^5.66.9",
67
67
  "string-comparison": "^1.3.0"
68
68
  }
@@ -1,4 +0,0 @@
1
- var S = /* @__PURE__ */ ((R) => (R.LOCATIONS = "LOCATIONS", R.CHECK_USER = "CHECK_USER", R.USER_REGIONS = "USER_REGIONS", R.CONVERT_CURRENCY = "CONVERT_CURRENCY", R.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", R.SEARCH_LIMIT = "SEARCH_LIMIT", R.PROGRAMS = "PROGRAMS", R.USER_PROGRAMS = "USER_PROGRAMS", R.BANKS = "BANKS", R.CARDS = "CARDS", R.USER_CARDS = "USER_CARDS", R.TRIPS = "TRIPS", R.UNCATEGORISED_BOOKINGS = "UNCATEGORISED_BOOKINGS", R.BOOKING = "BOOKING", R))(S || {});
2
- export {
3
- S as E
4
- };