@odynn/awayz-core 0.2.25 → 0.2.26

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.
Files changed (55) hide show
  1. package/dist/AccountService-BmvBvxkG.js +7720 -0
  2. package/dist/assets/_styles.css +1 -0
  3. package/dist/components/CashValue/CashValue.js +21646 -0
  4. package/dist/components/CashValue/CashValueTypes.js +5 -0
  5. package/dist/components/index.js +6 -0
  6. package/dist/configs/awayzClient.js +16 -0
  7. package/dist/configs/awayzConfig.js +1 -0
  8. package/dist/configs/baseUrl.js +8 -0
  9. package/dist/configs/defaultAwayzConfig.js +11 -0
  10. package/dist/configs/endpoints.js +6 -0
  11. package/dist/context/AwayzContext.js +16 -0
  12. package/dist/hooks/useAwayzAuth/useAwayzAuth.js +176 -0
  13. package/dist/hooks/useAwayzAuth/useAwayzAuth.types.js +1 -0
  14. package/dist/hooks/useAwayzContext.js +13 -0
  15. package/dist/hooks/useSearchLimit.js +25 -0
  16. package/dist/hooks/useWallet.js +57 -0
  17. package/dist/lib/components/CashValue/CashValue.d.ts +9 -0
  18. package/dist/lib/components/CashValue/CashValueTypes.d.ts +28 -0
  19. package/dist/lib/components/index.d.ts +2 -0
  20. package/dist/lib/configs/awayzClient.d.ts +2 -0
  21. package/dist/lib/configs/awayzConfig.d.ts +47 -0
  22. package/dist/lib/configs/baseUrl.d.ts +2 -0
  23. package/dist/lib/configs/defaultAwayzConfig.d.ts +8 -0
  24. package/dist/lib/configs/endpoints.d.ts +32 -0
  25. package/dist/lib/context/AwayzContext.d.ts +17 -0
  26. package/dist/lib/hooks/useAwayzAuth/useAwayzAuth.d.ts +37 -0
  27. package/dist/lib/hooks/useAwayzAuth/useAwayzAuth.types.d.ts +21 -0
  28. package/dist/lib/hooks/useAwayzContext.d.ts +2 -0
  29. package/dist/lib/hooks/useSearchLimit.d.ts +10 -0
  30. package/dist/lib/hooks/useWallet.d.ts +15 -0
  31. package/dist/lib/main.d.ts +11 -0
  32. package/dist/lib/providers/AwayzProvider.d.ts +12 -0
  33. package/dist/lib/services/account/AccountService.d.ts +93 -0
  34. package/dist/lib/services/account/AccountServices.types.d.ts +174 -0
  35. package/dist/lib/services/currency/CurrencyService.d.ts +15 -0
  36. package/dist/lib/services/currency/CurrencyService.types.d.ts +18 -0
  37. package/dist/lib/services/instance.d.ts +2 -0
  38. package/dist/lib/services/wallet/WalletService.d.ts +9 -0
  39. package/dist/lib/services/wallet/WalletService.types.d.ts +61 -0
  40. package/dist/lib/types/EAuthFlow.d.ts +9 -0
  41. package/dist/lib/types/auth.d.ts +22 -0
  42. package/dist/lib/types/index.d.ts +1 -0
  43. package/dist/main.js +25 -0
  44. package/dist/providers/AwayzProvider.js +40 -0
  45. package/dist/services/account/AccountService.js +7 -0
  46. package/dist/services/account/AccountServices.types.js +4 -0
  47. package/dist/services/currency/CurrencyService.js +66 -0
  48. package/dist/services/currency/CurrencyService.types.js +1 -0
  49. package/dist/services/instance.js +9 -0
  50. package/dist/services/wallet/WalletService.js +84 -0
  51. package/dist/services/wallet/WalletService.types.js +1 -0
  52. package/dist/types/EAuthFlow.js +4 -0
  53. package/dist/types/auth.js +1 -0
  54. package/dist/types/index.js +4 -0
  55. package/package.json +4 -2
@@ -0,0 +1,93 @@
1
+ import { IAuthData, IRegion, IResendVerificationEmailParams, ISearchLimitResponse, IUser } from './AccountServices.types';
2
+ import { TServiceResponse } from '@type-op/shared';
3
+ import { ISignInParams, ISignUpParams } from '../../types/auth';
4
+ export interface IClientUser {
5
+ _id: string;
6
+ email_address: string;
7
+ user_region: string;
8
+ client_id: string;
9
+ client_user_id: string;
10
+ __v: number;
11
+ }
12
+ /**
13
+ * AccountService provides methods for user authentication and account management.
14
+ */
15
+ declare class _AccountService {
16
+ /**
17
+ * Logs in a user with the provided email and password.
18
+ *
19
+ * @param params - The sign-in parameters containing email and password.
20
+ * @returns A promise that resolves to a service response containing authentication data.
21
+ */
22
+ login: (params: ISignInParams) => Promise<{
23
+ success: boolean;
24
+ data: IAuthData;
25
+ message?: undefined;
26
+ } | {
27
+ success: boolean;
28
+ message: any;
29
+ data?: undefined;
30
+ }>;
31
+ /**
32
+ * Registers a new user with the provided email, password, and region.
33
+ *
34
+ * @param params - The sign-up parameters containing email, password, and region.
35
+ * @returns A promise that resolves to a service response containing authentication data.
36
+ */
37
+ signUp: (params: ISignUpParams) => Promise<{
38
+ success: boolean;
39
+ data: IAuthData;
40
+ message?: undefined;
41
+ } | {
42
+ success: boolean;
43
+ message: any;
44
+ data?: undefined;
45
+ }>;
46
+ resendVerificationEmail: (params: IResendVerificationEmailParams) => Promise<any>;
47
+ /**
48
+ * Authenticates a user using an ID token.
49
+ *
50
+ * @param idToken - The ID token to authenticate with.
51
+ * @returns A promise that resolves to a service response containing authentication data.
52
+ */
53
+ authenticateWithToken: (idToken: string) => Promise<TServiceResponse<IAuthData>>;
54
+ /**
55
+ * If token is available in local storage, check if it is valid and return user details
56
+ *
57
+ * @returns A promise that resolves to a service response containing the user details.
58
+ */
59
+ checkUser: () => Promise<TServiceResponse<IUser>>;
60
+ /**
61
+ * @description In the case of a 401 error, the refresh token is used to get a new access token and user details, by exchanging the
62
+ * refresh token for a new id_token and in turn exchanging that for a new awayz token
63
+ *
64
+ * @param refreshToken - The refresh token
65
+ */
66
+ refreshEmbedToken: (refreshToken: string) => Promise<TServiceResponse<{
67
+ user: IUser;
68
+ token: string;
69
+ id_token: string;
70
+ }>>;
71
+ /**
72
+ * @description In the case of a 401 error, the refresh token is used to get a new access token and user details
73
+ *
74
+ * @param refreshToken - The refresh token
75
+ */
76
+ refreshToken: (refreshToken: string) => Promise<TServiceResponse<{
77
+ token: string;
78
+ }>>;
79
+ /**
80
+ * Retrieves the request limit for the authenticated user.
81
+ *
82
+ * @returns A promise that resolves to a service response containing the request limit data.
83
+ */
84
+ getRequestLimit: () => Promise<TServiceResponse<ISearchLimitResponse[]>>;
85
+ /**
86
+ * Retrieves the regions available for user registration.
87
+ *
88
+ * @returns A promise that resolves to a service response containing the available regions.
89
+ */
90
+ getRegions: () => Promise<IRegion[]>;
91
+ }
92
+ export declare const AccountService: _AccountService;
93
+ export {};
@@ -0,0 +1,174 @@
1
+ import { ESearchLimitType } from '@type-op/shared';
2
+ /**
3
+ * @description - the awayz user after being mapped from backend response to desired shape
4
+ */
5
+ export interface IUser {
6
+ id: string;
7
+ emailAddress: string;
8
+ emailVerified: boolean;
9
+ clientId: string;
10
+ clientUserId: string;
11
+ userRegion: IRegion;
12
+ account: IAccount;
13
+ }
14
+ export interface IAccount {
15
+ userId: string;
16
+ subscriptionId: string;
17
+ subscription: ISubscription;
18
+ expiresAt: string;
19
+ status: string;
20
+ stripeDetails: IStripeDetails;
21
+ id: string;
22
+ }
23
+ interface IStripeDetails {
24
+ subscriptionId: string;
25
+ priceId: string;
26
+ trialPeriod: number;
27
+ }
28
+ export interface ISubscription {
29
+ tier: string;
30
+ flightSearchLimit: number;
31
+ hotelSearchLimit: number;
32
+ hotelAvailabilityAlertLimit: number;
33
+ isPaid: boolean;
34
+ stripeProductId: string;
35
+ isDeleted: boolean;
36
+ features: IFeature[];
37
+ id: string;
38
+ }
39
+ interface IFeature {
40
+ key?: string;
41
+ text: string;
42
+ included: boolean;
43
+ }
44
+ export interface ISearchLimit {
45
+ isAdmin: boolean;
46
+ numberOfCalls: number;
47
+ remainingCalls: number;
48
+ searchLimit: number;
49
+ searchType: string;
50
+ subscription: string;
51
+ }
52
+ export interface IResetPasswordParams {
53
+ email: string;
54
+ password: string;
55
+ confirm_password: string;
56
+ code: string;
57
+ }
58
+ export interface IForgotPasswordResponse {
59
+ success: boolean;
60
+ message: string;
61
+ token: string;
62
+ }
63
+ export interface ISignInResponse {
64
+ success: boolean;
65
+ message: string;
66
+ data: IAuthDataResponse | null;
67
+ }
68
+ export interface IAuthDataResponse {
69
+ user: IUserResponse;
70
+ accessToken?: string;
71
+ refreshToken?: string;
72
+ }
73
+ export interface ISignUpResponse {
74
+ user: IUserResponse;
75
+ tokens: {
76
+ accessToken?: string;
77
+ refreshToken?: string;
78
+ };
79
+ }
80
+ export interface IAuthData {
81
+ user: IUser;
82
+ token?: string;
83
+ refreshToken?: string;
84
+ }
85
+ export interface IResendVerificationEmailParams {
86
+ email: string;
87
+ successUrl: string;
88
+ cancelUrl: string;
89
+ }
90
+ export interface IUserResponse {
91
+ email_address: string;
92
+ user_region: string;
93
+ client_id: string;
94
+ email_verified: boolean;
95
+ _id: string;
96
+ }
97
+ export interface ISpendingBreakdown {
98
+ Internet: number;
99
+ Restaurants: number;
100
+ Airfare: number;
101
+ nonAirTravel: number;
102
+ Gas: number;
103
+ Other: number;
104
+ Groceries: number;
105
+ Rent: number;
106
+ }
107
+ export interface IAwayzAccess {
108
+ id: string;
109
+ details: IDetails;
110
+ customer_id: string;
111
+ cancel_at_period_end: boolean;
112
+ active: boolean;
113
+ awayz_gold: boolean;
114
+ awayz_premium: boolean;
115
+ awayz_enum: string;
116
+ }
117
+ export interface IDetails {
118
+ si_id: string;
119
+ current_period_end: number;
120
+ current_period_start: number;
121
+ interval: string;
122
+ interval_count: number;
123
+ amount: number;
124
+ price_id: string;
125
+ product_id: string;
126
+ discount_amount: number;
127
+ original_amount: any;
128
+ }
129
+ export interface ICheckUserResponse {
130
+ success: boolean;
131
+ userVeri: IUser | null;
132
+ userData: any;
133
+ message?: string;
134
+ }
135
+ export interface IRegion {
136
+ id: string;
137
+ name: string;
138
+ code: string;
139
+ currency: string;
140
+ flagIcon: string;
141
+ isActive: boolean;
142
+ }
143
+ export interface IRegionResponse {
144
+ _id: string;
145
+ name: string;
146
+ code: string;
147
+ currency: string;
148
+ flag_icon: string;
149
+ is_active: boolean;
150
+ }
151
+ export declare enum ESource {
152
+ CODE = "code",
153
+ OFFER = "offer"
154
+ }
155
+ export interface IAccountResponse {
156
+ email_address: string;
157
+ password: string;
158
+ account_type: string;
159
+ price_id: string;
160
+ success_url: string;
161
+ cancel_url: string;
162
+ coupon?: string;
163
+ user_region: string;
164
+ user_source_id?: string;
165
+ }
166
+ export interface ISearchLimitResponse {
167
+ search_type: ESearchLimitType;
168
+ subscription: string;
169
+ is_admin: boolean;
170
+ search_limit: number;
171
+ number_of_calls: number;
172
+ remaining_calls: number;
173
+ }
174
+ export {};
@@ -0,0 +1,15 @@
1
+ import { IConvertCurrencyArgs } from './CurrencyService.types';
2
+ declare class _CurrencyService {
3
+ convertCurrency: ({ baseCurrency }: IConvertCurrencyArgs) => Promise<number>;
4
+ /**
5
+ * Convert from base currency to target currency for the amount provided
6
+ * @param param0 IConvertCurrencyArgs
7
+ * @param baseCurrency the base currency to convert from
8
+ * @param targetCurrency the target currency to convert to
9
+ * @parm amount the amount to be converted from the base to the target currency
10
+ * @returns the converted amount
11
+ */
12
+ convertToCurrency: ({ baseCurrency, targetCurrency, amount }: IConvertCurrencyArgs) => Promise<number>;
13
+ }
14
+ export declare const CurrencyService: _CurrencyService;
15
+ export {};
@@ -0,0 +1,18 @@
1
+ export interface IConvertCurrencyArgs {
2
+ baseCurrency: string;
3
+ targetCurrency?: string;
4
+ amount?: number;
5
+ }
6
+ export interface IConvertCurrencyResult {
7
+ result: string;
8
+ documentation: string;
9
+ terms_of_use: string;
10
+ time_last_update_unix: number;
11
+ time_last_update_utc: string;
12
+ time_next_update_unix: number;
13
+ time_next_update_utc: string;
14
+ base_code: string;
15
+ target_code: string;
16
+ conversion_rate: number;
17
+ conversion_result: number;
18
+ }
@@ -0,0 +1,2 @@
1
+ export declare const instance: import('axios').AxiosInstance;
2
+ export declare const clientInstance: import('axios').AxiosInstance;
@@ -0,0 +1,9 @@
1
+ import { IBank, ICard, ILoyaltyProgram } from './WalletService.types';
2
+ declare class _WalletService {
3
+ getAwards: () => Promise<ILoyaltyProgram[]>;
4
+ setAwardPoints: (main_program: string, amount: number) => Promise<any>;
5
+ getBanks: () => Promise<IBank[]>;
6
+ getCards: () => Promise<ICard[]>;
7
+ }
8
+ export declare const WalletService: _WalletService;
9
+ export {};
@@ -0,0 +1,61 @@
1
+ import { ERewardProgramCategory } from '@type-op/shared';
2
+ export interface IStatusLevels {
3
+ level1: string;
4
+ level2: string;
5
+ level3: string;
6
+ level4: string;
7
+ level5: string;
8
+ }
9
+ export interface ILoyaltyProgram {
10
+ id: string;
11
+ mainProgram: string;
12
+ category: ERewardProgramCategory;
13
+ statusLevels: IStatusLevels;
14
+ displayProgram: string;
15
+ awayzActive: string[];
16
+ modified: string;
17
+ colour: string;
18
+ programLogo: string;
19
+ url: string;
20
+ faredropUrl: string;
21
+ categoryLogo: string;
22
+ alternateRegions: string[];
23
+ region: string;
24
+ totalAccumulatedPoints: number;
25
+ }
26
+ export interface IBank {
27
+ id: string;
28
+ created: string;
29
+ name: string;
30
+ code: string;
31
+ mxCode: string;
32
+ rank: number;
33
+ modified: string;
34
+ region: string;
35
+ alternateRegions: string[];
36
+ }
37
+ export interface ICard {
38
+ id: string;
39
+ name: string;
40
+ signupBonus: number;
41
+ cashBonus: number;
42
+ minimumSpend: number;
43
+ daysToSpend: number;
44
+ annualFee: number;
45
+ annualFeeWaived: boolean;
46
+ cashPerks: number;
47
+ bank: {
48
+ name: string;
49
+ };
50
+ rewardsCurrency: string;
51
+ bisCard: boolean;
52
+ chargeCard: boolean;
53
+ cardFamily: number;
54
+ websiteUrl: string;
55
+ network: {
56
+ name: string;
57
+ };
58
+ colour: string;
59
+ region: string;
60
+ alternateRegions: string[];
61
+ }
@@ -0,0 +1,9 @@
1
+ export declare enum EAuthFlow {
2
+ STANDARD = "standard",
3
+ /** Pass the token in using window.postmessage */
4
+ POST_MESSAGE = "postMessage",
5
+ /** Not yet supported */
6
+ OAUTH = "oauth",
7
+ /** Pass the token as a query param */
8
+ QUERY = "query"
9
+ }
@@ -0,0 +1,22 @@
1
+ import { IAuthData } from '../services/account/AccountServices.types';
2
+ export interface ISignUpParams {
3
+ email: string;
4
+ password: string;
5
+ region: string;
6
+ successUrl?: string;
7
+ cancelUrl?: string;
8
+ priceId: string;
9
+ }
10
+ export interface ISignInParams {
11
+ email: string;
12
+ password: string;
13
+ }
14
+ export type TAuthResponse = {
15
+ success: boolean;
16
+ data: IAuthData;
17
+ message?: undefined;
18
+ } | {
19
+ success: boolean;
20
+ message: any;
21
+ data?: undefined;
22
+ };
@@ -0,0 +1 @@
1
+ export * from './EAuthFlow';
package/dist/main.js ADDED
@@ -0,0 +1,25 @@
1
+ import { AwayzProvider as e } from "./providers/AwayzProvider.js";
2
+ import { useAwayzContext as a } from "./hooks/useAwayzContext.js";
3
+ import { useSearchLimit as p } from "./hooks/useSearchLimit.js";
4
+ import { useWallet as f } from "./hooks/useWallet.js";
5
+ import { EAuthFlow as s } from "./types/EAuthFlow.js";
6
+ import { c as l, i as c } from "./AccountService-BmvBvxkG.js";
7
+ import { awayzClient as w } from "./configs/awayzClient.js";
8
+ import { CashValue as C } from "./components/CashValue/CashValue.js";
9
+ import { EToolTipPosition as z } from "./components/CashValue/CashValueTypes.js";
10
+ import { CurrencyService as v } from "./services/currency/CurrencyService.js";
11
+ import { getBaseUrl as P } from "./configs/baseUrl.js";
12
+ export {
13
+ e as AwayzProvider,
14
+ C as CashValue,
15
+ v as CurrencyService,
16
+ s as EAuthFlow,
17
+ z as EToolTipPosition,
18
+ w as awayzClient,
19
+ l as clientInstance,
20
+ P as getBaseUrl,
21
+ c as instance,
22
+ a as useAwayzContext,
23
+ p as useSearchLimit,
24
+ f as useWallet
25
+ };
@@ -0,0 +1,40 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { useEffect as i } from "react";
3
+ import { AwayzContext as m } from "../context/AwayzContext.js";
4
+ import { E as e } from "../AccountService-BmvBvxkG.js";
5
+ import { useAwayzAuth as s } from "../hooks/useAwayzAuth/useAwayzAuth.js";
6
+ import { setBaseUrl as l } from "../configs/baseUrl.js";
7
+ import { QueryClientProvider as u } from "@tanstack/react-query";
8
+ import { awayzClient as d } from "../configs/awayzClient.js";
9
+ import '../assets/_styles.css';/* empty css */
10
+ import { defaultAwayzConfig as n } from "../configs/defaultAwayzConfig.js";
11
+ const C = ({ children: o, config: r }) => {
12
+ const a = s({
13
+ authFlow: r.authFlow,
14
+ onSuccess: r.onAuthSuccess,
15
+ onError: r.onAuthFailure,
16
+ trustedOrigins: r.trustedOrigins
17
+ });
18
+ return i(() => {
19
+ if (!r.clientId) {
20
+ console.error("You need to provide a client ID to the AwayzProvider");
21
+ return;
22
+ }
23
+ localStorage.setItem(e.CLIENT_ID, r.clientId), localStorage.setItem(e.AUTH_FLOW, r.authFlow), l(r.testMode ?? !1);
24
+ }, [r]), /* @__PURE__ */ t(u, { client: d, children: /* @__PURE__ */ t(
25
+ m.Provider,
26
+ {
27
+ value: {
28
+ ...a,
29
+ config: {
30
+ ...n,
31
+ ...r
32
+ }
33
+ },
34
+ children: o
35
+ }
36
+ ) });
37
+ };
38
+ export {
39
+ C as AwayzProvider
40
+ };
@@ -0,0 +1,7 @@
1
+ import { e as m } from "../../AccountService-BmvBvxkG.js";
2
+ import "react";
3
+ import "../../configs/endpoints.js";
4
+ import "../../configs/awayzClient.js";
5
+ export {
6
+ m as AccountService
7
+ };
@@ -0,0 +1,4 @@
1
+ var e = /* @__PURE__ */ ((r) => (r.CODE = "code", r.OFFER = "offer", r))(e || {});
2
+ export {
3
+ e as ESource
4
+ };
@@ -0,0 +1,66 @@
1
+ import '../../assets/_styles.css';var i = Object.defineProperty;
2
+ var y = (t, r, e) => r in t ? i(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
3
+ var o = (t, r, e) => y(t, typeof r != "symbol" ? r + "" : r, e);
4
+ import { e as p, a as C, c as a } from "../../AccountService-BmvBvxkG.js";
5
+ import "react";
6
+ import { ECurrencyEndpoints as s } from "../../configs/endpoints.js";
7
+ import "react/jsx-runtime";
8
+ import "../../context/AwayzContext.js";
9
+ import { awayzClient as m } from "../../configs/awayzClient.js";
10
+ import "@tanstack/react-query";
11
+ /* empty css */
12
+ class E {
13
+ constructor() {
14
+ o(this, "convertCurrency", async ({
15
+ baseCurrency: r
16
+ }) => {
17
+ try {
18
+ const { success: e, data: n } = await m.ensureQueryData({
19
+ queryKey: [C.CHECK_USER],
20
+ queryFn: p.checkUser
21
+ });
22
+ if (!e)
23
+ throw new Error("Failed to fetch user data");
24
+ const { userRegion: c } = n, { data: u } = await a.post(s.CURRENCY_CONVERSION, {
25
+ target_currency: c.currency,
26
+ base_currency: r
27
+ });
28
+ if (e)
29
+ return u.data.conversion_rate;
30
+ } catch (e) {
31
+ console.error(e);
32
+ }
33
+ return 0;
34
+ });
35
+ /**
36
+ * Convert from base currency to target currency for the amount provided
37
+ * @param param0 IConvertCurrencyArgs
38
+ * @param baseCurrency the base currency to convert from
39
+ * @param targetCurrency the target currency to convert to
40
+ * @parm amount the amount to be converted from the base to the target currency
41
+ * @returns the converted amount
42
+ */
43
+ o(this, "convertToCurrency", async ({
44
+ baseCurrency: r,
45
+ targetCurrency: e,
46
+ amount: n
47
+ }) => {
48
+ try {
49
+ const { data: c } = await a.post(s.CURRENCY_CONVERSION, {
50
+ target_currency: e,
51
+ base_currency: r,
52
+ amount: n
53
+ });
54
+ if (c.success)
55
+ return c.data.conversion_result;
56
+ } catch (c) {
57
+ console.error(c);
58
+ }
59
+ return 0;
60
+ });
61
+ }
62
+ }
63
+ const h = new E();
64
+ export {
65
+ h as CurrencyService
66
+ };
@@ -0,0 +1,9 @@
1
+ import { c as p, i as a } from "../AccountService-BmvBvxkG.js";
2
+ import "react";
3
+ import "../configs/endpoints.js";
4
+ import "../configs/baseUrl.js";
5
+ import "../types/EAuthFlow.js";
6
+ export {
7
+ p as clientInstance,
8
+ a as instance
9
+ };
@@ -0,0 +1,84 @@
1
+ import '../../assets/_styles.css';var y = Object.defineProperty;
2
+ var w = (e, a, t) => a in e ? y(e, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[a] = t;
3
+ var o = (e, a, t) => w(e, typeof a != "symbol" ? a + "" : a, t);
4
+ import { b as s, c as i, d as n } from "../../AccountService-BmvBvxkG.js";
5
+ import "react";
6
+ import "react/jsx-runtime";
7
+ import "../../context/AwayzContext.js";
8
+ import { EWalletEndpoints as m } from "../../configs/endpoints.js";
9
+ import "../../configs/awayzClient.js";
10
+ import "@tanstack/react-query";
11
+ /* empty css */
12
+ class E {
13
+ constructor() {
14
+ o(this, "getAwards", async () => {
15
+ var a, t, c;
16
+ try {
17
+ const l = [
18
+ s.HOTEL,
19
+ s.BANK,
20
+ s.AIRLINE
21
+ ], [
22
+ { data: d },
23
+ { data: p },
24
+ { data: g }
25
+ ] = await Promise.all(
26
+ l.map(
27
+ (r) => i.get(
28
+ m.USER_AWARDS,
29
+ {
30
+ params: { category: r }
31
+ }
32
+ )
33
+ )
34
+ ), u = ((a = d.data) == null ? void 0 : a.map(
35
+ (r) => n({
36
+ ...r,
37
+ ctegory: s.HOTEL
38
+ })
39
+ )) ?? [], A = ((t = p.data) == null ? void 0 : t.map(
40
+ (r) => n({
41
+ ...r,
42
+ ctegory: s.BANK
43
+ })
44
+ )) ?? [], R = ((c = g.data) == null ? void 0 : c.map(
45
+ (r) => n({
46
+ ...r,
47
+ ctegory: s.AIRLINE
48
+ })
49
+ )) ?? [];
50
+ return [
51
+ ...u,
52
+ ...A,
53
+ ...R
54
+ ];
55
+ } catch (l) {
56
+ console.error(l);
57
+ }
58
+ return [];
59
+ });
60
+ o(this, "setAwardPoints", async (a, t) => {
61
+ const { data: c } = await i.put(m.USER_AWARDS, {
62
+ main_program: a,
63
+ amount: t
64
+ });
65
+ return c;
66
+ });
67
+ o(this, "getBanks", async () => {
68
+ const { data: a } = await i.get(
69
+ m.BANKS
70
+ );
71
+ return a.success ? a.data.map((t) => n(t)) : [];
72
+ });
73
+ o(this, "getCards", async () => {
74
+ const { data: a } = await i.get(
75
+ m.CARDS
76
+ );
77
+ return a.success ? a.data.map((t) => n(t)) : [];
78
+ });
79
+ }
80
+ }
81
+ const b = new E();
82
+ export {
83
+ b as WalletService
84
+ };
@@ -0,0 +1,4 @@
1
+ var a = /* @__PURE__ */ ((r) => (r.STANDARD = "standard", r.POST_MESSAGE = "postMessage", r.OAUTH = "oauth", r.QUERY = "query", r))(a || {});
2
+ export {
3
+ a as EAuthFlow
4
+ };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,4 @@
1
+ import { EAuthFlow as t } from "./EAuthFlow.js";
2
+ export {
3
+ t as EAuthFlow
4
+ };