@liquidcommerce/cloud-sdk 1.0.1
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.
- package/README.md +256 -0
- package/dist/index.cjs +1 -0
- package/dist/index.esm.js +1 -0
- package/dist/liquidcommerce-cloud-sdk.ssr.js +1 -0
- package/dist/types/constants/core.constant.d.ts +4 -0
- package/dist/types/core/authenticated.service.d.ts +125 -0
- package/dist/types/core/cart-helper.service.d.ts +48 -0
- package/dist/types/core/catalog-helper.service.d.ts +113 -0
- package/dist/types/core/checkout-helper.service.d.ts +76 -0
- package/dist/types/core/index.d.ts +7 -0
- package/dist/types/core/location-helper.service.d.ts +47 -0
- package/dist/types/core/payment-provider.service.d.ts +91 -0
- package/dist/types/core/singleton.service.d.ts +138 -0
- package/dist/types/enums.d.ts +265 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.umd.d.ts +2 -0
- package/dist/types/interfaces/address.interface.d.ts +21 -0
- package/dist/types/interfaces/cart.interface.d.ts +188 -0
- package/dist/types/interfaces/catalog.interface.d.ts +69 -0
- package/dist/types/interfaces/catalog.service.interface.d.ts +65 -0
- package/dist/types/interfaces/checkout.interface.d.ts +118 -0
- package/dist/types/interfaces/liquid-commerce-client.interface.d.ts +597 -0
- package/dist/types/interfaces/payment.interface.d.ts +88 -0
- package/dist/types/interfaces/retailer.interface.d.ts +63 -0
- package/dist/types/interfaces/user.interface.d.ts +53 -0
- package/dist/types/liquid-commerce-client.d.ts +189 -0
- package/dist/types/services/address.service.d.ts +44 -0
- package/dist/types/services/cart.service.d.ts +31 -0
- package/dist/types/services/catalog.service.d.ts +38 -0
- package/dist/types/services/checkout.service.d.ts +28 -0
- package/dist/types/services/payment.service.d.ts +39 -0
- package/dist/types/services/user.service.d.ts +43 -0
- package/dist/types/types.d.ts +36 -0
- package/package.json +108 -0
- package/umd/liquidcommerce-cloud-sdk.min.js +1 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { ICatalogParams } from '../interfaces/catalog.service.interface';
|
|
2
|
+
import type { IAvailabilityParams } from '../services/catalog.service';
|
|
3
|
+
import type { LocationHelperService } from './location-helper.service';
|
|
4
|
+
/**
|
|
5
|
+
* The `CatalogHelperService` class provides utility methods for validating and normalizing
|
|
6
|
+
* input parameters for availability and catalog search.
|
|
7
|
+
*/
|
|
8
|
+
export declare class CatalogHelperService {
|
|
9
|
+
private locationServiceHelper;
|
|
10
|
+
private readonly taxonomyValues;
|
|
11
|
+
constructor(locationServiceHelper: LocationHelperService);
|
|
12
|
+
/**
|
|
13
|
+
* Validates and normalizes the input parameters for availability.
|
|
14
|
+
*
|
|
15
|
+
* @param {IAvailabilityParams} params - The availability parameters to be validated and normalized.
|
|
16
|
+
* @returns {IAvailabilityParams} - The validated and normalized availability parameters.
|
|
17
|
+
*/
|
|
18
|
+
validateAndNormalizeParams(params: IAvailabilityParams): IAvailabilityParams;
|
|
19
|
+
/**
|
|
20
|
+
* Validates and normalizes the search parameters for catalog search.
|
|
21
|
+
*
|
|
22
|
+
* @param {ICatalogParams} params - The search parameters to be validated and normalized.
|
|
23
|
+
* @returns {ICatalogParams} - The validated and normalized search parameters.
|
|
24
|
+
*/
|
|
25
|
+
validateAndNormalizeSearchParams(params: ICatalogParams): ICatalogParams & {
|
|
26
|
+
error?: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Validates an array of UPCs.
|
|
30
|
+
*
|
|
31
|
+
* @param {string[]} upcs - The array of UPCs to validate.
|
|
32
|
+
* @throws {Error} If upcs is not an array or is an empty array.
|
|
33
|
+
* @throws {Error} If any UPC in the array is not a non-empty string.
|
|
34
|
+
*/
|
|
35
|
+
private validateUPCs;
|
|
36
|
+
/**
|
|
37
|
+
* Validates the orderBy parameter and adds any validation errors to the errors array.
|
|
38
|
+
*
|
|
39
|
+
* @param orderBy - The orderBy value to validate.
|
|
40
|
+
* @param errors - The array to store any validation errors.
|
|
41
|
+
*
|
|
42
|
+
* @return void
|
|
43
|
+
*/
|
|
44
|
+
private validateOrderBy;
|
|
45
|
+
/**
|
|
46
|
+
* Validates the order direction.
|
|
47
|
+
*
|
|
48
|
+
* @param {ENUM_NAVIGATION_ORDER_DIRECTION_TYPE | undefined} orderDirection - The order direction to be validated.
|
|
49
|
+
* @param {string[]} errors - An array to store error messages.
|
|
50
|
+
*
|
|
51
|
+
* @return {void} This method does not return any value.
|
|
52
|
+
*/
|
|
53
|
+
private validateOrderDirection;
|
|
54
|
+
/**
|
|
55
|
+
* Validates the filters for the catalog.
|
|
56
|
+
*
|
|
57
|
+
* @param filters - The filters to be validated.
|
|
58
|
+
* @param errors - An array to store any validation errors.
|
|
59
|
+
* @returns void
|
|
60
|
+
*/
|
|
61
|
+
private validateFilters;
|
|
62
|
+
/**
|
|
63
|
+
* Validates the availability filter value.
|
|
64
|
+
*
|
|
65
|
+
* @param {ENUM_AVAILABILITY_VALUE} value - The value to be validated.
|
|
66
|
+
* @param {string[]} errors - The array to store any validation errors.
|
|
67
|
+
*
|
|
68
|
+
* @return {void}
|
|
69
|
+
*/
|
|
70
|
+
private validateAvailabilityFilter;
|
|
71
|
+
/**
|
|
72
|
+
* Validates the given array filter.
|
|
73
|
+
*
|
|
74
|
+
* @param values - The array to be validated.
|
|
75
|
+
* @param maxLength - The maximum number of values allowed in the array filter.
|
|
76
|
+
* @param filterName - The name of the filter being validated.
|
|
77
|
+
* @param errors - An array to store any validation errors.
|
|
78
|
+
*
|
|
79
|
+
* @return - This method does not return anything.
|
|
80
|
+
*
|
|
81
|
+
* @remarks
|
|
82
|
+
* This method checks if the given values parameter is an array. If it is not, an error message is added
|
|
83
|
+
* to the errors array indicating that the filter must be an array.
|
|
84
|
+
*
|
|
85
|
+
* If the array has a length that exceeds the maxLength parameter, an error message is added to the errors
|
|
86
|
+
* array indicating that the filter can have a maximum of maxLength values.
|
|
87
|
+
*/
|
|
88
|
+
private validateArrayFilter;
|
|
89
|
+
/**
|
|
90
|
+
* Validates the categories filter values.
|
|
91
|
+
*
|
|
92
|
+
* @param {LiquidTaxonomy[]} values - The array of category values to validate.
|
|
93
|
+
* @param {string[]} errors - An array to store any validation errors.
|
|
94
|
+
*
|
|
95
|
+
* @return {void} - This method does not return a value.
|
|
96
|
+
*/
|
|
97
|
+
private validateCategoriesFilter;
|
|
98
|
+
/**
|
|
99
|
+
* Validates the pagination options.
|
|
100
|
+
*
|
|
101
|
+
* @param {number | undefined} page - The current page number.
|
|
102
|
+
* @param {number | undefined} perPage - The number of items per page.
|
|
103
|
+
* @param {string[]} errors - An array to store any validation errors.
|
|
104
|
+
*
|
|
105
|
+
* @return {void}
|
|
106
|
+
*
|
|
107
|
+
* @description
|
|
108
|
+
* This method validates the provided pagination options and adds any validation errors to the `errors` array.
|
|
109
|
+
* The `page` argument must be a non-negative number, and the `perPage` argument must be a positive number.
|
|
110
|
+
* If either argument fails validation, an error message is pushed to the `errors` array.
|
|
111
|
+
*/
|
|
112
|
+
private validatePagination;
|
|
113
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { ICheckoutCompleteParams, ICheckoutPrepareParams } from '../interfaces/checkout.interface';
|
|
2
|
+
import type { LocationHelperService } from './location-helper.service';
|
|
3
|
+
/**
|
|
4
|
+
* CheckoutHelperService is a helper class that provides methods
|
|
5
|
+
* for validating and normalizing checkout parameters.
|
|
6
|
+
*/
|
|
7
|
+
export declare class CheckoutHelperService {
|
|
8
|
+
private locationHelperService;
|
|
9
|
+
constructor(locationHelperService: LocationHelperService);
|
|
10
|
+
/**
|
|
11
|
+
* Validates and normalizes prepare parameters.
|
|
12
|
+
*
|
|
13
|
+
* @param {ICheckoutPrepareParams} params - The prepare parameters to be validated and normalized.
|
|
14
|
+
*
|
|
15
|
+
* @return {ICheckoutPrepareParams} - The normalized prepare parameters.
|
|
16
|
+
*
|
|
17
|
+
* @throws {Error} - Invalid cartId if cartId is missing or not a string.
|
|
18
|
+
*/
|
|
19
|
+
validateAndNormalizePrepareParams(params: ICheckoutPrepareParams): ICheckoutPrepareParams;
|
|
20
|
+
/**
|
|
21
|
+
* Validates and normalizes the complete checkout parameters.
|
|
22
|
+
*
|
|
23
|
+
* @param {ICheckoutCompleteParams} params - The complete checkout parameters.
|
|
24
|
+
*
|
|
25
|
+
* @throws {Error} If the token is missing or not a string.
|
|
26
|
+
* @throws {Error} If the payment token is missing or not a string.
|
|
27
|
+
*
|
|
28
|
+
* @return {ICheckoutCompleteParams} The validated and normalized complete checkout parameters.
|
|
29
|
+
*/
|
|
30
|
+
validateAndNormalizeCompleteParams(params: ICheckoutCompleteParams): ICheckoutCompleteParams;
|
|
31
|
+
/**
|
|
32
|
+
* Validates the recipient object.
|
|
33
|
+
*
|
|
34
|
+
* @param {ICheckoutPrepareParams['recipient']} recipient - The recipient object to be validated.
|
|
35
|
+
* @throws {Error} If the recipient object is invalid.
|
|
36
|
+
* @returns {void}
|
|
37
|
+
*/
|
|
38
|
+
private validateRecipient;
|
|
39
|
+
/**
|
|
40
|
+
* Validates the given address object.
|
|
41
|
+
* @param {IAddress} address - The address object to validate.
|
|
42
|
+
* @throws {Error} If the address is invalid or any required field is missing or not a string.
|
|
43
|
+
* @returns {void}
|
|
44
|
+
*/
|
|
45
|
+
private validateAddress;
|
|
46
|
+
/**
|
|
47
|
+
* Validates the giftOptions parameter.
|
|
48
|
+
*
|
|
49
|
+
* @param {ICheckoutPrepareParams['giftOptions']} giftOptions - The giftOptions to be validated.
|
|
50
|
+
*
|
|
51
|
+
* @throws {Error} If the giftOptions parameter is not provided or is not an object.
|
|
52
|
+
* @throws {Error} If the gift message is provided but is not a string.
|
|
53
|
+
* @throws {Error} If the gift recipient's name, phone, or email is provided but is not a string.
|
|
54
|
+
*
|
|
55
|
+
* @returns {void}
|
|
56
|
+
*/
|
|
57
|
+
private validateGiftOptions;
|
|
58
|
+
/**
|
|
59
|
+
* Validates the given marketing preferences.
|
|
60
|
+
*
|
|
61
|
+
* @param {ICheckoutPrepareParams['marketingPreferences']} preferences - The marketing preferences to validate.
|
|
62
|
+
*
|
|
63
|
+
* @throws {Error} The error thrown if the marketing preferences are invalid.
|
|
64
|
+
*/
|
|
65
|
+
private validateMarketingPreferences;
|
|
66
|
+
/**
|
|
67
|
+
* Validates the delivery tips array.
|
|
68
|
+
*
|
|
69
|
+
* @param {ICheckoutPrepareParams['deliveryTips']} tips - An array of delivery tips to validate.
|
|
70
|
+
* @throws {Error} If the deliveryTips parameter is not an array.
|
|
71
|
+
* @throws {Error} If the fulfillmentId property of any delivery tip is invalid.
|
|
72
|
+
* @throws {Error} If the tip amount of any delivery tip is invalid.
|
|
73
|
+
* @return {void}
|
|
74
|
+
*/
|
|
75
|
+
private validateDeliveryTips;
|
|
76
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './authenticated.service';
|
|
2
|
+
export * from './cart-helper.service';
|
|
3
|
+
export * from './catalog-helper.service';
|
|
4
|
+
export * from './checkout-helper.service';
|
|
5
|
+
export * from './location-helper.service';
|
|
6
|
+
export * from './payment-provider.service';
|
|
7
|
+
export * from './singleton.service';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ILoc } from '../interfaces/address.interface';
|
|
2
|
+
/**
|
|
3
|
+
* The LocationHelperService class provides methods to validate and normalize location objects.
|
|
4
|
+
*/
|
|
5
|
+
export declare class LocationHelperService {
|
|
6
|
+
/**
|
|
7
|
+
* Validates and normalizes a location object.
|
|
8
|
+
* @param {ILoc} loc - The location object to validate and normalize.
|
|
9
|
+
* @throws {Error} - If the loc argument is not a valid object or if
|
|
10
|
+
* it doesn't contain either coords or address.
|
|
11
|
+
*/
|
|
12
|
+
validateAndNormalizeLocation(loc: ILoc): void;
|
|
13
|
+
/**
|
|
14
|
+
* Validates coordinates to ensure they are within valid range.
|
|
15
|
+
*
|
|
16
|
+
* @param coords - The object containing the latitude and longitude values to be validated.
|
|
17
|
+
* @param coords.lat - The latitude value to be validated.
|
|
18
|
+
* @param coords.long - The longitude value to be validated.
|
|
19
|
+
*
|
|
20
|
+
* @throws {Error} - Throws an error if the coordinates are not valid numbers or are out of range.
|
|
21
|
+
*
|
|
22
|
+
* @return {void}
|
|
23
|
+
*/
|
|
24
|
+
private validateCoordinates;
|
|
25
|
+
/**
|
|
26
|
+
* Validates and normalizes an address object.
|
|
27
|
+
*
|
|
28
|
+
* @param {any} address - The address object to validate and normalize.
|
|
29
|
+
*
|
|
30
|
+
* @throws {Error} If the state is missing or not a string.
|
|
31
|
+
* @throws {Error} If the city is missing or not a string.
|
|
32
|
+
* @throws {Error} If the ZIP code is missing or not a string.
|
|
33
|
+
*
|
|
34
|
+
* @return {void}
|
|
35
|
+
*/
|
|
36
|
+
private validateAndNormalizeAddress;
|
|
37
|
+
/**
|
|
38
|
+
* Normalize the state value to its corresponding code or name.
|
|
39
|
+
* The state can be either a state code or state name.
|
|
40
|
+
*
|
|
41
|
+
* @param {STATES_CODE | STATES_NAME} state - The state value to normalize.
|
|
42
|
+
* @return {string} - The normalized state value, which is the corresponding code or name.
|
|
43
|
+
*
|
|
44
|
+
* @throws {Error} - If the state value is invalid.
|
|
45
|
+
*/
|
|
46
|
+
private normalizeState;
|
|
47
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { ILiquidPaymentConfig, ILiquidPaymentError, ILiquidPaymentToken, IPaymentElementEventMap, IPaymentProvider } from '../interfaces/payment.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a service for handling payment processing using the Stripe API.
|
|
4
|
+
* Implements the IPaymentProvider interface.
|
|
5
|
+
*/
|
|
6
|
+
export declare class PaymentProviderService implements IPaymentProvider {
|
|
7
|
+
private stripe;
|
|
8
|
+
private elements;
|
|
9
|
+
private paymentElement;
|
|
10
|
+
private readonly events;
|
|
11
|
+
private readonly eventsErrorMsg;
|
|
12
|
+
/**
|
|
13
|
+
* Mounts the Stripe payment element to the specified container element on the page.
|
|
14
|
+
*
|
|
15
|
+
* @param {ILiquidPaymentConfig} config - The configuration object for the payment element.
|
|
16
|
+
*
|
|
17
|
+
* @throws {Error} If the container element with the specified ID is not found.
|
|
18
|
+
* @throws {Error} If there is an error loading or initializing the Stripe API.
|
|
19
|
+
*
|
|
20
|
+
* @return {Promise<void>} A promise that resolves when the payment element is successfully mounted.
|
|
21
|
+
*/
|
|
22
|
+
mount(config: ILiquidPaymentConfig): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Generate a payment token for a liquid payment.
|
|
25
|
+
*
|
|
26
|
+
* This method generates a payment token using the Stripe API. The payment token represents the payment information provided by the user.
|
|
27
|
+
* The method first checks if the Stripe instance and the Stripe Elements instance have been initialized. If not, it returns an error indicating that the payment form has not been initialized.
|
|
28
|
+
*
|
|
29
|
+
* Next, the method submits the payment form using the `submit()` method of the Stripe Elements instance. If there is an error during the submission, it returns a validation error indicating the error message and code.
|
|
30
|
+
*
|
|
31
|
+
* After successful submission, the method creates a payment method using the `createPaymentMethod()` method of the Stripe instance, passing the Stripe Elements instance as a parameter. If there is an error during the creation of the payment method, it returns the appropriate error containing the error message, code, and parameter (if applicable).
|
|
32
|
+
*
|
|
33
|
+
* If the payment method is successfully created, the method returns the payment information in the form of an object containing the payment method's ID, type, and card details (if available), as well as the creation timestamp. The card details include the card brand, country, expiration month, expiration year, last 4 digits, and funding source.
|
|
34
|
+
*
|
|
35
|
+
* If none of the above conditions are met, it returns an error indicating that the payment token generation has failed.
|
|
36
|
+
*
|
|
37
|
+
* @returns A Promise that resolves to either a LiquidPaymentToken object or a LiquidPaymentError object.
|
|
38
|
+
*
|
|
39
|
+
* The LiquidPaymentToken object has the following properties:
|
|
40
|
+
* - id (string): The ID of the payment method.
|
|
41
|
+
* - type (string): The type of the payment method.
|
|
42
|
+
* - card (object): An optional object containing the card details.
|
|
43
|
+
* - brand (string): The brand of the card.
|
|
44
|
+
* - country (string): The country of the card.
|
|
45
|
+
* - expMonth (number): The expiration month of the card.
|
|
46
|
+
* - expYear (number): The expiration year of the card.
|
|
47
|
+
* - last4 (string): The last 4 digits of the card.
|
|
48
|
+
* - funding (string): The funding source of the card.
|
|
49
|
+
* - created (number): The timestamp indicating when the payment method was created.
|
|
50
|
+
*
|
|
51
|
+
* The LiquidPaymentError object has the following properties:
|
|
52
|
+
* - type (string): The type of the error (either 'client_error', 'validation_error', or 'api_error').
|
|
53
|
+
* - message (string): The error message.
|
|
54
|
+
* - code (string): The error code (if applicable).
|
|
55
|
+
* - param (string): The error parameter (if applicable).
|
|
56
|
+
*/
|
|
57
|
+
generateToken(): Promise<ILiquidPaymentToken | ILiquidPaymentError>;
|
|
58
|
+
/**
|
|
59
|
+
* Subscribes to a specific event on the payment element.
|
|
60
|
+
*
|
|
61
|
+
* @param eventType - The type of event to subscribe to.
|
|
62
|
+
* @param handler - The function to be called when the event is triggered.
|
|
63
|
+
* @throws {Error} - If the payment element has not been initialized.
|
|
64
|
+
* @return {void}
|
|
65
|
+
*/
|
|
66
|
+
subscribe<K extends keyof IPaymentElementEventMap>(eventType: K, handler: (event: IPaymentElementEventMap[K]) => void): void;
|
|
67
|
+
/**
|
|
68
|
+
* Unsubscribes an event handler from a specific event type in the payment element.
|
|
69
|
+
*
|
|
70
|
+
* @param eventType - The type of event to unsubscribe from.
|
|
71
|
+
* @param handler - (Optional) The event handler function to unsubscribe.
|
|
72
|
+
* @throws {Error} - Thrown if the payment element has not been initialized.
|
|
73
|
+
* @return {void}
|
|
74
|
+
*/
|
|
75
|
+
unsubscribe<K extends keyof IPaymentElementEventMap>(eventType: K, handler?: (event: IPaymentElementEventMap[K]) => void): void;
|
|
76
|
+
/**
|
|
77
|
+
* Maps the appearance options from the provided LiquidPaymentConfig object
|
|
78
|
+
* to the corresponding StripeElementsOptions object.
|
|
79
|
+
*
|
|
80
|
+
* @param appearance - The appearance options from the LiquidPaymentConfig object.
|
|
81
|
+
* @returns The appearance options for the StripeElementsOptions object.
|
|
82
|
+
*/
|
|
83
|
+
private mapAppearance;
|
|
84
|
+
/**
|
|
85
|
+
* Maps the given options to Stripe payment element options.
|
|
86
|
+
*
|
|
87
|
+
* @param {ILiquidPaymentElementOptions} options - The options to be mapped.
|
|
88
|
+
* @return {StripePaymentElementOptions} - The mapped Stripe payment element options.
|
|
89
|
+
*/
|
|
90
|
+
private mapElementOptions;
|
|
91
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { ILiquidCommerceClient, ILiquidCommerceClientConstructor } from '../interfaces/liquid-commerce-client.interface';
|
|
2
|
+
import { AddressService } from '../services/address.service';
|
|
3
|
+
import { CartService } from '../services/cart.service';
|
|
4
|
+
import { CatalogService } from '../services/catalog.service';
|
|
5
|
+
import { CheckoutService } from '../services/checkout.service';
|
|
6
|
+
import { PaymentService } from '../services/payment.service';
|
|
7
|
+
import { UserService } from '../services/user.service';
|
|
8
|
+
import type { ILiquidCommerceConfig } from '../types';
|
|
9
|
+
import { AuthenticatedService } from './authenticated.service';
|
|
10
|
+
import { CartHelperService } from './cart-helper.service';
|
|
11
|
+
import { CatalogHelperService } from './catalog-helper.service';
|
|
12
|
+
import { CheckoutHelperService } from './checkout-helper.service';
|
|
13
|
+
import { LocationHelperService } from './location-helper.service';
|
|
14
|
+
import { PaymentProviderService } from './payment-provider.service';
|
|
15
|
+
/**
|
|
16
|
+
* The SingletonManager class is responsible for managing singleton instances of various services.
|
|
17
|
+
* It provides methods for retrieving or creating instances of these services based on unique keys.
|
|
18
|
+
*/
|
|
19
|
+
export declare class SingletonManager {
|
|
20
|
+
private static instance;
|
|
21
|
+
private services;
|
|
22
|
+
private liquidCommerceClientConstructor;
|
|
23
|
+
static getInstance(): SingletonManager;
|
|
24
|
+
/**
|
|
25
|
+
* Sets the constructor for the Liquid Commerce Client.
|
|
26
|
+
*
|
|
27
|
+
* @param {ILiquidCommerceClientConstructor} constructor - The constructor function for the Liquid Commerce Client.
|
|
28
|
+
*
|
|
29
|
+
* @return {void}
|
|
30
|
+
*/
|
|
31
|
+
setLiquidCommerceClientConstructor(constructor: ILiquidCommerceClientConstructor): void;
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves or creates an instance of the LiquidCommerceClient.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} apiKey - The API key for authentication.
|
|
36
|
+
* @param {ILiquidCommerceConfig} config - The configuration object.
|
|
37
|
+
* @returns {Promise<ILiquidCommerceClient>} - A promise that resolves to an instance of ILiquidCommerceClient.
|
|
38
|
+
* @throws {Error} - If the LiquidCommerceClient constructor is not set.
|
|
39
|
+
*/
|
|
40
|
+
getLiquidCommerceClient(apiKey: string, config: ILiquidCommerceConfig): Promise<ILiquidCommerceClient>;
|
|
41
|
+
/**
|
|
42
|
+
* Returns an instance of a service based on the given key and ServiceClass.
|
|
43
|
+
* If the service does not exist, it creates a new instance using the ServiceClass and optional arguments.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} key - The key to identify the service.
|
|
46
|
+
* @param {ServiceFactory<T>} ServiceClass - The class or factory function for the service.
|
|
47
|
+
* @param {...any[]} args - Optional arguments to be passed to the constructor or factory function.
|
|
48
|
+
* @return {T} - The instance of the service.
|
|
49
|
+
*/
|
|
50
|
+
private getOrCreateService;
|
|
51
|
+
/**
|
|
52
|
+
* Returns an authenticated client for the given configuration.
|
|
53
|
+
*
|
|
54
|
+
* @param config - The configuration object containing the API key and base URL.
|
|
55
|
+
* @param config.apiKey - The API key for authentication.
|
|
56
|
+
* @param config.baseURL - The base URL for API requests.
|
|
57
|
+
*
|
|
58
|
+
* @return The authenticated service object.
|
|
59
|
+
*/
|
|
60
|
+
getAuthenticatedClient(config: {
|
|
61
|
+
apiKey: string;
|
|
62
|
+
baseURL: string;
|
|
63
|
+
}): AuthenticatedService;
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves the instance of the LocationHelperService.
|
|
66
|
+
* If the service does not yet exist, it will be created.
|
|
67
|
+
*
|
|
68
|
+
* @return {LocationHelperService} The LocationHelperService instance.
|
|
69
|
+
*/
|
|
70
|
+
getLocationHelperService(): LocationHelperService;
|
|
71
|
+
/**
|
|
72
|
+
* Gets the AddressService instance associated with the provided AuthenticatedService.
|
|
73
|
+
*
|
|
74
|
+
* @param authenticatedClient - The authenticated client used to retrieve the AddressService instance.
|
|
75
|
+
* @return The AddressService instance associated with the authenticated client.
|
|
76
|
+
*/
|
|
77
|
+
getAddressService(authenticatedClient: AuthenticatedService): AddressService;
|
|
78
|
+
/**
|
|
79
|
+
* Retrieves the CatalogHelperService instance.
|
|
80
|
+
*
|
|
81
|
+
* @return {CatalogHelperService} The CatalogHelperService instance.
|
|
82
|
+
*/
|
|
83
|
+
getCatalogHelperService(): CatalogHelperService;
|
|
84
|
+
/**
|
|
85
|
+
* Retrieves the CatalogService for the provided authenticated client.
|
|
86
|
+
*
|
|
87
|
+
* @param authenticatedClient The authenticated client.
|
|
88
|
+
*
|
|
89
|
+
* @return The CatalogService instance created or retrieved.
|
|
90
|
+
*/
|
|
91
|
+
getCatalogService(authenticatedClient: AuthenticatedService): CatalogService;
|
|
92
|
+
/**
|
|
93
|
+
* Retrieves the CartHelperService instance.
|
|
94
|
+
*
|
|
95
|
+
* @return {CartHelperService} The CartHelperService instance.
|
|
96
|
+
*/
|
|
97
|
+
getCartHelperService(): CartHelperService;
|
|
98
|
+
/**
|
|
99
|
+
* Retrieves the CartService instance associated with the given authenticated client.
|
|
100
|
+
*
|
|
101
|
+
* @param authenticatedClient - The authenticated client for which to retrieve the CartService.
|
|
102
|
+
* @return The CartService instance associated with the authenticated client.
|
|
103
|
+
*/
|
|
104
|
+
getCartService(authenticatedClient: AuthenticatedService): CartService;
|
|
105
|
+
/**
|
|
106
|
+
* Retrieves the UserService for the provided authenticated client.
|
|
107
|
+
*
|
|
108
|
+
* @param authenticatedClient - The authenticated client for which to retrieve the UserService.
|
|
109
|
+
* @return The UserService instance.
|
|
110
|
+
*/
|
|
111
|
+
getUserService(authenticatedClient: AuthenticatedService): UserService;
|
|
112
|
+
/**
|
|
113
|
+
* Returns the instance of the `PaymentProviderService` class.
|
|
114
|
+
* This method uses the `getOrCreateService` method internally to obtain the instance.
|
|
115
|
+
*
|
|
116
|
+
* @return {PaymentProviderService} The instance of the `PaymentProviderService` class.
|
|
117
|
+
*/
|
|
118
|
+
getPaymentProviderService(): PaymentProviderService;
|
|
119
|
+
/**
|
|
120
|
+
* Retrieves the payment service by calling the getOrCreateService method.
|
|
121
|
+
*
|
|
122
|
+
* @return {PaymentService} The payment service object.
|
|
123
|
+
*/
|
|
124
|
+
getPaymentService(): PaymentService;
|
|
125
|
+
/**
|
|
126
|
+
* Retrieves the CheckoutHelperService instance.
|
|
127
|
+
*
|
|
128
|
+
* @return {CheckoutHelperService} The CheckoutHelperService instance.
|
|
129
|
+
*/
|
|
130
|
+
getCheckoutHelperService(): CheckoutHelperService;
|
|
131
|
+
/**
|
|
132
|
+
* Retrieves the CheckoutService instance for the provided authenticated client.
|
|
133
|
+
*
|
|
134
|
+
* @param authenticatedClient - The authenticated client object.
|
|
135
|
+
* @return The CheckoutService instance.
|
|
136
|
+
*/
|
|
137
|
+
getCheckoutService(authenticatedClient: AuthenticatedService): CheckoutService;
|
|
138
|
+
}
|