@odynn/awayz-core 0.3.5 → 0.3.7

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.
@@ -1,3 +1,4 @@
1
+ import { IAirport } from '@type-op/shared';
1
2
  export interface IBed {
2
3
  }
3
4
  export interface IGuest {
@@ -38,21 +39,6 @@ export interface IHotelBookingDetails {
38
39
  address: IAddress;
39
40
  guests: IGuest[];
40
41
  }
41
- export interface IFlightPassenger {
42
- id: string;
43
- type: string | null;
44
- }
45
- export interface IFlightCarriers {
46
- marketing: string[];
47
- operating: string[];
48
- }
49
- export interface IFlightSlice {
50
- id: string;
51
- origin: string;
52
- destination: string;
53
- carriers: IFlightCarriers;
54
- fareBrandName: string | null;
55
- }
56
42
  export interface IFlightConditionDetails {
57
43
  allowed: boolean;
58
44
  penaltyAmount: string | null;
@@ -62,49 +48,38 @@ export interface IFlightConditions {
62
48
  refundBeforeDeparture: IFlightConditionDetails;
63
49
  changeBeforeDeparture: IFlightConditionDetails;
64
50
  }
65
- export interface IFlightPaymentStatus {
66
- paidAt: string;
67
- priceGuaranteeExpiresAt: string | null;
68
- paymentRequiredBy: string | null;
69
- awaitingPayment: boolean;
70
- }
71
- export interface IFlightDocument {
72
- passengerIds: string[];
73
- uniqueIdentifier: string;
74
- type: string;
75
- }
76
- export interface IFlightService {
77
- id: string;
78
- type: string;
79
- quantity: number;
80
- totalAmount: string;
81
- totalCurrency: string;
82
- }
83
51
  export interface IFlightBookingDetails {
84
52
  id: string;
85
53
  flightOfferId: string;
86
- userId: string;
54
+ baseAmount: number;
55
+ taxAmount: number;
56
+ feeAmount: number;
57
+ extrasAmount: number;
58
+ totalAmount: number;
59
+ currency: string;
87
60
  status: string;
88
- availableActions: string[];
89
- totalCurrency: string;
90
- arrivalDate: string;
91
- baseAmount: string;
92
- extrasAmount: string;
93
- extrasCurrency: string;
94
- baseCurrency: string;
61
+ cancelledAt?: string;
95
62
  conditions: IFlightConditions;
96
- departureDate: string;
97
- passengers: IFlightPassenger[];
98
- slices: IFlightSlice[];
99
- taxAmount: string;
100
- taxCurrency: string;
101
- totalAmount: string;
102
- type: string;
103
- syncedAt: string;
104
- orderId: string;
105
- bookingReference: string;
106
- cancelledAt: string | null;
107
- paymentStatus: IFlightPaymentStatus;
108
- documents: IFlightDocument[];
109
- services: IFlightService[];
63
+ class: string;
64
+ passengers: {
65
+ id: string;
66
+ givenName: string;
67
+ familyName: string;
68
+ type: string;
69
+ title: string;
70
+ email: string;
71
+ gender: string;
72
+ phoneNumber: string;
73
+ }[];
74
+ airlines: string[];
75
+ flights: IFlight[];
76
+ }
77
+ export interface IFlight {
78
+ origin: IAirport;
79
+ destination: IAirport;
80
+ departingAt: string;
81
+ arrivingAt: string;
82
+ numberOfStops: number;
83
+ durationInMinutes: number;
84
+ reference: string;
110
85
  }
@@ -3,3 +3,4 @@ export { clientNoRetryInstance } from './noRetryInstance';
3
3
  export * from './currency/CurrencyService';
4
4
  export * from './wallet/WalletService.types';
5
5
  export * from './trips/TripService.types';
6
+ export * from './bookings/BookingService.types';
@@ -1,51 +1,94 @@
1
- var c = Object.defineProperty;
2
- var r = (o, t, a) => t in o ? c(o, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : o[t] = a;
3
- var n = (o, t, a) => r(o, typeof t != "symbol" ? t + "" : t, a);
1
+ var m = Object.defineProperty;
2
+ var l = (n, a, t) => a in n ? m(n, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[a] = t;
3
+ var o = (n, a, t) => l(n, typeof a != "symbol" ? a + "" : a, t);
4
4
  import "../../arrayExtensions-DlcBOj5a.js";
5
- import { c as e, b as i } from "../../AccountService-D_6U8vP6.js";
5
+ import { c as i, b as d } from "../../AccountService-D_6U8vP6.js";
6
6
  import "react";
7
7
  import { EBookingEndpoints as s } from "../../configs/endpoints.js";
8
- class l {
8
+ const u = (n) => {
9
+ const a = /P((\d+)D)?T((\d+)H)?((\d+)M)?/, t = n.match(a);
10
+ if (t) {
11
+ const r = t[2] ? `${t[2]}d ` : "", e = t[4] ? `${t[4]}h ` : "", c = t[6] ? `${t[6]}m` : "";
12
+ return `${r}${e}${c}`.trim();
13
+ } else
14
+ return n;
15
+ };
16
+ class _ {
9
17
  constructor() {
10
- n(this, "getHotelBooking", async (t) => {
11
- const { data: a } = await e.get(
12
- `${s.USER_HOTEL_BOOKINGS}/${t}`
18
+ o(this, "getHotelBooking", async (a) => {
19
+ const { data: t } = await i.get(
20
+ `${s.USER_HOTEL_BOOKINGS}/${a}`
13
21
  );
14
- return i({
15
- ...a.data,
16
- total_amount: parseFloat(a.data.total_amount),
17
- fee_amount: parseFloat(a.data.fee_amount),
18
- tax_amount: parseFloat(a.data.tax_amount),
19
- base_amount: parseFloat(a.data.base_amount)
22
+ return d({
23
+ ...t.data,
24
+ total_amount: parseFloat(t.data.total_amount),
25
+ fee_amount: parseFloat(t.data.fee_amount),
26
+ tax_amount: parseFloat(t.data.tax_amount),
27
+ base_amount: parseFloat(t.data.base_amount)
20
28
  });
21
29
  });
22
- n(this, "getFlightBooking", async (t) => {
23
- const { data: a } = await e.get(
24
- `${s.USER_FLIGHT_BOOKINGS}/${t}`
30
+ o(this, "getFlightBooking", async (a) => {
31
+ const { data: t } = await i.get(
32
+ `${s.USER_FLIGHT_BOOKINGS}/${a}`
25
33
  );
26
- return i(a.data);
34
+ return {
35
+ id: t.data._id,
36
+ taxAmount: parseFloat(t.data.tax_amount),
37
+ extrasAmount: parseFloat(t.data.extras_amount),
38
+ baseAmount: parseFloat(t.data.base_amount),
39
+ feeAmount: parseFloat(t.data.fee_amount),
40
+ totalAmount: parseFloat(t.data.total_amount),
41
+ currency: t.data.total_currency,
42
+ status: t.data.status,
43
+ conditions: t.data.conditions,
44
+ class: t.data.data.slices[0].fare_brand_name,
45
+ flightOfferId: t.data.flight_offer_id,
46
+ cancelledAt: t.data.cancelled_at,
47
+ airlines: t.data.data.slices[0].segments.map(
48
+ (e) => e.operating_carrier.name
49
+ ),
50
+ passengers: t.data.data.passengers.map((e) => ({
51
+ id: e.id,
52
+ givenName: e.given_ame,
53
+ familyName: e.family_name,
54
+ type: e.type,
55
+ title: e.title,
56
+ email: e.email,
57
+ gender: e.gender,
58
+ phoneNumber: e.phone_number
59
+ })),
60
+ flights: t.data.data.slices.map((e) => ({
61
+ departingAt: e.segments[0].departing_at,
62
+ arrivingAt: e.segments.getLast().arriving_at,
63
+ numberOfStops: e.segments.length - 1,
64
+ reference: t.data.booking_reference,
65
+ durationInMinutes: u(e.duration),
66
+ origin: d(e.origin),
67
+ destination: d(e.destination)
68
+ }))
69
+ };
27
70
  });
28
- n(this, "initiateCancelFlightBooking", async (t) => {
29
- const { data: a } = await e.put(
30
- `${s.INITIATE_FLIGHT_CANCEL}/${t}`
71
+ o(this, "initiateCancelFlightBooking", async (a) => {
72
+ const { data: t } = await i.put(
73
+ `${s.INITIATE_FLIGHT_CANCEL}/${a}`
31
74
  );
32
- return a.success;
75
+ return t.success;
33
76
  });
34
- n(this, "confirmCancelFlightBooking", async (t) => {
35
- const { data: a } = await e.put(
36
- `${s.CONFIRM_FLIGHT_CANCEL}/${t}`
77
+ o(this, "confirmCancelFlightBooking", async (a) => {
78
+ const { data: t } = await i.put(
79
+ `${s.CONFIRM_FLIGHT_CANCEL}/${a}`
37
80
  );
38
- return a.success;
81
+ return t.success;
39
82
  });
40
- n(this, "cancelHotelBooking", async (t) => {
41
- const { data: a } = await e.post(
42
- `${s.CANCEL_HOTEL_BOOKING}/${t}`
83
+ o(this, "cancelHotelBooking", async (a) => {
84
+ const { data: t } = await i.post(
85
+ `${s.CANCEL_HOTEL_BOOKING}/${a}`
43
86
  );
44
- return a.success;
87
+ return t.success;
45
88
  });
46
89
  }
47
90
  }
48
- const B = new l();
91
+ const b = new _();
49
92
  export {
50
- B as BookingService
93
+ b as BookingService
51
94
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"