@liquidcommerce/cloud-sdk 1.2.0 → 1.4.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.
Files changed (36) hide show
  1. package/README.md +384 -93
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.esm.js +1 -1
  4. package/dist/liquidcommerce-cloud-sdk.ssr.js +1 -1
  5. package/dist/types/constants/core.constant.d.ts +8 -0
  6. package/dist/types/core/cart-helper.service.d.ts +1 -1
  7. package/dist/types/core/catalog-helper.service.d.ts +24 -4
  8. package/dist/types/core/checkout-helper.service.d.ts +23 -8
  9. package/dist/types/core/location-helper.service.d.ts +4 -3
  10. package/dist/types/core/payment-provider.service.d.ts +56 -8
  11. package/dist/types/core/singleton.service.d.ts +9 -10
  12. package/dist/types/{enums.d.ts → enums/enums.d.ts} +62 -92
  13. package/dist/types/enums/index.d.ts +2 -0
  14. package/dist/types/enums/taxonomy.d.ts +285 -0
  15. package/dist/types/index.d.ts +2 -0
  16. package/dist/types/interfaces/address.interface.d.ts +86 -1
  17. package/dist/types/interfaces/cart.interface.d.ts +28 -10
  18. package/dist/types/interfaces/catalog.interface.d.ts +268 -8
  19. package/dist/types/interfaces/checkout.interface.d.ts +265 -50
  20. package/dist/types/interfaces/index.d.ts +8 -0
  21. package/dist/types/interfaces/liquid-commerce-client.interface.d.ts +199 -9
  22. package/dist/types/interfaces/payment.interface.d.ts +88 -9
  23. package/dist/types/interfaces/retailer.interface.d.ts +121 -0
  24. package/dist/types/interfaces/user.interface.d.ts +145 -9
  25. package/dist/types/liquid-commerce-client.d.ts +3 -173
  26. package/dist/types/services/address.service.d.ts +2 -18
  27. package/dist/types/services/cart.service.d.ts +1 -1
  28. package/dist/types/services/catalog.service.d.ts +1 -12
  29. package/dist/types/services/checkout.service.d.ts +1 -1
  30. package/dist/types/services/index.d.ts +5 -0
  31. package/dist/types/services/payment.service.d.ts +24 -1
  32. package/dist/types/services/user.service.d.ts +83 -1
  33. package/dist/types/types.d.ts +11 -5
  34. package/package.json +105 -105
  35. package/umd/liquidcommerce-cloud-sdk.min.js +1 -1
  36. package/dist/types/interfaces/catalog.service.interface.d.ts +0 -65
@@ -1,53 +1,189 @@
1
1
  import type { ENUM_ADDRESS_TYPE } from '../enums';
2
2
  import type { ICoreParams } from '../types';
3
+ /**
4
+ * Represents a user session with key and secret used for authentication.
5
+ */
3
6
  export interface IUserSession {
4
7
  key: string | null;
5
8
  secret: string | null;
6
9
  createdAt: Date;
7
10
  }
8
- export interface IUserAddress {
9
- id: string;
11
+ /**
12
+ * Represents the basic structure of a user's address.
13
+ *
14
+ * @interface IUserAddressBase
15
+ *
16
+ * @property {string} placesId - The unique identifier for the place.
17
+ * @property {string} one - The primary street address or neighborhood.
18
+ * @property {string} two - The secondary address information, such as apartment or suite number.
19
+ * @property {string} city - The name of the city.
20
+ * @property {string} state - The name of the state or region.
21
+ * @property {string} zip - The postal code.
22
+ * @property {string} country - The name of the country.
23
+ * @property {number} lat - The latitude coordinate of the address.
24
+ * @property {number} long - The longitude coordinate of the address.
25
+ */
26
+ export interface IUserAddressBase {
27
+ placesId: string;
10
28
  one: string;
11
- two?: string | null;
29
+ two: string;
12
30
  city: string;
13
31
  state: string;
14
32
  zip: string;
15
33
  country: string;
34
+ lat: number;
35
+ long: number;
36
+ }
37
+ /**
38
+ * IUserAddress interface represents a user's address details.
39
+ * It extends the IUserAddressBase interface, adding additional properties for
40
+ * unique identification, timestamps, and default status.
41
+ *
42
+ * @interface IUserAddress
43
+ * @extends {IUserAddressBase}
44
+ *
45
+ * @property {string} id - Unique identifier for the user's address.
46
+ * @property {Date} createdAt - Timestamp indicating when the address was created.
47
+ * @property {Date} updatedAt - Timestamp indicating the last update to the address.
48
+ * @property {boolean} [isDefault] - Optional flag indicating if this is the default address.
49
+ */
50
+ export interface IUserAddress extends IUserAddressBase {
51
+ id: string;
16
52
  createdAt: Date;
17
53
  updatedAt: Date;
18
54
  isDefault?: boolean;
19
55
  }
56
+ /**
57
+ * Interface representing a saved card.
58
+ *
59
+ * @interface ISavedCard
60
+ */
61
+ export interface ISavedCard {
62
+ brand: string | null;
63
+ country: string | null;
64
+ expMonth: number | null;
65
+ expYear: number | null;
66
+ last4: string | null;
67
+ funding: string | null;
68
+ }
69
+ /**
70
+ * Represents a user's payment method.
71
+ *
72
+ * @interface IUserPayment
73
+ * @property {string} id - The unique identifier for the payment method.
74
+ * @property {string} type - The type of the payment method (e.g., credit card, PayPal).
75
+ * @property {boolean} isDefault - Indicates whether this payment method is the default one.
76
+ * @property {ISavedCard} [card] - The saved card details if the payment method is a card.
77
+ * @property {Date} createdAt - The date when the payment method was added.
78
+ */
79
+ export interface IUserPayment {
80
+ id: string;
81
+ type: string;
82
+ isDefault: boolean;
83
+ card?: ISavedCard;
84
+ createdAt: Date;
85
+ }
86
+ /**
87
+ * The IUser interface defines the structure for user objects within the application.
88
+ */
20
89
  export interface IUser {
21
90
  id: string;
22
91
  email: string;
23
92
  firstName: string | null;
24
93
  lastName: string | null;
25
94
  phone: string | null;
95
+ company: string | null;
96
+ profileImage: string | null;
26
97
  birthDate: string | null;
27
98
  createdAt: Date;
28
99
  updatedAt: Date;
29
100
  addresses: IUserAddress[];
101
+ savedPayments: IUserPayment[];
30
102
  session: IUserSession;
31
103
  }
104
+ /**
105
+ * Represents a basic user excluding the session information.
106
+ *
107
+ * This type is useful when user session details are not required
108
+ * or need to be omitted for certain operations, such as basic
109
+ * user management tasks.
110
+ *
111
+ * It extends the IUser interface but removes the 'session' property.
112
+ *
113
+ * Typically used in contexts where minimal user information is
114
+ * sufficient, focusing on non-session related attributes.
115
+ */
116
+ export type BaseUser = Omit<IUser, 'session'>;
117
+ /**
118
+ * Interface representing the parameters for a user session.
119
+ */
32
120
  export interface IUserSessionParams extends ICoreParams {
33
121
  id?: string;
34
122
  email?: string;
35
123
  firstName?: string | null;
36
124
  lastName?: string | null;
37
125
  phone?: string | null;
126
+ company?: string | null;
127
+ profileImage?: string | null;
38
128
  birthDate?: string | null;
39
129
  }
130
+ /**
131
+ * Interface representing the response from a purge operation.
132
+ */
40
133
  export interface IPurgeResponse {
41
134
  deleted: boolean;
42
135
  message: string;
43
136
  }
137
+ /**
138
+ * Interface representing the parameters required for user address operations.
139
+ * Extends the core parameters from ICoreParams.
140
+ */
44
141
  export interface IUserAddressParams extends ICoreParams {
45
142
  customerId: string;
46
- one: string;
47
- two?: string | null;
48
- city: string;
49
- state: string;
50
- zip: string;
51
- isDefault?: boolean;
143
+ placesId?: string;
144
+ one?: string;
145
+ two?: string;
146
+ city?: string;
147
+ state?: string;
148
+ zip?: string;
149
+ country?: string;
150
+ lat?: number;
151
+ long?: number;
52
152
  type: ENUM_ADDRESS_TYPE;
153
+ isDefault?: boolean;
154
+ }
155
+ /**
156
+ * Interface representing the parameters required for user payment operations.
157
+ *
158
+ * This interface extends the core parameters interface (`ICoreParams`) and includes
159
+ * specific properties necessary for processing a user payment.
160
+ *
161
+ * Properties:
162
+ * - `customerId`: A string representing the unique identifier of the customer making the payment.
163
+ * - `paymentMethodId`: A string representing the unique identifier of the payment method to be used.
164
+ */
165
+ export interface IUserPaymentParams extends ICoreParams {
166
+ customerId: string;
167
+ paymentMethodId: string;
168
+ }
169
+ /**
170
+ * Interface representing the parameters required to add a user payment.
171
+ *
172
+ * Extends the IUserPaymentParams interface to inherit the basic payment parameters.
173
+ *
174
+ * @property isDefault - Optional boolean indicating if the payment method should be set as default.
175
+ */
176
+ export interface IUserPaymentAddParams extends IUserPaymentParams {
177
+ isDefault?: boolean;
178
+ }
179
+ /**
180
+ * IUserPaymentUpdateParams is an interface extending IUserPaymentParams,
181
+ * representing the parameters required to update user payment information.
182
+ *
183
+ * @extends IUserPaymentParams
184
+ *
185
+ * @property {boolean} isDefault - Indicates whether the payment method is the default one.
186
+ */
187
+ export interface IUserPaymentUpdateParams extends IUserPaymentParams {
188
+ isDefault: boolean;
53
189
  }
@@ -1,173 +1,5 @@
1
- import { LIQUID_COMMERCE_ENV } from './enums';
2
- import type { ICart, ICartUpdateParams } from './interfaces/cart.interface';
3
- import type { ICatalog, ICatalogParams } from './interfaces/catalog.service.interface';
4
- import type { ICheckoutCompleteParams, ICheckoutCompleteResponse, ICheckoutPrepareParams, ICheckoutPrepareResponse } from './interfaces/checkout.interface';
5
- import type { IAddressMethod, ICartMethod, ICatalogMethod, ICheckoutMethod, ILiquidCommerceClient, IPaymentMethod, IUserMethod } from './interfaces/liquid-commerce-client.interface';
6
- import type { ILiquidPaymentConfig, ILiquidPaymentToken, IPaymentElementEventMap } from './interfaces/payment.interface';
7
- import type { IPurgeResponse, IUser, IUserAddress, IUserAddressParams, IUserSessionParams } from './interfaces/user.interface';
8
- import type { IAddressAutocompleteParams, IAddressAutocompleteResult, IAddressDetailsParams, IAddressDetailsResult } from './services/address.service';
9
- import type { IAvailabilityParams, IAvailabilityResponse } from './services/catalog.service';
10
- import type { IApiResponseWithData, IApiResponseWithoutData, ILiquidCommerceConfig } from './types';
11
- /**
12
- * The LiquidCommerceClient class is a client for interacting with the LiquidCommerce Cloud APIs.
13
- * This client encapsulates the logic for working with various services, including addresses, catalog products,
14
- * carts, users, payments, checkouts, and orders.
15
- *
16
- * The client handles authentication, service initialization, and ensures secure interaction with the
17
- * LiquidCommerce Cloud API by managing token expiration and re-authentication automatically.
18
- *
19
- * @class
20
- * @implements {ILiquidCommerceClient}
21
- */
22
- declare class LiquidCommerceClient implements ILiquidCommerceClient {
23
- private readonly authenticatedClient;
24
- private addressService;
25
- private catalogService;
26
- private cartService;
27
- private userService;
28
- private paymentService;
29
- private checkoutService;
30
- private config;
31
- private singletonManager;
32
- /**
33
- * Creates an instance of LiquidCommerceClient.
34
- *
35
- * @constructor
36
- * @param {string} apiKey - The API key used for authenticating with the LiquidCommerce Cloud API.
37
- * @param {ILiquidCommerceConfig} config - Configuration options including environment settings, base URLs, and other preferences.
38
- */
39
- constructor(apiKey: string, config: ILiquidCommerceConfig);
40
- /**
41
- * Determines the appropriate base URL for the API based on the environment.
42
- *
43
- * @private
44
- * @param {ILiquidCommerceConfig} config - Configuration options.
45
- * @return {string} - The base URL for the selected environment.
46
- */
47
- private determineBaseURL;
48
- /**
49
- * Initializes the client by authenticating with the LiquidCommerce API.
50
- * This method should be called before making any API requests.
51
- *
52
- * @public
53
- * @return {Promise<void>} - Resolves when initialization is successful.
54
- * @throws {Error} - Throws an error if authentication fails.
55
- */
56
- init(): Promise<void>;
57
- /**
58
- * Ensures that the client is authenticated before making API requests.
59
- * If the authentication token is expired, it will attempt to re-authenticate.
60
- *
61
- * @private
62
- * @return {Promise<void>} - Resolves when the client is authenticated.
63
- * @throws {Error} - Throws an error if re-authentication fails.
64
- */
65
- private ensureAuthenticated;
66
- /**
67
- * Address object that provides methods for performing address autocompletion and retrieving address details.
68
- *
69
- * @interface IAddressMethod address
70
- *
71
- * @property {function(Omit<IAddressAutocompleteParams, 'key'>): Promise<IApiResponseWithData<IAddressAutocompleteResult[]>>} autocomplete -
72
- * Method for performing address autocompletion based on the provided parameters.
73
- *
74
- * @property {function(Omit<IAddressDetailsParams, 'key'>): Promise<IApiResponseWithData<IAddressDetailsResult>>} details -
75
- * Method for retrieving address details based on the provided parameters.
76
- */
77
- address: IAddressMethod;
78
- /**
79
- * Catalog object that provides methods for availability and search operations.
80
- *
81
- * @interface ICatalogMethod catalog
82
- *
83
- * @property {function(params: IAvailabilityParams): Promise<IApiResponseWithoutData<IAvailabilityResponse>>} availability -
84
- * Method to check the availability of a specific item in the catalog.
85
- *
86
- * @property {function(params: ICatalogParams): Promise<IApiResponseWithoutData<ICatalog>>} search -
87
- * Method to perform a search in the catalog based on the provided parameters.
88
- *
89
- * @see {@link IApiResponseWithoutData} for the structure of the promise returned by both methods.
90
- */
91
- catalog: ICatalogMethod;
92
- /**
93
- * Represents a cart object with methods for updating and retrieving cart data.
94
- *
95
- * @interface ICartMethod cart
96
- *
97
- * @property {function(id: string): Promise<IApiResponseWithoutData<ICart>>} get -
98
- * Retrieves the cart by its ID, or returns a new cart if no ID is provided.
99
- * @property {function(params: ICartUpdateParams): Promise<IApiResponseWithoutData<ICart>>} update -
100
- * Method to update the cart with the provided parameters.
101
- *
102
- * @see {@link ICartUpdateParams} for the structure of the parameters required to update the cart.
103
- * @see {@link IApiResponseWithoutData} for the structure of the promise returned by both methods.
104
- * @see {@link ICart} for the structure of the cart data returned.
105
- */
106
- cart: ICartMethod;
107
- /**
108
- * User object that provides methods for user-related operations.
109
- *
110
- * @interface IUserMethod user
111
- *
112
- * @property {function(params: IUserSessionParams): Promise<IApiResponseWithData<IUser>>} session -
113
- * Method for creating or updating a user session.
114
- * @property {function(identifier: string): Promise<IApiResponseWithData<IPurgeResponse>>} purge -
115
- * Method for purging a user's data from the system.
116
- * @property {function(params: IUserAddressParams): Promise<IApiResponseWithData<IUserAddress>>} updateAddress -
117
- * Method for updating or creating a user's address.
118
- * @property {function(addressId: string): Promise<IApiResponseWithData<IPurgeResponse>>} purgeAddress -
119
- * Method for purging a user's address.
120
- *
121
- * @see {@link IUserSessionParams} for the structure of the session request parameters.
122
- * @see {@link IUserAddressParams} for the structure of the address update request parameters.
123
- * @see {@link IUser} for the structure of the user data returned.
124
- * @see {@link IUserAddress} for the structure of the user's address data returned.
125
- * @see {@link IPurgeResponse} for the structure of the user data returned.
126
- *
127
- * */
128
- user: IUserMethod;
129
- /**
130
- * Payment object that provides methods for payment-related operations.
131
- *
132
- * @interface IPaymentMethod payment
133
- *
134
- * @property {function(config: ILiquidPaymentConfig): Promise<void>} mount -
135
- * Method for mounting the payment element into the DOM.
136
- *
137
- * @property {function(): Promise<ILiquidPaymentToken>} generateToken -
138
- * Method for generating a payment token for the current payment information.
139
- *
140
- * @property {function(eventType: K, handler: function): void} subscribe -
141
- * Method for subscribing to payment element events.
142
- *
143
- * @property {function(eventType: K, handler?: function): void} unsubscribe -
144
- * Method for unsubscribing from payment element events.
145
- *
146
- * @see {@link ILiquidPaymentConfig} Represents the configuration for Liquid payment.
147
- * @see {@link ILiquidPaymentToken} Represents a payment token for liquid payments.
148
- * @see {@link ILiquidPaymentError} Represents an error that occurs during a liquid payment.
149
- * @see {@link ILiquidPaymentElementOptions} The options for the payment element.
150
- * @see {@link IPaymentElementEventMap} The map of payment element event types to their corresponding event objects.
151
- */
152
- payment: IPaymentMethod;
153
- /**
154
- * Checkout object that provides methods for checkout-related operations.
155
- *
156
- * @interface ICheckoutMethod checkout
157
- *
158
- * @property {function(params: ICheckoutPrepareParams): Promise<IApiResponseWithoutData<ICheckoutPrepareResponse>>} prepare -
159
- * Method to prepare a checkout based on the provided parameters.
160
- * @property {function(params: ICheckoutCompleteParams): Promise<IApiResponseWithoutData<ICheckoutCompleteResponse>>} complete -
161
- * Method completes a checkout process with the provided token and payment information.
162
- *
163
- * @see {@link ICheckoutPrepareParams} for the structure of the prepare request parameters.
164
- * @see {@link IApiResponseWithoutData} for the structure of the promise returned by the prepare method.
165
- * @see {@link ICheckoutPrepareResponse} for the structure of the prepared checkout data returned.
166
- * @see {@link ICheckoutCompleteParams} for the structure of the complete request parameters.
167
- * @see {@link ICheckoutCompleteResponse} for the structure of the complete checkout data returned.
168
- */
169
- checkout: ICheckoutMethod;
170
- }
1
+ import type { ILiquidCommerceClient } from './interfaces';
2
+ import type { ILiquidCommerceConfig } from './types';
171
3
  /**
172
4
  * Factory function to create and initialize a LiquidCommerceClient instance.
173
5
  *
@@ -184,6 +16,4 @@ declare class LiquidCommerceClient implements ILiquidCommerceClient {
184
16
  *
185
17
  * @throws {Error} - Throws an error if the client initialization fails.
186
18
  */
187
- export declare function LiquidCommerce(apiKey: string, config: ILiquidCommerceConfig): Promise<LiquidCommerceClient>;
188
- export { LIQUID_COMMERCE_ENV };
189
- export type { IAddressAutocompleteParams, IAddressAutocompleteResult, IAddressDetailsParams, IAddressDetailsResult, IAddressMethod, IApiResponseWithData, IApiResponseWithoutData, IAvailabilityParams, IAvailabilityResponse, ICart, ICartMethod, ICartUpdateParams, ICatalog, ICatalogMethod, ICatalogParams, ICheckoutCompleteParams, ICheckoutCompleteResponse, ICheckoutMethod, ICheckoutPrepareParams, ICheckoutPrepareResponse, ILiquidCommerceClient, ILiquidCommerceConfig, ILiquidPaymentConfig, ILiquidPaymentToken, IPaymentElementEventMap, IPaymentMethod, IPurgeResponse, IUser, IUserAddress, IUserAddressParams, IUserMethod, IUserSessionParams, };
19
+ export declare function LiquidCommerce(apiKey: string, config: ILiquidCommerceConfig): Promise<ILiquidCommerceClient>;
@@ -1,21 +1,6 @@
1
1
  import type { AuthenticatedService } from '../core';
2
- import type { ICoords } from '../interfaces/address.interface';
3
- import type { IApiResponseWithData, ICoreParams } from '../types';
4
- export interface IAddressAutocompleteParams extends ICoreParams {
5
- input: string;
6
- }
7
- export interface IAddressAutocompleteResult {
8
- id: string;
9
- description: string;
10
- }
11
- export interface IAddressDetailsParams extends ICoreParams {
12
- id: string;
13
- }
14
- export interface IAddressDetailsResult {
15
- formattedAddress: string;
16
- coords: ICoords;
17
- }
18
- type AddressServiceResponse<T> = IApiResponseWithData<T>;
2
+ import type { IAddressAutocompleteParams, IAddressAutocompleteResult, IAddressDetailsParams, IAddressDetailsResult } from '../interfaces';
3
+ import type { AddressServiceResponse } from '../types';
19
4
  /**
20
5
  * Represents a service for interacting with address-related functionality.
21
6
  */
@@ -41,4 +26,3 @@ export declare class AddressService {
41
26
  */
42
27
  details(params: IAddressDetailsParams, googlePlacesApiKey: string): Promise<AddressServiceResponse<IAddressDetailsResult>>;
43
28
  }
44
- export {};
@@ -1,5 +1,5 @@
1
1
  import type { AuthenticatedService, CartHelperService } from '../core';
2
- import type { ICart, ICartUpdateParams } from '../interfaces/cart.interface';
2
+ import type { ICart, ICartUpdateParams } from '../interfaces';
3
3
  import type { IApiResponseWithoutData } from '../types';
4
4
  /**
5
5
  * The CartService class is responsible for fetching and updating cart data from the server.
@@ -1,17 +1,6 @@
1
1
  import type { AuthenticatedService, CatalogHelperService } from '../core';
2
- import type { ILocBase } from '../interfaces/address.interface';
3
- import type { IProduct } from '../interfaces/catalog.interface';
4
- import type { ICatalog, ICatalogParams } from '../interfaces/catalog.service.interface';
5
- import type { IRetailer } from '../interfaces/retailer.interface';
2
+ import type { IAvailabilityParams, IAvailabilityResponse, ICatalog, ICatalogParams } from '../interfaces';
6
3
  import type { IApiResponseWithoutData } from '../types';
7
- export interface IAvailabilityParams extends ILocBase {
8
- upcs: string[];
9
- shouldShowOffHours?: boolean;
10
- }
11
- export interface IAvailabilityResponse {
12
- products: IProduct[];
13
- retailers: IRetailer[];
14
- }
15
4
  /**
16
5
  * The CatalogService class provides methods for interacting with the catalog API.
17
6
  */
@@ -1,5 +1,5 @@
1
1
  import type { AuthenticatedService, CheckoutHelperService } from '../core';
2
- import type { ICheckoutCompleteParams, ICheckoutCompleteResponse, ICheckoutPrepareParams, ICheckoutPrepareResponse } from '../interfaces/checkout.interface';
2
+ import type { ICheckoutCompleteParams, ICheckoutCompleteResponse, ICheckoutPrepareParams, ICheckoutPrepareResponse } from '../interfaces';
3
3
  import type { IApiResponseWithoutData } from '../types';
4
4
  /**
5
5
  * A service for managing the checkout process.
@@ -0,0 +1,5 @@
1
+ export * from './address.service';
2
+ export * from './catalog.service';
3
+ export * from './checkout.service';
4
+ export * from './payment.service';
5
+ export * from './user.service';
@@ -1,5 +1,5 @@
1
1
  import type { PaymentProviderService } from '../core';
2
- import type { ILiquidPaymentConfig, ILiquidPaymentError, ILiquidPaymentToken, IPaymentElementEventMap } from '../interfaces/payment.interface';
2
+ import type { ILiquidPaymentConfig, ILiquidPaymentError, ILiquidPaymentToken, IPaymentElementEventMap } from '../interfaces';
3
3
  /**
4
4
  * The PaymentService class provides methods for interacting with payment functionality.
5
5
  */
@@ -36,4 +36,27 @@ export declare class PaymentService {
36
36
  * @return void
37
37
  */
38
38
  unsubscribe<K extends keyof IPaymentElementEventMap>(eventType: K, handler?: (event: IPaymentElementEventMap[K]) => void): void;
39
+ /**
40
+ * Collapses the payment element if it has been initialized.
41
+ * Throws an error if the payment element has not been initialized.
42
+ *
43
+ * @return {void}
44
+ * @throws {Error} Will throw an error if the payment element has not been initialized.
45
+ */
46
+ collapse: () => void;
47
+ /**
48
+ * Unmounts the payment element from the DOM.
49
+ * Throws an error if the payment element has not been initialized.
50
+ *
51
+ * @return {void}
52
+ * @throws {Error} Will throw an error if the payment element has not been initialized.
53
+ */
54
+ unmount: () => void;
55
+ /**
56
+ * Destroys the payment element if it has been initialized.
57
+ *
58
+ * @return {void} No return value.
59
+ * @throws {Error} Will throw an error if the payment element has not been initialized.
60
+ */
61
+ destroy: () => void;
39
62
  }
@@ -1,5 +1,5 @@
1
1
  import type { AuthenticatedService } from '../core';
2
- import type { IPurgeResponse, IUser, IUserAddress, IUserAddressParams, IUserSessionParams } from '../interfaces/user.interface';
2
+ import type { BaseUser, IPurgeResponse, IUser, IUserAddress, IUserAddressParams, IUserPayment, IUserPaymentAddParams, IUserPaymentUpdateParams, IUserSessionParams } from '../interfaces';
3
3
  import type { IApiResponseWithData } from '../types';
4
4
  /**
5
5
  * A class representing a user service.
@@ -16,6 +16,14 @@ export declare class UserService {
16
16
  * @throws {Error} If the session creation/update request fails or if neither id nor email is provided.
17
17
  */
18
18
  createOrUpdateSession(params: IUserSessionParams): Promise<IApiResponseWithData<IUser>>;
19
+ /**
20
+ * Fetches user data from the API using the provided identifier.
21
+ *
22
+ * @param {string} identifier - The unique identifier for the user.
23
+ * @return {Promise<IApiResponseWithData<BaseUser>>} The API response containing
24
+ * user data omitting the session field.
25
+ */
26
+ fetchUser(identifier: string): Promise<IApiResponseWithData<BaseUser>>;
19
27
  /**
20
28
  * Purges a user's data from the system.
21
29
  *
@@ -24,6 +32,14 @@ export declare class UserService {
24
32
  * @throws {Error} If the purge request fails or if the identifier is not provided.
25
33
  */
26
34
  purge(identifier: string): Promise<IApiResponseWithData<IPurgeResponse>>;
35
+ /**
36
+ * Adds a new address for a user.
37
+ *
38
+ * @param {IUserAddressParams} params - The parameters containing the user's address details.
39
+ * @return {Promise<IApiResponseWithData<IUserAddress>>} - A promise that resolves with the API response containing the added user address.
40
+ * @throws {Error} If the addAddress request fails or if the required parameters are not provided.
41
+ */
42
+ addAddress(params: IUserAddressParams): Promise<IApiResponseWithData<IUserAddress>>;
27
43
  /**
28
44
  * Updates or creates a new address for a user.
29
45
  *
@@ -32,6 +48,43 @@ export declare class UserService {
32
48
  * @throws {Error} If the address update request fails or if required parameters are missing.
33
49
  */
34
50
  updateAddress(params: IUserAddressParams): Promise<IApiResponseWithData<IUserAddress>>;
51
+ /**
52
+ * Validates the parameters required for updating a user address.
53
+ *
54
+ * @param {IUserAddressParams} params - The parameters to be validated for the address update. This should include
55
+ * at least the user ID and one of the following: address object, latitude and longitude, or a Google places ID.
56
+ * @return {IUserAddressParams} Throws an error if the required parameters are not provided.
57
+ */
58
+ private validateAddressParams;
59
+ /**
60
+ * Checks if the given user address parameters contain valid customer ID and user ID.
61
+ *
62
+ * @param {IUserAddressParams} params - The user address parameters object containing customerId and userId.
63
+ * @return {boolean} - Returns true if the customerId or userId is missing or not a string, otherwise returns false.
64
+ */
65
+ private hasUser;
66
+ /**
67
+ * Checks if the given user address object has a valid address.
68
+ *
69
+ * @param {IUserAddressParams} params - The user address parameters object containing address details.
70
+ *
71
+ * @return {boolean} Returns true if the user address object is valid; otherwise, returns false.
72
+ */
73
+ private hasUserAddressObj;
74
+ /**
75
+ * Checks if the user address coordinates (latitude and longitude) are not present or not of type 'number'.
76
+ *
77
+ * @param {IUserAddressParams} params - The user address parameters containing latitude and longitude.
78
+ * @return {boolean} Returns true if latitude or longitude are not provided or are not numbers, otherwise returns false.
79
+ */
80
+ private hasUserAddressCoords;
81
+ /**
82
+ * Checks whether the user address parameters contain a valid placesId.
83
+ *
84
+ * @param {IUserAddressParams} params - The user address parameters containing placesId.
85
+ * @return {boolean} Returns true if placesId is missing or not a string, false otherwise.
86
+ */
87
+ private hasUserAddressPlacesId;
35
88
  /**
36
89
  * Purges an address for a user.
37
90
  *
@@ -40,4 +93,33 @@ export declare class UserService {
40
93
  * @throws {Error} If the address purge request fails or if the address ID is not provided.
41
94
  */
42
95
  purgeAddress(addressId: string): Promise<IApiResponseWithData<IPurgeResponse>>;
96
+ /**
97
+ * Adds a new payment method for a user.
98
+ *
99
+ * @param {IUserPaymentParams} params - The parameters required to add a payment method.
100
+ * @param {string} params.customerId - The ID of the customer.
101
+ * @param {string} params.paymentMethodId - The ID of the payment method.
102
+ * @param {boolean} params.isDefault - Indicates whether the new payment method should be marked as default.
103
+ * @return {Promise<IApiResponseWithData<IUserPayment>>} - A promise that resolves to the response containing user payment information.
104
+ * @throws {Error} - Throws an error if required parameters are missing or if the request fails.
105
+ */
106
+ addPayment(params: IUserPaymentAddParams): Promise<IApiResponseWithData<IUserPayment>>;
107
+ /**
108
+ * Updates whether the default payment method for a user.
109
+ *
110
+ * @param {IUserPaymentParams} params - The payment parameters required to update payment. Must include `customerId`,
111
+ * `paymentMethodId`, and a boolean `isDefault`.
112
+ * @returns {Promise<IApiResponseWithData<IUserPayment>>} - A promise that resolves to the API response containing
113
+ * the updated payment information.
114
+ * @throws {Error} - Throws an error if required parameters are missing or the request fails.
115
+ */
116
+ updatePayment(params: IUserPaymentUpdateParams): Promise<IApiResponseWithData<IUserPayment>>;
117
+ /**
118
+ * Purges a payment record for a specified customer.
119
+ *
120
+ * @param {string} customerId - The ID of the customer whose payment record is to be purged.
121
+ * @param {string} paymentId - The ID of the payment record to be purged.
122
+ * @return {Promise<IApiResponseWithData<IPurgeResponse>>} A promise that resolves to the response of the purge request.
123
+ */
124
+ purgePayment(customerId: string, paymentId: string): Promise<IApiResponseWithData<IPurgeResponse>>;
43
125
  }
@@ -1,9 +1,16 @@
1
- import type { ENUM_BEER, ENUM_FOOD, ENUM_MERCHANDISE, ENUM_NON_ALCOHOLIC, ENUM_READY_TO_DRINK, ENUM_SPIRITS, ENUM_WINE, LIQUID_COMMERCE_ENV } from './enums';
1
+ import type { ENUM_BEER, ENUM_FOOD, ENUM_MERCHANDISE, ENUM_MISCELLANEOUS, ENUM_NON_ALCOHOLIC, ENUM_READY_TO_DRINK, ENUM_SPIRITS, ENUM_WINE, LIQUID_COMMERCE_ENV } from './enums';
2
2
  export interface ICoreParams {
3
3
  refresh?: boolean;
4
+ isLean?: boolean;
5
+ isLegacy?: boolean;
6
+ }
7
+ export interface IAuth {
8
+ token: string;
9
+ exp: number;
10
+ type: 'ACCESS_TOKEN';
4
11
  }
5
12
  export interface IAuthResponse {
6
- auth?: IAuthResponse;
13
+ auth?: IAuth;
7
14
  }
8
15
  export interface IResponseMetadata {
9
16
  languages: string[];
@@ -24,8 +31,6 @@ export type IApiResponseWithData<T> = IApiResponseBase & {
24
31
  export type IApiResponseWithoutData<T> = IApiResponseBase & {
25
32
  [K in keyof T]: T[K];
26
33
  };
27
- export type IApiResponse<T> = IApiResponseWithData<T> | IApiResponseWithoutData<T>;
28
- export declare function isApiResponseWithData<T>(response: IApiResponse<T>): response is IApiResponseWithData<T>;
29
34
  export interface ILiquidCommerceConfig {
30
35
  googlePlacesApiKey: string;
31
36
  env: LIQUID_COMMERCE_ENV;
@@ -33,4 +38,5 @@ export interface ILiquidCommerceConfig {
33
38
  stage?: string;
34
39
  };
35
40
  }
36
- export type LiquidTaxonomy = ENUM_BEER | ENUM_FOOD | ENUM_MERCHANDISE | ENUM_NON_ALCOHOLIC | ENUM_READY_TO_DRINK | ENUM_SPIRITS | ENUM_WINE;
41
+ export type LiquidTaxonomy = ENUM_BEER | ENUM_FOOD | ENUM_MERCHANDISE | ENUM_MISCELLANEOUS | ENUM_NON_ALCOHOLIC | ENUM_READY_TO_DRINK | ENUM_SPIRITS | ENUM_WINE;
42
+ export type AddressServiceResponse<T> = IApiResponseWithData<T>;