oneentry 1.0.159 → 1.0.161
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 +2 -0
- package/changelog.md +56 -1
- package/dist/admins/adminsApi.d.ts +15 -1
- package/dist/admins/adminsApi.js +29 -0
- package/dist/admins/adminsInterfaces.d.ts +37 -1
- package/dist/base/lazySchema.d.ts +15 -0
- package/dist/base/lazySchema.js +20 -0
- package/dist/discounts/discountsApi.d.ts +14 -1
- package/dist/discounts/discountsApi.js +21 -0
- package/dist/discounts/discountsInterfaces.d.ts +27 -1
- package/dist/filters/filtersInterfaces.d.ts +2 -2
- package/dist/filters/filtersSchemas.d.ts +1 -1
- package/dist/filters/filtersSchemas.js +4 -1
- package/dist/forms-data/formsDataApi.d.ts +14 -1
- package/dist/forms-data/formsDataApi.js +21 -0
- package/dist/forms-data/formsDataInterfaces.d.ts +74 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/orders/ordersApi.d.ts +15 -1
- package/dist/orders/ordersApi.js +22 -0
- package/dist/orders/ordersInterfaces.d.ts +27 -1
- package/dist/pages/pagesApi.d.ts +14 -1
- package/dist/pages/pagesApi.js +21 -0
- package/dist/pages/pagesInterfaces.d.ts +38 -1
- package/dist/payments/paymentsInterfaces.d.ts +2 -2
- package/dist/products/productsInterfaces.d.ts +1 -1
- package/dist/search/searchApi.d.ts +35 -0
- package/dist/search/searchApi.js +86 -0
- package/dist/search/searchInterfaces.d.ts +94 -0
- package/dist/search/searchInterfaces.js +2 -0
- package/dist/search/searchSchemas.d.ts +73 -0
- package/dist/search/searchSchemas.js +44 -0
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +0 -2
- package/dist/templates-preview/templatesPreviewSchemas.d.ts +0 -2
- package/dist/templates-preview/templatesPreviewSchemas.js +0 -1
- package/dist/types.d.ts +35 -0
- package/dist/types.js +2 -0
- package/dist/users/usersApi.d.ts +15 -1
- package/dist/users/usersApi.js +22 -0
- package/dist/users/usersInterfaces.d.ts +39 -1
- package/dist/web-socket/lazySocket.d.ts +18 -0
- package/dist/web-socket/lazySocket.js +70 -0
- package/esm/admins/adminsApi.d.ts +66 -0
- package/esm/admins/adminsApi.js +90 -0
- package/esm/admins/adminsInterfaces.d.ts +137 -0
- package/esm/admins/adminsInterfaces.js +1 -0
- package/esm/admins/adminsSchemas.d.ts +48 -0
- package/esm/admins/adminsSchemas.js +31 -0
- package/esm/attribute-sets/attributeSetsApi.d.ts +67 -0
- package/esm/attribute-sets/attributeSetsApi.js +97 -0
- package/esm/attribute-sets/attributeSetsInterfaces.d.ts +285 -0
- package/esm/attribute-sets/attributeSetsInterfaces.js +1 -0
- package/esm/attribute-sets/attributeSetsSchemas.d.ts +84 -0
- package/esm/attribute-sets/attributeSetsSchemas.js +66 -0
- package/esm/auth-provider/authProviderApi.d.ts +262 -0
- package/esm/auth-provider/authProviderApi.js +362 -0
- package/esm/auth-provider/authProviderSchemas.d.ts +124 -0
- package/esm/auth-provider/authProviderSchemas.js +92 -0
- package/esm/auth-provider/authProvidersInterfaces.d.ts +430 -0
- package/esm/auth-provider/authProvidersInterfaces.js +1 -0
- package/esm/base/asyncModules.d.ts +123 -0
- package/esm/base/asyncModules.js +382 -0
- package/esm/base/lazySchema.d.ts +15 -0
- package/esm/base/lazySchema.js +17 -0
- package/esm/base/stateModule.d.ts +35 -0
- package/esm/base/stateModule.js +51 -0
- package/esm/base/syncModules.d.ts +245 -0
- package/esm/base/syncModules.js +555 -0
- package/esm/base/timeIntervals.d.ts +95 -0
- package/esm/base/timeIntervals.js +317 -0
- package/esm/base/utils.d.ts +354 -0
- package/esm/base/utils.js +1 -0
- package/esm/base/validation.d.ts +98 -0
- package/esm/base/validation.js +118 -0
- package/esm/blocks/blocksApi.d.ts +252 -0
- package/esm/blocks/blocksApi.js +394 -0
- package/esm/blocks/blocksInterfaces.d.ts +361 -0
- package/esm/blocks/blocksInterfaces.js +1 -0
- package/esm/blocks/blocksSchemas.d.ts +213 -0
- package/esm/blocks/blocksSchemas.js +40 -0
- package/esm/discounts/discountsApi.d.ts +94 -0
- package/esm/discounts/discountsApi.js +136 -0
- package/esm/discounts/discountsInterfaces.d.ts +293 -0
- package/esm/discounts/discountsInterfaces.js +1 -0
- package/esm/events/eventsApi.d.ts +108 -0
- package/esm/events/eventsApi.js +141 -0
- package/esm/events/eventsInterfaces.d.ts +176 -0
- package/esm/events/eventsInterfaces.js +1 -0
- package/esm/file-uploading/fileUploadingApi.d.ts +91 -0
- package/esm/file-uploading/fileUploadingApi.js +127 -0
- package/esm/file-uploading/fileUploadingInterfaces.d.ts +116 -0
- package/esm/file-uploading/fileUploadingInterfaces.js +1 -0
- package/esm/file-uploading/fileUploadingSchemas.d.ts +24 -0
- package/esm/file-uploading/fileUploadingSchemas.js +19 -0
- package/esm/filters/filtersApi.d.ts +32 -0
- package/esm/filters/filtersApi.js +36 -0
- package/esm/filters/filtersInterfaces.d.ts +56 -0
- package/esm/filters/filtersInterfaces.js +1 -0
- package/esm/filters/filtersSchemas.d.ts +32 -0
- package/esm/filters/filtersSchemas.js +29 -0
- package/esm/forms/formsApi.d.ts +44 -0
- package/esm/forms/formsApi.js +54 -0
- package/esm/forms/formsInterfaces.d.ts +237 -0
- package/esm/forms/formsInterfaces.js +1 -0
- package/esm/forms/formsSchemas.d.ts +56 -0
- package/esm/forms/formsSchemas.js +32 -0
- package/esm/forms-data/formsDataApi.d.ts +124 -0
- package/esm/forms-data/formsDataApi.js +210 -0
- package/esm/forms-data/formsDataInterfaces.d.ts +670 -0
- package/esm/forms-data/formsDataInterfaces.js +1 -0
- package/esm/forms-data/formsDataSchemas.d.ts +107 -0
- package/esm/forms-data/formsDataSchemas.js +83 -0
- package/esm/general-types/generalTypesApi.d.ts +29 -0
- package/esm/general-types/generalTypesApi.js +34 -0
- package/esm/general-types/generalTypesInterfaces.d.ts +29 -0
- package/esm/general-types/generalTypesInterfaces.js +1 -0
- package/esm/general-types/generalTypesSchemas.d.ts +68 -0
- package/esm/general-types/generalTypesSchemas.js +42 -0
- package/esm/index.d.ts +143 -0
- package/esm/index.js +124 -0
- package/esm/integration-collections/integrationCollectionsApi.d.ts +172 -0
- package/esm/integration-collections/integrationCollectionsApi.js +224 -0
- package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +317 -0
- package/esm/integration-collections/integrationCollectionsInterfaces.js +1 -0
- package/esm/integration-collections/integrationCollectionsSchemas.d.ts +84 -0
- package/esm/integration-collections/integrationCollectionsSchemas.js +60 -0
- package/esm/locales/localesApi.d.ts +28 -0
- package/esm/locales/localesApi.js +33 -0
- package/esm/locales/localesInterfaces.d.ts +40 -0
- package/esm/locales/localesInterfaces.js +1 -0
- package/esm/locales/localesSchemas.d.ts +32 -0
- package/esm/locales/localesSchemas.js +23 -0
- package/esm/menus/menusApi.d.ts +30 -0
- package/esm/menus/menusApi.js +35 -0
- package/esm/menus/menusInterfaces.d.ts +87 -0
- package/esm/menus/menusInterfaces.js +2 -0
- package/esm/menus/menusSchemas.d.ts +16 -0
- package/esm/menus/menusSchemas.js +25 -0
- package/esm/orders/ordersApi.d.ts +213 -0
- package/esm/orders/ordersApi.js +288 -0
- package/esm/orders/ordersInterfaces.d.ts +763 -0
- package/esm/orders/ordersInterfaces.js +1 -0
- package/esm/orders/ordersSchemas.d.ts +312 -0
- package/esm/orders/ordersSchemas.js +171 -0
- package/esm/package.json +4 -0
- package/esm/pages/pagesApi.d.ts +173 -0
- package/esm/pages/pagesApi.js +414 -0
- package/esm/pages/pagesInterfaces.d.ts +344 -0
- package/esm/pages/pagesInterfaces.js +1 -0
- package/esm/pages/pagesSchemas.d.ts +121 -0
- package/esm/pages/pagesSchemas.js +60 -0
- package/esm/payments/paymentsApi.d.ts +88 -0
- package/esm/payments/paymentsApi.js +122 -0
- package/esm/payments/paymentsInterfaces.d.ts +189 -0
- package/esm/payments/paymentsInterfaces.js +1 -0
- package/esm/payments/paymentsSchemas.d.ts +94 -0
- package/esm/payments/paymentsSchemas.js +53 -0
- package/esm/product-statuses/productStatusesApi.d.ts +50 -0
- package/esm/product-statuses/productStatusesApi.js +68 -0
- package/esm/product-statuses/productStatusesInterfaces.d.ts +62 -0
- package/esm/product-statuses/productStatusesInterfaces.js +1 -0
- package/esm/product-statuses/productStatusesSchemas.d.ts +34 -0
- package/esm/product-statuses/productStatusesSchemas.js +27 -0
- package/esm/products/productsApi.d.ts +366 -0
- package/esm/products/productsApi.js +468 -0
- package/esm/products/productsInterfaces.d.ts +723 -0
- package/esm/products/productsInterfaces.js +1 -0
- package/esm/products/productsSchemas.d.ts +234 -0
- package/esm/products/productsSchemas.js +121 -0
- package/esm/search/searchApi.d.ts +35 -0
- package/esm/search/searchApi.js +47 -0
- package/esm/search/searchInterfaces.d.ts +94 -0
- package/esm/search/searchInterfaces.js +1 -0
- package/esm/search/searchSchemas.d.ts +73 -0
- package/esm/search/searchSchemas.js +41 -0
- package/esm/sitemap/sitemapApi.d.ts +37 -0
- package/esm/sitemap/sitemapApi.js +41 -0
- package/esm/sitemap/sitemapInterfaces.d.ts +51 -0
- package/esm/sitemap/sitemapInterfaces.js +1 -0
- package/esm/subscriptions/subscriptionsApi.d.ts +74 -0
- package/esm/subscriptions/subscriptionsApi.js +90 -0
- package/esm/subscriptions/subscriptionsInterfaces.d.ts +111 -0
- package/esm/subscriptions/subscriptionsInterfaces.js +1 -0
- package/esm/subscriptions/subscriptionsSchemas.d.ts +46 -0
- package/esm/subscriptions/subscriptionsSchemas.js +38 -0
- package/esm/system/systemApi.d.ts +46 -0
- package/esm/system/systemApi.js +53 -0
- package/esm/system/systemInterfaces.d.ts +29 -0
- package/esm/system/systemInterfaces.js +1 -0
- package/esm/templates/templatesApi.d.ts +53 -0
- package/esm/templates/templatesApi.js +78 -0
- package/esm/templates/templatesInterfaces.d.ts +68 -0
- package/esm/templates/templatesInterfaces.js +1 -0
- package/esm/templates/templatesSchemas.d.ts +48 -0
- package/esm/templates/templatesSchemas.js +28 -0
- package/esm/templates-preview/templatesPreviewApi.d.ts +40 -0
- package/esm/templates-preview/templatesPreviewApi.js +50 -0
- package/esm/templates-preview/templatesPreviewInterfaces.d.ts +129 -0
- package/esm/templates-preview/templatesPreviewInterfaces.js +1 -0
- package/esm/templates-preview/templatesPreviewSchemas.d.ts +79 -0
- package/esm/templates-preview/templatesPreviewSchemas.js +43 -0
- package/esm/types.d.ts +35 -0
- package/esm/types.js +1 -0
- package/esm/user-activity/userActivityApi.d.ts +31 -0
- package/esm/user-activity/userActivityApi.js +37 -0
- package/esm/user-activity/userActivityInterfaces.d.ts +42 -0
- package/esm/user-activity/userActivityInterfaces.js +1 -0
- package/esm/users/usersApi.d.ts +249 -0
- package/esm/users/usersApi.js +312 -0
- package/esm/users/usersInterfaces.d.ts +419 -0
- package/esm/users/usersInterfaces.js +1 -0
- package/esm/users/usersSchemas.d.ts +72 -0
- package/esm/users/usersSchemas.js +55 -0
- package/esm/web-socket/lazySocket.d.ts +18 -0
- package/esm/web-socket/lazySocket.js +67 -0
- package/esm/web-socket/wsApi.d.ts +27 -0
- package/esm/web-socket/wsApi.js +43 -0
- package/esm/web-socket/wsInterfaces.d.ts +16 -0
- package/esm/web-socket/wsInterfaces.js +1 -0
- package/package.json +47 -2
- package/types.d.ts +1 -0
- package/types.js +1 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules.js';
|
|
2
|
+
import type StateModule from '../base/stateModule.js';
|
|
3
|
+
import type { IError } from '../base/utils.js';
|
|
4
|
+
import type { IBonusBalanceEntity, IBonusTransactionEntity, IBonusTransactionType, ICouponValidationResult, IDiscountsApi, IDiscountsEntity, IDiscountsResponse, IDiscountsVectorSearch, IDiscountType } from './discountsInterfaces.js';
|
|
5
|
+
/**
|
|
6
|
+
* Controllers for working with events
|
|
7
|
+
* @handle /api/content/events
|
|
8
|
+
* @class DiscountsApi
|
|
9
|
+
* @augments AsyncModules
|
|
10
|
+
* @implements {IDiscountsApi}
|
|
11
|
+
* @description This class provides methods to interact with events, including subscribing and unsubscribing to product events, and retrieving all subscriptions.
|
|
12
|
+
*/
|
|
13
|
+
export default class DiscountsApi extends AsyncModules implements IDiscountsApi {
|
|
14
|
+
protected state: StateModule;
|
|
15
|
+
protected _url: string;
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the Constructor for DiscountsApi class with the provided state module.
|
|
18
|
+
* @class DiscountsApi
|
|
19
|
+
* @augments AsyncModules
|
|
20
|
+
* @implements {DiscountsApi}
|
|
21
|
+
* @param {StateModule} state - The state module containing the base URL and other configurations.
|
|
22
|
+
* @description Initializes the DiscountsApi with the provided state module.
|
|
23
|
+
*/
|
|
24
|
+
constructor(state: StateModule);
|
|
25
|
+
/**
|
|
26
|
+
* Return all discounts.
|
|
27
|
+
* @handleName getAllDiscounts
|
|
28
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
29
|
+
* @param {number} [offset] - Optional parameter for pagination. Default: 0.
|
|
30
|
+
* @param {number} [limit] - Optional parameter for pagination. Default: 30.
|
|
31
|
+
* @param {IDiscountType} [type] - Optional parameter to filter discounts by type.
|
|
32
|
+
* @returns {Promise<IDiscountsResponse | IError>} Returns an object containing all discounts or an error object if there was an issue.
|
|
33
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
34
|
+
* @description Fetches all discounts from the server.
|
|
35
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getAllDiscounts getAllDiscounts} documentation.
|
|
36
|
+
*/
|
|
37
|
+
getAllDiscounts(langCode?: string, offset?: number, limit?: number, type?: IDiscountType): Promise<IDiscountsResponse | IError>;
|
|
38
|
+
/**
|
|
39
|
+
* Get discount by marker
|
|
40
|
+
* @handleName getDiscountByMarker
|
|
41
|
+
* @param {string} marker - Textual identifier of the discount storage object. Example: "discount_storage".
|
|
42
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
43
|
+
* @returns {Promise<IDiscountsEntity | IError>} Returns an object containing discount by marker or an error object if there was an issue.
|
|
44
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
45
|
+
* @description Fetches a discount by its marker.
|
|
46
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getDiscountByMarker getDiscountByMarker} documentation.
|
|
47
|
+
*/
|
|
48
|
+
getDiscountByMarker(marker: string, langCode?: string): Promise<IDiscountsEntity | IError>;
|
|
49
|
+
/**
|
|
50
|
+
* Get bonus balance of the current user.
|
|
51
|
+
* @handleName getBonusBalance
|
|
52
|
+
* @returns {Promise<IBonusBalanceEntity | IError>} Returns bonus balance or an error object.
|
|
53
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
54
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getBonusBalance getBonusBalance} documentation.
|
|
55
|
+
*/
|
|
56
|
+
getBonusBalance(): Promise<IBonusBalanceEntity | IError>;
|
|
57
|
+
/**
|
|
58
|
+
* Get bonus transaction history of the current user.
|
|
59
|
+
* @handleName getBonusHistory
|
|
60
|
+
* @param {IBonusTransactionType} [type] - Transaction type filter.
|
|
61
|
+
* @param {string} [dateFrom] - Start date filter.
|
|
62
|
+
* @param {string} [dateTo] - End date filter.
|
|
63
|
+
* @param {number} [discountId] - Discount id filter.
|
|
64
|
+
* @param {number} [moduleId] - Module id filter.
|
|
65
|
+
* @param {boolean} [isAdmin] - Admin filter.
|
|
66
|
+
* @returns {Promise<IBonusTransactionEntity[] | IError>} Returns array of bonus transactions or an error object.
|
|
67
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
68
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getBonusHistory getBonusHistory} documentation.
|
|
69
|
+
*/
|
|
70
|
+
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<IBonusTransactionEntity[] | IError>;
|
|
71
|
+
/**
|
|
72
|
+
* Validate discounts coupon
|
|
73
|
+
* @handleName validateDiscountsCoupon
|
|
74
|
+
* @param {string} code - The coupon code to validate.
|
|
75
|
+
* @returns {Promise<ICouponValidationResult | IError>} Returns an coupon validation result or an error object if there was an issue.
|
|
76
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
77
|
+
* @description This function validates a coupon code and returns the result.
|
|
78
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/validateDiscountsCoupon validateDiscountsCoupon} documentation.
|
|
79
|
+
*/
|
|
80
|
+
validateDiscountsCoupon(code: string): Promise<ICouponValidationResult | IError>;
|
|
81
|
+
/**
|
|
82
|
+
* Semantic (vector) search for discounts.
|
|
83
|
+
* @handleName getDiscountsByVectorSearch
|
|
84
|
+
* @param {IDiscountsVectorSearch} body - Vector search body. Example: `{ queryText: "winter sale" }`.
|
|
85
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
86
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
87
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
88
|
+
* @returns {Promise<IDiscountsResponse | IError>} Returns an object with an array of found discounts and total count.
|
|
89
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
90
|
+
* @description This method performs a semantic (vector) search for discounts.
|
|
91
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getDiscountsByVectorSearch getDiscountsByVectorSearch} documentation.
|
|
92
|
+
*/
|
|
93
|
+
getDiscountsByVectorSearch(body: IDiscountsVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IDiscountsResponse | IError>;
|
|
94
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules.js';
|
|
2
|
+
/**
|
|
3
|
+
* Controllers for working with events
|
|
4
|
+
* @handle /api/content/events
|
|
5
|
+
* @class DiscountsApi
|
|
6
|
+
* @augments AsyncModules
|
|
7
|
+
* @implements {IDiscountsApi}
|
|
8
|
+
* @description This class provides methods to interact with events, including subscribing and unsubscribing to product events, and retrieving all subscriptions.
|
|
9
|
+
*/
|
|
10
|
+
export default class DiscountsApi extends AsyncModules {
|
|
11
|
+
/**
|
|
12
|
+
* Initializes the Constructor for DiscountsApi class with the provided state module.
|
|
13
|
+
* @class DiscountsApi
|
|
14
|
+
* @augments AsyncModules
|
|
15
|
+
* @implements {DiscountsApi}
|
|
16
|
+
* @param {StateModule} state - The state module containing the base URL and other configurations.
|
|
17
|
+
* @description Initializes the DiscountsApi with the provided state module.
|
|
18
|
+
*/
|
|
19
|
+
constructor(state) {
|
|
20
|
+
super(state);
|
|
21
|
+
this._url = state.url + '/api/content/discounts';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Return all discounts.
|
|
25
|
+
* @handleName getAllDiscounts
|
|
26
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
27
|
+
* @param {number} [offset] - Optional parameter for pagination. Default: 0.
|
|
28
|
+
* @param {number} [limit] - Optional parameter for pagination. Default: 30.
|
|
29
|
+
* @param {IDiscountType} [type] - Optional parameter to filter discounts by type.
|
|
30
|
+
* @returns {Promise<IDiscountsResponse | IError>} Returns an object containing all discounts or an error object if there was an issue.
|
|
31
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
32
|
+
* @description Fetches all discounts from the server.
|
|
33
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getAllDiscounts getAllDiscounts} documentation.
|
|
34
|
+
*/
|
|
35
|
+
async getAllDiscounts(langCode = this.state.lang, offset = 0, limit = 30, type) {
|
|
36
|
+
const query = {
|
|
37
|
+
langCode,
|
|
38
|
+
offset,
|
|
39
|
+
limit,
|
|
40
|
+
type,
|
|
41
|
+
};
|
|
42
|
+
const data = await this._fetchGet(`?` + this._queryParamsToString(query));
|
|
43
|
+
return this._normalizeData(data);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get discount by marker
|
|
47
|
+
* @handleName getDiscountByMarker
|
|
48
|
+
* @param {string} marker - Textual identifier of the discount storage object. Example: "discount_storage".
|
|
49
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
50
|
+
* @returns {Promise<IDiscountsEntity | IError>} Returns an object containing discount by marker or an error object if there was an issue.
|
|
51
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
52
|
+
* @description Fetches a discount by its marker.
|
|
53
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getDiscountByMarker getDiscountByMarker} documentation.
|
|
54
|
+
*/
|
|
55
|
+
async getDiscountByMarker(marker, langCode = this.state.lang) {
|
|
56
|
+
const query = {
|
|
57
|
+
marker: '',
|
|
58
|
+
langCode,
|
|
59
|
+
};
|
|
60
|
+
const data = await this._fetchGet(`/marker/${marker}?` + this._queryParamsToString(query));
|
|
61
|
+
return this._normalizeData(data);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get bonus balance of the current user.
|
|
65
|
+
* @handleName getBonusBalance
|
|
66
|
+
* @returns {Promise<IBonusBalanceEntity | IError>} Returns bonus balance or an error object.
|
|
67
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
68
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getBonusBalance getBonusBalance} documentation.
|
|
69
|
+
*/
|
|
70
|
+
async getBonusBalance() {
|
|
71
|
+
const data = await this._fetchGet(`/bonus-balance`);
|
|
72
|
+
return this._normalizeData(data);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get bonus transaction history of the current user.
|
|
76
|
+
* @handleName getBonusHistory
|
|
77
|
+
* @param {IBonusTransactionType} [type] - Transaction type filter.
|
|
78
|
+
* @param {string} [dateFrom] - Start date filter.
|
|
79
|
+
* @param {string} [dateTo] - End date filter.
|
|
80
|
+
* @param {number} [discountId] - Discount id filter.
|
|
81
|
+
* @param {number} [moduleId] - Module id filter.
|
|
82
|
+
* @param {boolean} [isAdmin] - Admin filter.
|
|
83
|
+
* @returns {Promise<IBonusTransactionEntity[] | IError>} Returns array of bonus transactions or an error object.
|
|
84
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
85
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getBonusHistory getBonusHistory} documentation.
|
|
86
|
+
*/
|
|
87
|
+
async getBonusHistory(type, dateFrom, dateTo, discountId, moduleId, isAdmin) {
|
|
88
|
+
const query = {
|
|
89
|
+
type,
|
|
90
|
+
dateFrom,
|
|
91
|
+
dateTo,
|
|
92
|
+
discountId,
|
|
93
|
+
moduleId,
|
|
94
|
+
isAdmin,
|
|
95
|
+
};
|
|
96
|
+
const data = await this._fetchGet(`/bonus-balance/history?` + this._queryParamsToString(query));
|
|
97
|
+
return this._normalizeData(data);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Validate discounts coupon
|
|
101
|
+
* @handleName validateDiscountsCoupon
|
|
102
|
+
* @param {string} code - The coupon code to validate.
|
|
103
|
+
* @returns {Promise<ICouponValidationResult | IError>} Returns an coupon validation result or an error object if there was an issue.
|
|
104
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
105
|
+
* @description This function validates a coupon code and returns the result.
|
|
106
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/validateDiscountsCoupon validateDiscountsCoupon} documentation.
|
|
107
|
+
*/
|
|
108
|
+
async validateDiscountsCoupon(code) {
|
|
109
|
+
const query = {
|
|
110
|
+
code,
|
|
111
|
+
};
|
|
112
|
+
const data = await this._fetchGet(`/coupons/validate?` + this._queryParamsToString(query));
|
|
113
|
+
return this._normalizeData(data);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Semantic (vector) search for discounts.
|
|
117
|
+
* @handleName getDiscountsByVectorSearch
|
|
118
|
+
* @param {IDiscountsVectorSearch} body - Vector search body. Example: `{ queryText: "winter sale" }`.
|
|
119
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
120
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
121
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
122
|
+
* @returns {Promise<IDiscountsResponse | IError>} Returns an object with an array of found discounts and total count.
|
|
123
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
124
|
+
* @description This method performs a semantic (vector) search for discounts.
|
|
125
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/discounts/getDiscountsByVectorSearch getDiscountsByVectorSearch} documentation.
|
|
126
|
+
*/
|
|
127
|
+
async getDiscountsByVectorSearch(body, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
128
|
+
const query = {
|
|
129
|
+
langCode,
|
|
130
|
+
offset,
|
|
131
|
+
limit,
|
|
132
|
+
};
|
|
133
|
+
const data = await this._fetchPost(`/vector/search?` + this._queryParamsToString(query), body);
|
|
134
|
+
return this._normalizeData(data, langCode);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import type { IAttributeValues, IError, ILocalizeInfo } from '../base/utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* Discount type.
|
|
4
|
+
*/
|
|
5
|
+
type IDiscountType = 'DISCOUNT' | 'BONUS' | 'PERSONAL_DISCOUNT';
|
|
6
|
+
/**
|
|
7
|
+
* Interface for the Discounts API module.
|
|
8
|
+
* @interface IDiscountsApi
|
|
9
|
+
*/
|
|
10
|
+
interface IDiscountsApi {
|
|
11
|
+
/**
|
|
12
|
+
* Return all discounts.
|
|
13
|
+
* @handleName getAllSubscriptions
|
|
14
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
15
|
+
* @param {number} [offset] - Optional parameter for pagination. Default: 0.
|
|
16
|
+
* @param {number} [limit] - Optional parameter for pagination. Default: 30.
|
|
17
|
+
* @param {IDiscountType} [type] - Optional parameter to filter discounts by type.
|
|
18
|
+
* @returns {Promise<IDiscountsResponse | IError>} Returns an object containing all discounts or an error object if there was an issue.
|
|
19
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
20
|
+
* @description Fetches all discounts from the server.
|
|
21
|
+
*/
|
|
22
|
+
getAllDiscounts(langCode?: string, offset?: number, limit?: number, type?: IDiscountType): Promise<IDiscountsResponse | IError>;
|
|
23
|
+
/**
|
|
24
|
+
* Get discount by marker
|
|
25
|
+
* @handleName getDiscountByMarker
|
|
26
|
+
* @param {string} marker - Textual identifier of the discount storage object. Example: "discount_storage".
|
|
27
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
28
|
+
* @returns {Promise<IDiscountsEntity | IError>} Returns an object containing discount by marker or an error object if there was an issue.
|
|
29
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
30
|
+
* @description Fetches a discount by its marker.
|
|
31
|
+
*/
|
|
32
|
+
getDiscountByMarker(marker: string, langCode: string): Promise<IDiscountsEntity | IError>;
|
|
33
|
+
/**
|
|
34
|
+
* Validate discounts coupon
|
|
35
|
+
* @handleName validateDiscountsCoupon
|
|
36
|
+
* @param {string} code - The coupon code to validate.
|
|
37
|
+
* @returns {Promise<ICouponValidationResult | IError>} Returns an coupon validation result or an error object if there was an issue.
|
|
38
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
39
|
+
* @description This function validates a coupon code and returns the result.
|
|
40
|
+
*/
|
|
41
|
+
validateDiscountsCoupon(code: string): Promise<ICouponValidationResult | IError>;
|
|
42
|
+
/**
|
|
43
|
+
* Get bonus balance of the current user.
|
|
44
|
+
* @handleName getBonusBalance
|
|
45
|
+
* @returns {Promise<IBonusBalanceEntity | IError>} Returns bonus balance or an error object.
|
|
46
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
47
|
+
*/
|
|
48
|
+
getBonusBalance(): Promise<IBonusBalanceEntity | IError>;
|
|
49
|
+
/**
|
|
50
|
+
* Get bonus transaction history of the current user.
|
|
51
|
+
* @handleName getBonusHistory
|
|
52
|
+
* @param {string} [type] - Transaction type filter.
|
|
53
|
+
* @param {string} [dateFrom] - Start date filter.
|
|
54
|
+
* @param {string} [dateTo] - End date filter.
|
|
55
|
+
* @param {number} [discountId] - Discount id filter.
|
|
56
|
+
* @param {number} [moduleId] - Module id filter.
|
|
57
|
+
* @param {boolean} [isAdmin] - Admin filter.
|
|
58
|
+
* @returns {Promise<IBonusTransactionEntity[] | IError>} Returns array of bonus transactions or an error object.
|
|
59
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
60
|
+
*/
|
|
61
|
+
getBonusHistory(type?: IBonusTransactionType, dateFrom?: string, dateTo?: string, discountId?: number, moduleId?: number, isAdmin?: boolean): Promise<IBonusTransactionEntity[] | IError>;
|
|
62
|
+
/**
|
|
63
|
+
* Semantic (vector) search for discounts.
|
|
64
|
+
* @handleName getDiscountsByVectorSearch
|
|
65
|
+
* @param {IDiscountsVectorSearch} body - Vector search body. Example: `{ queryText: "winter sale" }`.
|
|
66
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
67
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
68
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
69
|
+
* @returns {Promise<IDiscountsResponse | IError>} Returns an object with an array of found discounts and total count.
|
|
70
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
71
|
+
*/
|
|
72
|
+
getDiscountsByVectorSearch(body: IDiscountsVectorSearch, langCode?: string, offset?: number, limit?: number): Promise<IDiscountsResponse | IError>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Body for semantic (vector) discount search.
|
|
76
|
+
* @interface IDiscountsVectorSearch
|
|
77
|
+
* @property {string} queryText - Natural-language search query. Example: "winter sale".
|
|
78
|
+
* @property {number} [vectorDistanceThreshold] - Override of the cosine distance threshold (0..2). Example: 0.3.
|
|
79
|
+
* @property {number} [maxHits] - Top-K candidates fetched before pagination. Default: 100. Max: 500. Example: 10.
|
|
80
|
+
* @property {boolean} [debug] - When true, each returned item gets a `distance` field. Example: false.
|
|
81
|
+
* @description Body for the discounts vector/search endpoint.
|
|
82
|
+
*/
|
|
83
|
+
interface IDiscountsVectorSearch {
|
|
84
|
+
queryText: string;
|
|
85
|
+
vectorDistanceThreshold?: number;
|
|
86
|
+
maxHits?: number;
|
|
87
|
+
debug?: boolean;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Query parameters for fetching discounts.
|
|
91
|
+
* @interface IDiscountsQuery
|
|
92
|
+
* @property {IDiscountType} [type] - Filter discounts by type.
|
|
93
|
+
* @property {string} langCode - The language code for localization. Example: "en_US".
|
|
94
|
+
* @property {number} [offset] - Offset for pagination. Default: 0.
|
|
95
|
+
* @property {number} [limit] - Limit for pagination. Default: 30.
|
|
96
|
+
*/
|
|
97
|
+
interface IDiscountsQuery {
|
|
98
|
+
type?: IDiscountType;
|
|
99
|
+
langCode: string;
|
|
100
|
+
offset?: number;
|
|
101
|
+
limit?: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Represents a discount condition.
|
|
105
|
+
* @interface IDiscountCondition
|
|
106
|
+
* @property {string} type - The type of discount condition.
|
|
107
|
+
* @property {string} [value] - The value associated with the discount condition.
|
|
108
|
+
*/
|
|
109
|
+
interface IDiscountCondition {
|
|
110
|
+
type: 'PRODUCT' | 'CATEGORY' | 'ATTRIBUTE' | 'PRODUCT_IN_CART' | 'CATEGORY_IN_CART' | 'MIN_CART_AMOUNT' | 'USER_LTV' | 'USER_ATTRIBUTE';
|
|
111
|
+
value: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Represents a discount entity.
|
|
115
|
+
* @interface IDiscountsEntity
|
|
116
|
+
* @property {number} id - The unique identifier of the discount.
|
|
117
|
+
* @property {number | null} [attributeSetId] - The identifier of the attribute set linked to the discount, or `null` when no set is linked.
|
|
118
|
+
* @property {ILocalizeInfo} [localizeInfos] - The name of the discount.
|
|
119
|
+
* @property {number} [version] - The version of the discount.
|
|
120
|
+
* @property {string} [identifier] - The identifier of the discount.
|
|
121
|
+
* @property {IDiscountType} type - The type of the discount.
|
|
122
|
+
* @property {string} [startDate] - The start date of the discount.
|
|
123
|
+
* @property {string} [endDate] - The end date of the discount.
|
|
124
|
+
* @property {IDiscountValue} [discountValue] - The value of the discount, including its type and amount limits.
|
|
125
|
+
* @property {string} [conditionLogic] - The logic of the discount. Possible values are "AND" | "OR".
|
|
126
|
+
* @property {IDiscountCondition[]} [conditions] - The conditions of the discount.
|
|
127
|
+
* @property {Record<string, unknown> | null} [exclusions] - The exclusions of the discount.
|
|
128
|
+
* @property {Record<string, unknown> | null} [gifts] - The gifts of the discount.
|
|
129
|
+
* @property {boolean} [giftsReplaceCartItems] - Whether the gifts replace cart items.
|
|
130
|
+
* @property {Record<string, unknown> | null} [userGroups] - The user groups of the discount.
|
|
131
|
+
* @property {Record<string, unknown> | null} [userExclusions] - The user exclusions of the discount.
|
|
132
|
+
* @property {IAttributeValues} [attributeValues] - The attribute values of the discount.
|
|
133
|
+
* @property {string} [attributeSetIdentifier] - The identifier of the attribute set.
|
|
134
|
+
* @property {Record<string, unknown>} [bonusEvent] - Bonus event configuration.
|
|
135
|
+
* @property {number} [position] - Position number for sorting. Example: 1.
|
|
136
|
+
* @property {number | string} [total] - Total count of related entries. Example: "1".
|
|
137
|
+
*/
|
|
138
|
+
interface IDiscountsEntity {
|
|
139
|
+
id: number;
|
|
140
|
+
attributeSetId?: number | null;
|
|
141
|
+
localizeInfos?: ILocalizeInfo;
|
|
142
|
+
version?: number;
|
|
143
|
+
identifier?: string;
|
|
144
|
+
type: IDiscountType;
|
|
145
|
+
startDate?: string;
|
|
146
|
+
endDate?: string;
|
|
147
|
+
discountValue?: IDiscountValue;
|
|
148
|
+
conditionLogic?: 'AND' | 'OR';
|
|
149
|
+
conditions?: IDiscountCondition[];
|
|
150
|
+
exclusions?: Record<string, unknown> | null;
|
|
151
|
+
gifts?: Record<string, unknown> | null;
|
|
152
|
+
giftsReplaceCartItems?: boolean;
|
|
153
|
+
userGroups?: Record<string, unknown> | null;
|
|
154
|
+
userExclusions?: Record<string, unknown> | null;
|
|
155
|
+
attributeValues?: IAttributeValues;
|
|
156
|
+
attributeSetIdentifier?: string;
|
|
157
|
+
bonusEvent?: Record<string, unknown> | null;
|
|
158
|
+
position?: number;
|
|
159
|
+
total?: number | string;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* @interface IDiscountValue
|
|
163
|
+
* @property {'TO_PRODUCT' | 'TO_ORDER'} applicability - What the discount applies to. Example: "TO_PRODUCT".
|
|
164
|
+
* @property {'FIXED_AMOUNT' | 'PERCENT'} discountType - How the discount value is interpreted. Example: "FIXED_AMOUNT".
|
|
165
|
+
* @property {number} value - Discount amount (currency units for FIXED_AMOUNT, percentage points for PERCENT). Example: 10.
|
|
166
|
+
* @property {number | null} [maxAmount] - Cap on the absolute discount applied, or `null` when uncapped. Example: 5.
|
|
167
|
+
* @description Configuration of the discount calculation.
|
|
168
|
+
*/
|
|
169
|
+
interface IDiscountValue {
|
|
170
|
+
applicability: 'TO_PRODUCT' | 'TO_ORDER';
|
|
171
|
+
discountType: 'FIXED_AMOUNT' | 'PERCENT';
|
|
172
|
+
value: number;
|
|
173
|
+
maxAmount?: number | null;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* @interface ICouponEntity
|
|
177
|
+
* @property {number} id - Coupon record id. Example: 1.
|
|
178
|
+
* @property {number} discountId - Discount the coupon belongs to. Example: 1.
|
|
179
|
+
* @property {string} code - Coupon code. Example: "SUMMER-KBWZ-2428".
|
|
180
|
+
* @property {boolean} isReusable - Whether the coupon can be used more than once. Example: false.
|
|
181
|
+
* @property {boolean} isUsed - Whether the coupon has already been used. Example: false.
|
|
182
|
+
* @property {number | null} orderId - Order id where the coupon was applied, or null. Example: null.
|
|
183
|
+
* @property {string | null} usedAt - When the coupon was used, or null. Example: null.
|
|
184
|
+
* @description Coupon entity returned by the discounts API.
|
|
185
|
+
*/
|
|
186
|
+
interface ICouponEntity {
|
|
187
|
+
id: number;
|
|
188
|
+
discountId: number;
|
|
189
|
+
code: string;
|
|
190
|
+
isReusable: boolean;
|
|
191
|
+
isUsed: boolean;
|
|
192
|
+
orderId: number | null;
|
|
193
|
+
usedAt: string | null;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Paginated response for discounts list.
|
|
197
|
+
* @interface IDiscountsResponse
|
|
198
|
+
* @property {IDiscountsEntity[]} items - Array of discount entities.
|
|
199
|
+
* @property {number} total - Total number of discounts.
|
|
200
|
+
*/
|
|
201
|
+
interface IDiscountsResponse {
|
|
202
|
+
items: IDiscountsEntity[];
|
|
203
|
+
total: number;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Request body for coupon validation.
|
|
207
|
+
* @interface IDiscountsValidateCoupon
|
|
208
|
+
* @property {string} code - The coupon code to validate.
|
|
209
|
+
*/
|
|
210
|
+
interface IDiscountsValidateCoupon {
|
|
211
|
+
code: string;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Result of coupon validation.
|
|
215
|
+
* @interface ICouponValidationResult
|
|
216
|
+
* @property {boolean} valid - Whether the coupon is valid.
|
|
217
|
+
* @property {ICouponEntity} [coupon] - Coupon data if the coupon is valid.
|
|
218
|
+
* @property {string} [error] - Error message if the coupon is invalid.
|
|
219
|
+
*/
|
|
220
|
+
interface ICouponValidationResult {
|
|
221
|
+
valid: boolean;
|
|
222
|
+
coupon?: ICouponEntity;
|
|
223
|
+
error?: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Query parameters for fetching a discount by marker.
|
|
227
|
+
* @interface IDiscountByMarkerQuery
|
|
228
|
+
* @property {string} langCode - The language code for localization. Example: "en_US".
|
|
229
|
+
* @property {string} marker - Textual identifier of the discount. Example: "example_discount".
|
|
230
|
+
*/
|
|
231
|
+
interface IDiscountByMarkerQuery {
|
|
232
|
+
langCode: string;
|
|
233
|
+
marker: string;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
*
|
|
237
|
+
*/
|
|
238
|
+
type IBonusTransactionType = 'ACCRUAL' | 'USAGE' | 'REDUCE' | 'REVERSAL_ACCRUAL' | 'REVERSAL_USAGE' | 'EXPIRATION';
|
|
239
|
+
/**
|
|
240
|
+
* @interface IBonusHistoryQuery
|
|
241
|
+
* @property {IBonusTransactionType} [type] - Transaction type filter.
|
|
242
|
+
* @property {string} [dateFrom] - Start date filter.
|
|
243
|
+
* @property {string} [dateTo] - End date filter.
|
|
244
|
+
* @property {number} [discountId] - Discount id filter.
|
|
245
|
+
* @property {number} [moduleId] - Module id filter.
|
|
246
|
+
* @property {boolean} [isAdmin] - Admin filter.
|
|
247
|
+
*/
|
|
248
|
+
interface IBonusHistoryQuery {
|
|
249
|
+
type?: IBonusTransactionType;
|
|
250
|
+
dateFrom?: string;
|
|
251
|
+
dateTo?: string;
|
|
252
|
+
discountId?: number;
|
|
253
|
+
moduleId?: number;
|
|
254
|
+
isAdmin?: boolean;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* @interface IBonusTransactionEntity
|
|
258
|
+
* @property {number} balanceId - Balance id.
|
|
259
|
+
* @property {number} amount - Transaction amount.
|
|
260
|
+
* @property {IBonusTransactionType} type - Transaction type.
|
|
261
|
+
* @property {number} [discountId] - Discount id.
|
|
262
|
+
* @property {number} [moduleId] - Module id.
|
|
263
|
+
* @property {string} [entityIdentifier] - Entity identifier.
|
|
264
|
+
* @property {string} [comment] - Comment.
|
|
265
|
+
* @property {boolean} isAdmin - Admin flag.
|
|
266
|
+
* @property {number} [remainingAmount] - Remaining amount.
|
|
267
|
+
* @property {'EVENT' | 'SCHEDULED'} [triggerType] - Trigger type.
|
|
268
|
+
* @property {string} [expiresAt] - Expiration date.
|
|
269
|
+
* @property {string} [createdAt] - Creation date.
|
|
270
|
+
*/
|
|
271
|
+
interface IBonusTransactionEntity {
|
|
272
|
+
balanceId: number;
|
|
273
|
+
amount: number;
|
|
274
|
+
type: IBonusTransactionType;
|
|
275
|
+
discountId?: number;
|
|
276
|
+
moduleId?: number;
|
|
277
|
+
entityIdentifier?: string;
|
|
278
|
+
comment?: string;
|
|
279
|
+
isAdmin: boolean;
|
|
280
|
+
remainingAmount?: number;
|
|
281
|
+
triggerType?: 'EVENT' | 'SCHEDULED';
|
|
282
|
+
expiresAt?: string;
|
|
283
|
+
createdAt?: string;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* @interface IBonusBalanceEntity
|
|
287
|
+
* @description Represents the balance of bonus points.
|
|
288
|
+
* @property {number} balance - The balance of bonus points. Example: 100
|
|
289
|
+
*/
|
|
290
|
+
interface IBonusBalanceEntity {
|
|
291
|
+
balance: number;
|
|
292
|
+
}
|
|
293
|
+
export type { IBonusBalanceEntity, IBonusHistoryQuery, IBonusTransactionEntity, IBonusTransactionType, ICouponEntity, ICouponValidationResult, IDiscountByMarkerQuery, IDiscountCondition, IDiscountsApi, IDiscountsEntity, IDiscountsQuery, IDiscountsResponse, IDiscountsValidateCoupon, IDiscountsVectorSearch, IDiscountType, IDiscountValue, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules.js';
|
|
2
|
+
import type StateModule from '../base/stateModule.js';
|
|
3
|
+
import type { IError } from '../base/utils.js';
|
|
4
|
+
import type { IContentApiEvent, IEvents, IFormSubscriptionsResponse, ISubscribeFormEvent, ISubscriptions } from './eventsInterfaces.js';
|
|
5
|
+
/**
|
|
6
|
+
* Controllers for working with events
|
|
7
|
+
* @handle /api/content/events
|
|
8
|
+
* @class EventsApi
|
|
9
|
+
* @augments AsyncModules
|
|
10
|
+
* @implements {IEvents}
|
|
11
|
+
* @description This class provides methods to interact with events, including subscribing and unsubscribing to product events, and retrieving all subscriptions.
|
|
12
|
+
*/
|
|
13
|
+
export default class EventsApi extends AsyncModules implements IEvents {
|
|
14
|
+
protected state: StateModule;
|
|
15
|
+
protected _url: string;
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the EventsApi with the provided state module.
|
|
18
|
+
* @class EventsApi
|
|
19
|
+
* @augments AsyncModules
|
|
20
|
+
* @implements {IEvents}
|
|
21
|
+
* @param {StateModule} state - The state module containing the base URL and other configurations.
|
|
22
|
+
* @description Initializes the EventsApi with the provided state module.
|
|
23
|
+
*/
|
|
24
|
+
constructor(state: StateModule);
|
|
25
|
+
/**
|
|
26
|
+
* Return all subscriptions to product.
|
|
27
|
+
* @handleName getAllSubscriptions
|
|
28
|
+
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
29
|
+
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
30
|
+
* @returns {Promise<ISubscriptions | IError>} Returns an object containing all subscriptions or an error object if there was an issue.
|
|
31
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
32
|
+
* @description This method requires user authorization.
|
|
33
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
34
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/events/getAllSubscriptions getAllSubscriptions} documentation.
|
|
35
|
+
*/
|
|
36
|
+
getAllSubscriptions(offset?: number, limit?: number): Promise<ISubscriptions | IError>;
|
|
37
|
+
/**
|
|
38
|
+
* Subscribing to an event on a product.
|
|
39
|
+
* @handleName subscribeByMarker
|
|
40
|
+
* @param {string} marker - Event marker. Example: "product_price_change".
|
|
41
|
+
* @param {number} productId - Product id. Example: 12345.
|
|
42
|
+
* @param {string} [langCode] - Language code. Default: "en_US".=
|
|
43
|
+
* @returns {Promise<boolean | IError>} Returns true if subscription was successful, or an error object if there was an issue.
|
|
44
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
45
|
+
* @description This method requires user authorization.
|
|
46
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
47
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/events/subscribeByMarker subscribeByMarker} documentation.
|
|
48
|
+
*/
|
|
49
|
+
subscribeByMarker(marker: string, productId: number, langCode?: string): Promise<boolean | IError>;
|
|
50
|
+
/**
|
|
51
|
+
* Unsubscribing to an event on a product.
|
|
52
|
+
* @handleName unsubscribeByMarker
|
|
53
|
+
* @param {string} marker - The marker of the event to unsubscribe from. Example: "product_price_change".
|
|
54
|
+
* @param {number} productId - The ID of the product to unsubscribe from. Example: 12345.
|
|
55
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
56
|
+
* @returns {Promise<any | IError>} - Returns a promise that resolves to the result of the unsubscription operation or an error object if there was an issue.
|
|
57
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
58
|
+
* @description This method requires user authorization.
|
|
59
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
60
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/events/unsubscribeByMarker unsubscribeByMarker} documentation.
|
|
61
|
+
*/
|
|
62
|
+
unsubscribeByMarker(marker: string, productId: number, langCode?: string): Promise<boolean | IError>;
|
|
63
|
+
/**
|
|
64
|
+
* Returns all available events.
|
|
65
|
+
* @handleName getAllEvents
|
|
66
|
+
* @returns {Promise<IContentApiEvent[] | IError>} Returns an array of available events.
|
|
67
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
68
|
+
* @description This method returns all available events.
|
|
69
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/events/getAllEvents getAllEvents} documentation.
|
|
70
|
+
*/
|
|
71
|
+
getAllEvents(): Promise<IContentApiEvent[] | IError>;
|
|
72
|
+
/**
|
|
73
|
+
* Subscribe to a form event by marker.
|
|
74
|
+
* @handleName subscribeToForm
|
|
75
|
+
* @param {string} marker - Event marker. Example: "form_marker".
|
|
76
|
+
* @param {ISubscribeFormEvent} body - Subscription body. Example: `{ formDataId: 123 }`.
|
|
77
|
+
* @returns {Promise<boolean | IError>} Returns true if the subscription was successful, or an error object.
|
|
78
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
79
|
+
* @description This method requires user authorization.
|
|
80
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
81
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/events/subscribeToForm subscribeToForm} documentation.
|
|
82
|
+
*/
|
|
83
|
+
subscribeToForm(marker: string, body: ISubscribeFormEvent): Promise<boolean | IError>;
|
|
84
|
+
/**
|
|
85
|
+
* Returns all form subscriptions.
|
|
86
|
+
* @handleName getFormSubscriptions
|
|
87
|
+
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
88
|
+
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
89
|
+
* @returns {Promise<IFormSubscriptionsResponse | IError>} Returns an object with an array of form subscriptions and total count.
|
|
90
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
91
|
+
* @description This method requires user authorization.
|
|
92
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
93
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/events/getFormSubscriptions getFormSubscriptions} documentation.
|
|
94
|
+
*/
|
|
95
|
+
getFormSubscriptions(offset?: number, limit?: number): Promise<IFormSubscriptionsResponse | IError>;
|
|
96
|
+
/**
|
|
97
|
+
* Unsubscribe from form notifications by marker.
|
|
98
|
+
* @handleName unsubscribeFromForm
|
|
99
|
+
* @param {string} marker - Event marker. Example: "form_marker".
|
|
100
|
+
* @param {ISubscribeFormEvent} body - Subscription body. Example: `{ formDataId: 123 }`.
|
|
101
|
+
* @returns {Promise<boolean | IError>} Returns true if the unsubscription was successful, or an error object.
|
|
102
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
103
|
+
* @description This method requires user authorization.
|
|
104
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
105
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/events/unsubscribeFromForm unsubscribeFromForm} documentation.
|
|
106
|
+
*/
|
|
107
|
+
unsubscribeFromForm(marker: string, body: ISubscribeFormEvent): Promise<boolean | IError>;
|
|
108
|
+
}
|