@odynn/awayz-core 0.9.4 → 0.9.6

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.
@@ -2,18 +2,18 @@ import { jsxs as p } from "react/jsx-runtime";
2
2
  import { useQuery as m } from "@tanstack/react-query";
3
3
  import "../../arrayExtensions-DlcBOj5a.js";
4
4
  import { E as u } from "../../noRetryInstance-oiHCni_Z.js";
5
- import { useMemo as f } from "react";
6
- import { useAwayzContext as y } from "../../hooks/useAwayzContext.js";
5
+ import { useMemo as y } from "react";
6
+ import { useAwayzContext as f } from "../../hooks/useAwayzContext.js";
7
7
  import "react-i18next";
8
8
  import '../../assets/_styles3.css';import '../../assets/_styles4.css';import '../../assets/_styles.css';import '../../assets/_styles2.css';/* empty css */
9
9
  import "../../_styles.flight-booking-DEUJthTJ.js";
10
10
  /* empty css */
11
- import { CurrencyService as l } from "../../services/currency/CurrencyService.js";
11
+ import { CurrencyService as C } from "../../services/currency/CurrencyService.js";
12
12
  /* empty css */
13
13
  /* empty css */
14
14
  import "../../configs/awayzClient.js";
15
15
  import "../../context/AwayzContext.js";
16
- import { useFeatureFlags as C } from "../../hooks/useFeatureFlags.js";
16
+ import { useFeatureFlags as l } from "../../hooks/useFeatureFlags.js";
17
17
  import { useWallet as d } from "../../hooks/useWallet/useWallet.js";
18
18
  function g(t) {
19
19
  if (!t || isNaN(t) || t < 0) return "N/A";
@@ -27,19 +27,19 @@ const v = (t, e) => {
27
27
  cashAmount: t,
28
28
  currency: e
29
29
  }) => {
30
- const { pointsAsCash: r } = d(), { user: o } = y(), { featureFlags: i } = C(), n = f(
30
+ const { pointsAsCash: r } = d(), { user: o } = f(), { featureFlags: i } = l(), n = y(
31
31
  () => v(i.defaultCurrencyFeature, o),
32
32
  [o]
33
33
  ), { data: c } = m({
34
34
  queryKey: [u.CONVERT_CURRENCY, e, r.currency],
35
- queryFn: () => l.convertCurrency({
35
+ queryFn: () => C.convertCurrency({
36
36
  baseCurrency: e,
37
37
  targetCurrency: r.currency
38
38
  }),
39
39
  staleTime: 1e3 * 60 * 60,
40
40
  // 1 hour
41
41
  enabled: !!e && !!n && e !== n && r.currency !== e && !!r.currency
42
- }), s = t * (c ?? 1), a = Math.floor(s / r.valuePerPoint);
42
+ }), s = t * (c ?? 1), a = Math.round(s / r.valuePerPoint);
43
43
  return /* @__PURE__ */ p("p", { className: "client-points-amount", children: [
44
44
  g(a),
45
45
  " pts."
@@ -1,10 +1,10 @@
1
- var r = /* @__PURE__ */ ((e) => (e.SIGN_IN = "auth/user-login", e.SIGN_UP = "auth/sign-up", e.GOOGLE_AUTH = "/auth/google-user", e.ME = "user", e.RESEND_VERIFICATION_EMAIL = "auth/resend-verification-email", e.UPDATE_USER_DETAILS = "account/update/user", e.CONFIRM_EMAIL = "account/verifyAccount", e.FORGOT_PASSWORD = "email/sendVeri", e.RESEND_OTP = "email/sendForgotPasswordVerification", e.RESET_PASSWORD = "account/updateUserPassword", e.REQUEST_LIMIT = "user/request-limit", e.APPLE_SOCIAL_SIGN_UP = "tp/apple/get/user", e.GOOGLE_SOCIAL_SIGN_UP = "tp/google/get/user", e.UPDATE_USER = "account/details/addUserDetails", e.ACKNOWLEDGEMENT = "account/update/userAcknowledgement", e.REGIONS = "user/region", e.UPDATE_USER_REGION = "/account/update/userRegion", e.UPDATE_PASSENGER_DETAILS = "/account/awayz", e.REFRESH_TOKEN = "auth/refresh-token", e.EXCHANGE_TOKEN = "user/exchange-token", e.REFRESH_EMBED_TOKEN = "user/refresh-token", e.OAUTH_INITIATE = "user/oauth2/initiate", e.OAUTH_CALLBACK = "user/oauth2/callback", e.FEATURES = "/user/features", e))(r || {}), a = /* @__PURE__ */ ((e) => (e.CURRENCY_CONVERSION = "currency/convert", e))(a || {}), _ = /* @__PURE__ */ ((e) => (e.USER_AWARDS = "user/rewards", e.LINKED_USER_AWARDS = "user/rewards/user-linked", e.USER_CARDS = "user/cards", e.ADD_USER_CARDS = "user/cards/add", e.REMOVE_USER_CARDS = "user/cards/remove", e.BANKS = "banks", e.CARDS = "cards", e.POINTS_AS_CASH = "/points-as-cash/available-points", e))(_ || {}), S = /* @__PURE__ */ ((e) => (e.TRIPS = "user/trips", e.ADD_BOOKING = "user/trips/add-booking-to-trip", e.REMOVE_BOOKING = "user/trips/remove-booking-from-trip", e.UNCATEGORISED_BOOKINGS = "/user/trips/get-uncategorized-bookings", e))(S || {}), R = /* @__PURE__ */ ((e) => (e.USER_HOTEL_BOOKINGS = "/user/bookings/hotels", e.USER_FLIGHT_BOOKINGS = "/user/bookings/flights", e.INITIATE_FLIGHT_CANCEL = "/duffel/flights/initiate-order-cancellation", e.CONFIRM_FLIGHT_CANCEL = "/duffel/flights/confirm-order-cancellation", e.CANCEL_HOTEL_BOOKING = "/duffel/hotels/cancel", e.ACTION_AIRLINE_CHANGES = "/user/bookings/flights/action-airline-initiated-changes", e.REFUND_POINTS_BOOKING = "/points-as-cash/refund-booking", e))(R || {}), O = /* @__PURE__ */ ((e) => (e.POINTS_PER_CENT = "/user/rewards/points-per-cent", e))(O || {}), I = /* @__PURE__ */ ((e) => (e.USER_PREFERENCES = "/user/user-preferences", e))(I || {});
1
+ var r = /* @__PURE__ */ ((e) => (e.SIGN_IN = "auth/user-login", e.SIGN_UP = "auth/sign-up", e.GOOGLE_AUTH = "/auth/google-user", e.ME = "user", e.RESEND_VERIFICATION_EMAIL = "auth/resend-verification-email", e.UPDATE_USER_DETAILS = "account/update/user", e.CONFIRM_EMAIL = "account/verifyAccount", e.FORGOT_PASSWORD = "email/sendVeri", e.RESEND_OTP = "email/sendForgotPasswordVerification", e.RESET_PASSWORD = "account/updateUserPassword", e.REQUEST_LIMIT = "user/request-limit", e.APPLE_SOCIAL_SIGN_UP = "tp/apple/get/user", e.GOOGLE_SOCIAL_SIGN_UP = "tp/google/get/user", e.UPDATE_USER = "account/details/addUserDetails", e.ACKNOWLEDGEMENT = "account/update/userAcknowledgement", e.REGIONS = "user/region", e.UPDATE_USER_REGION = "/account/update/userRegion", e.UPDATE_PASSENGER_DETAILS = "/account/awayz", e.REFRESH_TOKEN = "auth/refresh-token", e.EXCHANGE_TOKEN = "user/exchange-token", e.REFRESH_EMBED_TOKEN = "user/refresh-token", e.OAUTH_INITIATE = "user/oauth2/initiate", e.OAUTH_CALLBACK = "user/oauth2/callback", e.FEATURES = "/user/features", e))(r || {}), a = /* @__PURE__ */ ((e) => (e.CURRENCY_CONVERSION = "currency/convert", e))(a || {}), _ = /* @__PURE__ */ ((e) => (e.USER_AWARDS = "user/rewards", e.LINKED_USER_AWARDS = "user/rewards/user-linked", e.USER_CARDS = "user/cards", e.ADD_USER_CARDS = "user/cards/add", e.REMOVE_USER_CARDS = "user/cards/remove", e.BANKS = "banks", e.CARDS = "cards", e.POINTS_AS_CASH = "/points-as-cash/available-points", e))(_ || {}), S = /* @__PURE__ */ ((e) => (e.TRIPS = "user/trips", e.ADD_BOOKING = "user/trips/add-booking-to-trip", e.REMOVE_BOOKING = "user/trips/remove-booking-from-trip", e.UNCATEGORISED_BOOKINGS = "/user/trips/get-uncategorized-bookings", e))(S || {}), O = /* @__PURE__ */ ((e) => (e.USER_HOTEL_BOOKINGS = "/user/bookings/hotels", e.USER_FLIGHT_BOOKINGS = "/user/bookings/flights", e.INITIATE_FLIGHT_CANCEL = "/duffel/flights/initiate-order-cancellation", e.CONFIRM_FLIGHT_CANCEL = "/duffel/flights/confirm-order-cancellation", e.CANCEL_HOTEL_BOOKING = "/duffel/hotels/cancel", e.ACTION_AIRLINE_CHANGES = "/user/bookings/flights/action-airline-initiated-changes", e.REFUND_POINTS_BOOKING = "/points-as-cash/refund-booking", e.BOOKING_POINTS_AS_CASH = "/points-as-cash", e))(O || {}), I = /* @__PURE__ */ ((e) => (e.POINTS_PER_CENT = "/user/rewards/points-per-cent", e))(I || {}), N = /* @__PURE__ */ ((e) => (e.USER_PREFERENCES = "/user/user-preferences", e))(N || {});
2
2
  export {
3
3
  r as EAuthEndpoints,
4
- R as EBookingEndpoints,
4
+ O as EBookingEndpoints,
5
5
  a as ECurrencyEndpoints,
6
6
  S as EMyTripsEndpoints,
7
- I as EPreferencesEndpoints,
8
- O as ERewardsEndpoints,
7
+ N as EPreferencesEndpoints,
8
+ I as ERewardsEndpoints,
9
9
  _ as EWalletEndpoints
10
10
  };
@@ -1,134 +1,140 @@
1
- import { useQuery as h, useMutation as u } from "@tanstack/react-query";
1
+ import { useQuery as u, useMutation as m } from "@tanstack/react-query";
2
2
  import "../../arrayExtensions-DlcBOj5a.js";
3
- import { E as s } from "../../noRetryInstance-oiHCni_Z.js";
3
+ import { E as a } from "../../noRetryInstance-oiHCni_Z.js";
4
4
  import "react";
5
5
  import "react/jsx-runtime";
6
6
  import "react-i18next";
7
7
  import '../../assets/_styles3.css';import '../../assets/_styles4.css';import '../../assets/_styles.css';import '../../assets/_styles2.css';/* empty css */
8
8
  import "../../_styles.flight-booking-DEUJthTJ.js";
9
9
  /* empty css */
10
- import { awayzClient as q } from "../../configs/awayzClient.js";
10
+ import { awayzClient as k } from "../../configs/awayzClient.js";
11
11
  /* empty css */
12
12
  import "../../context/AwayzContext.js";
13
13
  import { EBookingType as o } from "../../services/trips/TripService.types.js";
14
14
  /* empty css */
15
15
  import { BookingService as e } from "../../services/bookings/BookingService.js";
16
- const $ = (n, t) => {
16
+ const b = (r, t) => {
17
17
  const {
18
- data: i,
19
- isError: E,
18
+ data: s,
19
+ isError: g,
20
20
  error: d
21
- } = h({
22
- queryKey: [s.BOOKING, n, o.HOTEL],
23
- queryFn: () => e.getHotelBooking(n),
24
- enabled: t === o.HOTEL && !!n
21
+ } = u({
22
+ queryKey: [a.BOOKING, r, o.HOTEL],
23
+ queryFn: () => e.getHotelBooking(r),
24
+ enabled: t === o.HOTEL && !!r
25
25
  }), {
26
- data: r,
27
- isError: A,
26
+ data: n,
27
+ isError: B,
28
28
  error: f
29
- } = h({
30
- queryKey: [s.BOOKING, n, o.FLIGHT],
31
- queryFn: () => e.getFlightBooking(n),
32
- enabled: t === o.FLIGHT && !!n
29
+ } = u({
30
+ queryKey: [a.BOOKING, r, o.FLIGHT],
31
+ queryFn: () => e.getFlightBooking(r),
32
+ enabled: t === o.FLIGHT && !!r
33
+ }), { data: i, isLoading: F } = u({
34
+ queryKey: [a.BOOKING, r],
35
+ queryFn: () => e.getPointsAsCash(r),
36
+ enabled: !!r
33
37
  }), {
34
- mutate: g,
35
- isPending: B,
36
- isError: F,
38
+ mutate: O,
39
+ isPending: A,
40
+ isError: y,
37
41
  error: H,
38
- isSuccess: O
39
- } = u({
42
+ isSuccess: L
43
+ } = m({
40
44
  mutationFn: async () => {
41
- if (i != null && i.pointsAsCash)
45
+ if (i)
42
46
  throw new Error("Not supported for bookings made with Points as Cash");
43
47
  if (t === o.FLIGHT)
44
- return e.initiateCancelFlightBooking(n);
48
+ return e.initiateCancelFlightBooking(r);
45
49
  throw new Error("Not supported for hotel bookings");
46
50
  },
47
51
  onSuccess: () => {
48
- a();
52
+ c();
49
53
  }
50
54
  }), {
51
- mutate: I,
52
- isPending: m,
53
- isError: y,
54
- error: G,
55
- isSuccess: L
56
- } = u({
55
+ mutate: G,
56
+ isPending: C,
57
+ isError: S,
58
+ error: w,
59
+ isSuccess: I
60
+ } = m({
57
61
  mutationFn: async () => {
58
62
  if (t === o.FLIGHT)
59
- return r != null && r.pointsAsCash && await e.cancelPointsBooking({
60
- confirmationCode: r.pointsAsCash.confirmationCode,
61
- orderId: r.orderId,
62
- provider: r.pointsAsCash.provider,
63
+ return i && n && await e.cancelPointsBooking({
64
+ confirmationCode: i.confirmationCode,
65
+ orderId: n.orderId,
66
+ provider: i.provider,
63
67
  type: o.FLIGHT,
64
- pointsAmount: r.pointsAsCash.points,
65
- cashAmount: r.pointsAsCash.cashValue.amount
66
- }), e.confirmCancelFlightBooking(n);
68
+ pointsAmount: i.points,
69
+ cashAmount: i.cashValue.amount
70
+ }), e.confirmCancelFlightBooking(r);
67
71
  if (t === o.HOTEL)
68
- return i != null && i.pointsAsCash && await e.cancelPointsBooking({
69
- confirmationCode: i.pointsAsCash.confirmationCode,
70
- orderId: i.bookingId,
71
- provider: i.pointsAsCash.provider,
72
+ return i && s && await e.cancelPointsBooking({
73
+ confirmationCode: i.confirmationCode,
74
+ orderId: s.bookingId,
75
+ provider: i.provider,
72
76
  type: o.HOTEL,
73
- pointsAmount: i.pointsAsCash.points,
74
- cashAmount: i.pointsAsCash.cashValue.amount
75
- }), e.cancelHotelBooking(n);
77
+ pointsAmount: i.points,
78
+ cashAmount: i.cashValue.amount
79
+ }), e.cancelHotelBooking(r);
76
80
  },
77
81
  onSuccess: () => {
78
- a();
82
+ c();
79
83
  }
80
84
  }), {
81
- mutate: S,
82
- isPending: w,
83
- isError: v,
84
- error: K
85
- } = u({
86
- mutationFn: async (c) => {
87
- var C, l;
88
- const p = (l = (C = r == null ? void 0 : r.airlineInitiatedChanges) == null ? void 0 : C.filter(
89
- (T) => !T.actionTaken
90
- )) == null ? void 0 : l[0];
91
- if (t === o.FLIGHT && (r != null && r.airlineInitiatedChanges) && p)
85
+ mutate: K,
86
+ isPending: P,
87
+ isError: N,
88
+ error: v
89
+ } = m({
90
+ mutationFn: async (l) => {
91
+ var h, p;
92
+ const E = (p = (h = n == null ? void 0 : n.airlineInitiatedChanges) == null ? void 0 : h.filter(
93
+ (Q) => !Q.actionTaken
94
+ )) == null ? void 0 : p[0];
95
+ if (t === o.FLIGHT && (n != null && n.airlineInitiatedChanges) && E)
92
96
  return e.actionAirlineChanges({
93
- bookingId: n,
94
- acceptChanges: c,
95
- aicId: p.id
97
+ bookingId: r,
98
+ acceptChanges: l,
99
+ aicId: E.id
96
100
  });
97
101
  throw new Error("Not supported for hotel bookings");
98
102
  },
99
103
  onSuccess: () => {
100
- a();
104
+ c();
101
105
  }
102
- }), a = () => {
106
+ }), c = () => {
103
107
  [
104
- [s.BOOKING, n, t],
105
- [s.TRIPS],
106
- [s.UNCATEGORISED_BOOKINGS]
107
- ].forEach((c) => {
108
- q.invalidateQueries({ queryKey: c });
108
+ [a.BOOKING, r, t],
109
+ [a.TRIPS],
110
+ [a.UNCATEGORISED_BOOKINGS]
111
+ ].forEach((l) => {
112
+ k.invalidateQueries({ queryKey: l });
109
113
  });
110
- }, N = E || A, P = d || f;
114
+ }, T = g || B, q = d || f;
111
115
  return {
112
- details: t === o.HOTEL ? i : r,
113
- isError: N,
114
- error: P,
115
- initiateCancellation: g,
116
- isInitiatingCancellation: B,
117
- isInitiateCancellationError: F,
116
+ details: t === o.HOTEL ? s : n,
117
+ isError: T,
118
+ error: q,
119
+ initiateCancellation: O,
120
+ isInitiatingCancellation: A,
121
+ isInitiateCancellationError: y,
118
122
  initiateCancellationError: H,
119
- isInitiateCancellationSuccess: O,
120
- cancelBooking: I,
121
- isCancellingBooking: m,
122
- isCancelingBooking: m,
123
- isCancelBookingError: y,
124
- cancelBookingError: G,
125
- isCancelBookingSuccess: L,
126
- actionAirlineChanges: S,
127
- isActionAirlineChangesPending: w,
128
- isActionAirlineChangesError: v,
129
- actionAirlineChangesError: K
123
+ isInitiateCancellationSuccess: L,
124
+ cancelBooking: G,
125
+ isCancellingBooking: C,
126
+ isCancelingBooking: C,
127
+ isCancelBookingError: S,
128
+ cancelBookingError: w,
129
+ isCancelBookingSuccess: I,
130
+ actionAirlineChanges: K,
131
+ isActionAirlineChangesPending: P,
132
+ isActionAirlineChangesError: N,
133
+ actionAirlineChangesError: v,
134
+ pointsAsCashDetails: i,
135
+ isLoadingPointsAsCash: F
130
136
  };
131
137
  };
132
138
  export {
133
- $ as useBookingManagement
139
+ b as useBookingManagement
134
140
  };
@@ -50,7 +50,8 @@ export declare enum EBookingEndpoints {
50
50
  CONFIRM_FLIGHT_CANCEL = "/duffel/flights/confirm-order-cancellation",
51
51
  CANCEL_HOTEL_BOOKING = "/duffel/hotels/cancel",
52
52
  ACTION_AIRLINE_CHANGES = "/user/bookings/flights/action-airline-initiated-changes",
53
- REFUND_POINTS_BOOKING = "/points-as-cash/refund-booking"
53
+ REFUND_POINTS_BOOKING = "/points-as-cash/refund-booking",
54
+ BOOKING_POINTS_AS_CASH = "/points-as-cash"
54
55
  }
55
56
  export declare enum ERewardsEndpoints {
56
57
  POINTS_PER_CENT = "/user/rewards/points-per-cent"
@@ -1,4 +1,4 @@
1
- import { IFlightBookingDetails, IHotelBookingDetails } from '../../services/bookings/BookingService.types';
1
+ import { IFlightBookingDetails, IHotelBookingDetails, IPointsAsCash } from '../../services/bookings/BookingService.types';
2
2
  export interface IUseBookingManagement {
3
3
  /**
4
4
  * The booking details, which can be either hotel or flight booking details
@@ -77,4 +77,12 @@ export interface IUseBookingManagement {
77
77
  * The error object if there was an error while handling airline initiated changes
78
78
  */
79
79
  actionAirlineChangesError: Error | null;
80
+ /**
81
+ * Points as cash details for the booking, if available
82
+ */
83
+ pointsAsCashDetails: IPointsAsCash | undefined;
84
+ /**
85
+ * Indicates if the points as cash details are being loaded
86
+ */
87
+ isLoadingPointsAsCash: boolean;
80
88
  }
@@ -1,4 +1,4 @@
1
- import { IActionAirlineChangesRequest, ICancelPointsBookingArgs, IFlightBookingDetails, IHotelBookingDetails } from './BookingService.types';
1
+ import { IActionAirlineChangesRequest, ICancelPointsBookingArgs, IFlightBookingDetails, IHotelBookingDetails, IPointsAsCash } from './BookingService.types';
2
2
  declare class _BookingService {
3
3
  getHotelBooking: (bookingId: string) => Promise<IHotelBookingDetails>;
4
4
  getFlightBooking: (bookingId: string) => Promise<IFlightBookingDetails>;
@@ -7,6 +7,7 @@ declare class _BookingService {
7
7
  cancelHotelBooking: (bookingId: string) => Promise<any>;
8
8
  actionAirlineChanges: ({ bookingId, acceptChanges, aicId }: IActionAirlineChangesRequest) => Promise<any>;
9
9
  cancelPointsBooking: (args: ICancelPointsBookingArgs) => Promise<any>;
10
+ getPointsAsCash: (bookingId: string) => Promise<IPointsAsCash>;
10
11
  }
11
12
  export declare const BookingService: _BookingService;
12
13
  export {};
@@ -40,7 +40,6 @@ export interface IHotelBookingDetails {
40
40
  checkinAfterTime: string;
41
41
  coordinates: ICoordinates;
42
42
  cancellationTimeline: ICancellationTimeline[];
43
- pointsAsCash?: IPointsAsCash;
44
43
  rooms: {
45
44
  beds: IBed[];
46
45
  totalAmount: number;
@@ -108,7 +107,6 @@ export interface IFlightBookingDetails {
108
107
  flights: IFlight[];
109
108
  availableActions: string[];
110
109
  airlineInitiatedChanges: IAirlineInitiatedChanges[];
111
- pointsAsCash?: IPointsAsCash;
112
110
  }
113
111
  export interface IFlight {
114
112
  origin: IAirport;
@@ -1,24 +1,24 @@
1
- var p = Object.defineProperty;
2
- var g = (i, t, a) => t in i ? p(i, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : i[t] = a;
3
- var c = (i, t, a) => g(i, typeof t != "symbol" ? t + "" : t, a);
1
+ var g = Object.defineProperty;
2
+ var y = (r, t, a) => t in r ? g(r, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : r[t] = a;
3
+ var i = (r, t, a) => y(r, typeof t != "symbol" ? t + "" : t, a);
4
4
  import "../../arrayExtensions-DlcBOj5a.js";
5
- import { c as r, b as l, g as h } from "../../noRetryInstance-oiHCni_Z.js";
5
+ import { c as d, b as l, g as p } from "../../noRetryInstance-oiHCni_Z.js";
6
6
  import "react";
7
- import { EBookingEndpoints as d } from "../../configs/endpoints.js";
8
- const f = (i) => {
9
- const t = /P((\d+)D)?T((\d+)H)?((\d+)M)?/, a = i.match(t);
7
+ import { EBookingEndpoints as c } from "../../configs/endpoints.js";
8
+ const f = (r) => {
9
+ const t = /P((\d+)D)?T((\d+)H)?((\d+)M)?/, a = r.match(t);
10
10
  if (a) {
11
- const o = a[2] ? `${a[2]}d ` : "", e = a[4] ? `${a[4]}h ` : "", _ = a[6] ? `${a[6]}m` : "";
12
- return `${o}${e}${_}`.trim();
11
+ const o = a[2] ? `${a[2]}d ` : "", e = a[4] ? `${a[4]}h ` : "", m = a[6] ? `${a[6]}m` : "";
12
+ return `${o}${e}${m}`.trim();
13
13
  } else
14
- return i;
14
+ return r;
15
15
  };
16
- class y {
16
+ class h {
17
17
  constructor() {
18
- c(this, "getHotelBooking", async (t) => {
19
- var _, m;
20
- const { data: a } = await r.get(
21
- `${d.USER_HOTEL_BOOKINGS}/${t}`
18
+ i(this, "getHotelBooking", async (t) => {
19
+ var m, _;
20
+ const { data: a } = await d.get(
21
+ `${c.USER_HOTEL_BOOKINGS}/${t}`
22
22
  ), o = a.data.accommodation.rooms[0].rates[0];
23
23
  return {
24
24
  id: a.data._id,
@@ -62,7 +62,7 @@ class y {
62
62
  type: (s = a.data.guest_types[u]) == null ? void 0 : s.type
63
63
  };
64
64
  }),
65
- numberOfRooms: (_ = a.data.rooms) == null ? void 0 : _.length,
65
+ numberOfRooms: (m = a.data.rooms) == null ? void 0 : m.length,
66
66
  cancellationTimeline: o.cancellation_timeline.map(
67
67
  (n) => ({
68
68
  refundAmount: parseFloat(n.refund_amount),
@@ -70,15 +70,7 @@ class y {
70
70
  before: n.before
71
71
  })
72
72
  ),
73
- pointsAsCash: a.data.points_as_cash ? {
74
- authCode: a.data.points_as_cash.auth_code,
75
- points: a.data.points_as_cash.points,
76
- pointsValue: a.data.points_as_cash.points_value,
77
- confirmationCode: a.data.points_as_cash.confirmation_code,
78
- provider: a.data.points_as_cash.provider,
79
- cashValue: a.data.points_as_cash.cash_value
80
- } : void 0,
81
- rooms: (m = a.data.rooms) == null ? void 0 : m.map((n) => {
73
+ rooms: (_ = a.data.rooms) == null ? void 0 : _.map((n) => {
82
74
  var u;
83
75
  return {
84
76
  beds: (u = n.beds) == null ? void 0 : u.map((s) => ({
@@ -92,9 +84,9 @@ class y {
92
84
  createdAt: a.data.created_at
93
85
  };
94
86
  });
95
- c(this, "getFlightBooking", async (t) => {
96
- const { data: a } = await r.get(
97
- `${d.USER_FLIGHT_BOOKINGS}/${t}`
87
+ i(this, "getFlightBooking", async (t) => {
88
+ const { data: a } = await d.get(
89
+ `${c.USER_FLIGHT_BOOKINGS}/${t}`
98
90
  );
99
91
  return {
100
92
  id: a.data._id,
@@ -149,42 +141,34 @@ class y {
149
141
  destination: l(e.destination)
150
142
  })),
151
143
  availableActions: a.data.available_actions,
152
- airlineInitiatedChanges: l(a.data.airline_initiated_changes) || [],
153
- pointsAsCash: a.data.points_as_cash ? {
154
- authCode: a.data.points_as_cash.auth_code,
155
- points: a.data.points_as_cash.points,
156
- pointsValue: a.data.points_as_cash.points_value,
157
- confirmationCode: a.data.points_as_cash.confirmation_code,
158
- provider: a.data.points_as_cash.provider,
159
- cashValue: a.data.points_as_cash.cash_value
160
- } : void 0
144
+ airlineInitiatedChanges: l(a.data.airline_initiated_changes) || []
161
145
  };
162
146
  });
163
- c(this, "initiateCancelFlightBooking", async (t) => {
164
- const { data: a } = await r.put(
165
- `${d.INITIATE_FLIGHT_CANCEL}/${t}`
147
+ i(this, "initiateCancelFlightBooking", async (t) => {
148
+ const { data: a } = await d.put(
149
+ `${c.INITIATE_FLIGHT_CANCEL}/${t}`
166
150
  );
167
151
  return a.success;
168
152
  });
169
- c(this, "confirmCancelFlightBooking", async (t) => {
170
- const { data: a } = await r.put(
171
- `${d.CONFIRM_FLIGHT_CANCEL}/${t}`
153
+ i(this, "confirmCancelFlightBooking", async (t) => {
154
+ const { data: a } = await d.put(
155
+ `${c.CONFIRM_FLIGHT_CANCEL}/${t}`
172
156
  );
173
157
  return a.success;
174
158
  });
175
- c(this, "cancelHotelBooking", async (t) => {
176
- const { data: a } = await r.post(
177
- `${d.CANCEL_HOTEL_BOOKING}/${t}`
159
+ i(this, "cancelHotelBooking", async (t) => {
160
+ const { data: a } = await d.post(
161
+ `${c.CANCEL_HOTEL_BOOKING}/${t}`
178
162
  );
179
163
  return a.success;
180
164
  });
181
- c(this, "actionAirlineChanges", async ({
165
+ i(this, "actionAirlineChanges", async ({
182
166
  bookingId: t,
183
167
  acceptChanges: a,
184
168
  aicId: o
185
169
  }) => {
186
- const { data: e } = await r.post(
187
- d.ACTION_AIRLINE_CHANGES,
170
+ const { data: e } = await d.post(
171
+ c.ACTION_AIRLINE_CHANGES,
188
172
  {
189
173
  booking_id: t,
190
174
  action_taken: a ? "accepted" : "cancelled",
@@ -193,9 +177,9 @@ class y {
193
177
  );
194
178
  return e.success;
195
179
  });
196
- c(this, "cancelPointsBooking", async (t) => {
197
- const { data: a } = await h.post(
198
- `${d.REFUND_POINTS_BOOKING}`,
180
+ i(this, "cancelPointsBooking", async (t) => {
181
+ const { data: a } = await p.post(
182
+ `${c.REFUND_POINTS_BOOKING}`,
199
183
  {
200
184
  confirmationCode: t.confirmationCode,
201
185
  orderId: t.orderId,
@@ -207,9 +191,18 @@ class y {
207
191
  );
208
192
  return a.success;
209
193
  });
194
+ i(this, "getPointsAsCash", async (t) => {
195
+ const { data: a } = await p.get(
196
+ `${c.BOOKING_POINTS_AS_CASH}/${t}`
197
+ );
198
+ return {
199
+ ...a.data,
200
+ cashValue: a.data.cash
201
+ };
202
+ });
210
203
  }
211
204
  }
212
- const v = new y();
205
+ const N = new h();
213
206
  export {
214
- v as BookingService
207
+ N as BookingService
215
208
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"