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,122 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules.js';
|
|
2
|
+
import createSchemaLoader from '../base/lazySchema.js';
|
|
3
|
+
const schema = createSchemaLoader(() => import('./paymentsSchemas.js'));
|
|
4
|
+
/**
|
|
5
|
+
* Controllers for working with payments
|
|
6
|
+
* @handle /api/content/payments
|
|
7
|
+
* @description Controllers for working with payments
|
|
8
|
+
*/
|
|
9
|
+
export default class PaymentsApi extends AsyncModules {
|
|
10
|
+
/**
|
|
11
|
+
* Constructor
|
|
12
|
+
* @param {StateModule} state - StateModule instance
|
|
13
|
+
* @description Constructor initializes the PaymentsApi with a given state.
|
|
14
|
+
*/
|
|
15
|
+
constructor(state) {
|
|
16
|
+
super(state);
|
|
17
|
+
this._url = state.url + '/api/content/payments';
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get list of payment sessions.
|
|
21
|
+
* @handleName getSessions
|
|
22
|
+
* @param {number} [offset] - Optional parameter for pagination. Default: 0.
|
|
23
|
+
* @param {number} [limit] - Optional parameter for pagination. Default: 30.
|
|
24
|
+
* @returns {Promise<ISessionsEntity | IError>} Returns an array of SessionEntity objects.
|
|
25
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
26
|
+
* @description This method gets list of payment sessions. This method requires user authorization.
|
|
27
|
+
* @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}.
|
|
28
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getSessions getSessions} documentation.
|
|
29
|
+
*/
|
|
30
|
+
async getSessions(offset = 0, limit = 30) {
|
|
31
|
+
const query = {
|
|
32
|
+
offset,
|
|
33
|
+
limit,
|
|
34
|
+
};
|
|
35
|
+
const result = await this._fetchGet('/sessions/?' + this._queryParamsToString(query));
|
|
36
|
+
// Validate response if validation is enabled
|
|
37
|
+
const validated = await this._validateResponse(result, schema('PaymentSessionsResponseSchema'));
|
|
38
|
+
return validated;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get a single payment session object by its identifier.
|
|
42
|
+
* @handleName getSessionById
|
|
43
|
+
* @param {number} id - Identifier of the retrieved payment session object. Example: 12345.
|
|
44
|
+
* @returns {Promise<ISessionEntity | IError>} Returns a single payment session object.
|
|
45
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
46
|
+
* @description This method gets a single payment session object by its identifier. This method requires user authorization.
|
|
47
|
+
* @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}.
|
|
48
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getSessionById getSessionById} documentation.
|
|
49
|
+
*/
|
|
50
|
+
async getSessionById(id) {
|
|
51
|
+
const result = await this._fetchGet(`/sessions/${id}`);
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get one payment session object by order identifier
|
|
56
|
+
* @handleName getSessionByOrderId
|
|
57
|
+
* @param {number} id - Order identifier. Example: 12345.
|
|
58
|
+
* @returns {Promise<IAccountsEntity | IError>} Returns a single payment account object.
|
|
59
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
60
|
+
* @description This method gets one payment session object by order identifier. This method requires user authorization.
|
|
61
|
+
* @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}.
|
|
62
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getSessionByOrderId getSessionByOrderId} documentation.
|
|
63
|
+
*/
|
|
64
|
+
async getSessionByOrderId(id) {
|
|
65
|
+
const result = await this._fetchGet(`/sessions/order/${id}`);
|
|
66
|
+
// Validate response if validation is enabled
|
|
67
|
+
const validated = await this._validateResponse(result, schema('SinglePaymentSessionSchema'));
|
|
68
|
+
return validated;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Creation of payment session.
|
|
72
|
+
* @handleName createSession
|
|
73
|
+
* @param {number} orderId - Order identifier. Example: 12345.
|
|
74
|
+
* @param {'session' | 'intent'} type - Session type. Possible values: "session" or "intent". Example: 'session'.
|
|
75
|
+
* @param {boolean} [automaticTaxEnabled] - Automatic calculation of the tax rate. Default: false.
|
|
76
|
+
* @returns {Promise<ISessionEntity | IError>} Returns a single payment session object.
|
|
77
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
78
|
+
* @description This method creates a payment session. This method requires user authorization.
|
|
79
|
+
* @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}.
|
|
80
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/createSession createSession} documentation.
|
|
81
|
+
*/
|
|
82
|
+
async createSession(orderId, type, automaticTaxEnabled = false) {
|
|
83
|
+
const result = await this._fetchPost('/sessions', {
|
|
84
|
+
orderId,
|
|
85
|
+
type,
|
|
86
|
+
automaticTaxEnabled,
|
|
87
|
+
});
|
|
88
|
+
// Validate response if validation is enabled
|
|
89
|
+
const validated = await this._validateResponse(result, schema('PaymentSessionSchema'));
|
|
90
|
+
return validated;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get all payment accounts as an array.
|
|
94
|
+
* @handleName getAccounts
|
|
95
|
+
* @returns {Promise<IAccountsEntity | IError>} Returns all created payment accounts as an array of PaymentAccountEntity objects.
|
|
96
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
97
|
+
* @description This method gets all payment accounts as an array. This method requires user authorization.
|
|
98
|
+
* @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}.
|
|
99
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getAccounts getAccounts} documentation.
|
|
100
|
+
*/
|
|
101
|
+
async getAccounts() {
|
|
102
|
+
const result = await this._fetchGet('/accounts');
|
|
103
|
+
// Validate response if validation is enabled
|
|
104
|
+
const validated = await this._validateResponse(result, schema('PaymentAccountsResponseSchema'));
|
|
105
|
+
return this._normalizeData(validated);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get a single payment account object by its identifier.
|
|
109
|
+
* @handleName getAccountById
|
|
110
|
+
* @param {number} id - Identifier of the retrieved payment account object. Example: 12345.
|
|
111
|
+
* @returns {Promise<IAccountsEntity | IError>} Returns a single payment account object.
|
|
112
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
113
|
+
* @description Get a single payment account object by its identifier.
|
|
114
|
+
* @description This method requires user authorization.
|
|
115
|
+
* @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}.
|
|
116
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getAccountById getAccountById} documentation.
|
|
117
|
+
*/
|
|
118
|
+
async getAccountById(id) {
|
|
119
|
+
const result = await this._fetchGet(`/accounts/${id}`);
|
|
120
|
+
return this._normalizeData(result);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { IError, ILocalizeInfo } from '../base/utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* @interface IPaymentsApi
|
|
4
|
+
* @description This interface defines methods for managing payment sessions, accounts, and connected payment settings in the system.
|
|
5
|
+
*/
|
|
6
|
+
interface IPaymentsApi {
|
|
7
|
+
/**
|
|
8
|
+
* Get list of payment sessions.
|
|
9
|
+
* @handleName getSessions
|
|
10
|
+
* @param {number} [offset] - Optional parameter for pagination. Default: 0.
|
|
11
|
+
* @param {number} [limit] - Optional parameter for pagination. Default: 30.
|
|
12
|
+
* @returns {ISessionsEntity} Returns an array of SessionEntity objects.
|
|
13
|
+
* @throws {IError} If there is an error during the fetch operation, it will return an error object.
|
|
14
|
+
* @description This method gets list of payment sessions. This method requires user authorization.
|
|
15
|
+
* @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}.
|
|
16
|
+
*/
|
|
17
|
+
getSessions(offset?: number, limit?: number): Promise<ISessionsEntity | IError>;
|
|
18
|
+
/**
|
|
19
|
+
* Get a single payment session object by its identifier.
|
|
20
|
+
* @handleName getSessionById
|
|
21
|
+
* @param {number} id - Identifier of the retrieved payment session object. Example: 12345.
|
|
22
|
+
* @returns {ISessionEntity} Returns a single payment session object.
|
|
23
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
24
|
+
* @description This method gets a single payment session object by its identifier. This method requires user authorization.
|
|
25
|
+
* @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}.
|
|
26
|
+
*/
|
|
27
|
+
getSessionById(id: number): Promise<ISessionEntity | IError>;
|
|
28
|
+
/**
|
|
29
|
+
* Get one payment session object by order identifier 🔐
|
|
30
|
+
* @handleName getSessionByOrderId
|
|
31
|
+
* @param {number} id - Order identifier. Example: 12345.
|
|
32
|
+
* @returns {ISessionEntity} Returns a single payment session object.
|
|
33
|
+
* @throws {IError} If there is an error during the fetch operation, it will return an error object.
|
|
34
|
+
* @description This method gets one payment session object by order identifier. This method requires user authorization.
|
|
35
|
+
* @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}.
|
|
36
|
+
*/
|
|
37
|
+
getSessionByOrderId(id: number): Promise<ISessionEntity | ISessionEntity[] | IError>;
|
|
38
|
+
/**
|
|
39
|
+
* Creation of payment session.
|
|
40
|
+
* @handleName createSession
|
|
41
|
+
* @param {number} orderId - Order identifier. Example: 12345.
|
|
42
|
+
* @param {'session' | 'intent'} type - Session type. Possible values: "session" or "intent". Example: "session".
|
|
43
|
+
* @param {boolean} [automaticTaxEnabled] - Automatic calculation of the tax rate. Default: false.
|
|
44
|
+
* @returns {ISessionEntity} Returns a single payment session object.
|
|
45
|
+
* @throws {IError} If there is an error during the fetch operation, it will return an error object.
|
|
46
|
+
* @description This method creates a payment session. This method requires user authorization.
|
|
47
|
+
* @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}.
|
|
48
|
+
*/
|
|
49
|
+
createSession(orderId: number, type: 'session' | 'intent', automaticTaxEnabled?: boolean): Promise<ISessionEntity | IError>;
|
|
50
|
+
/**
|
|
51
|
+
* Get all payment accounts as an array.
|
|
52
|
+
* @handleName getAccounts
|
|
53
|
+
* @returns {IAccountsEntity} Returns all created payment accounts as an array of PaymentAccountEntity objects.
|
|
54
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
55
|
+
* @description This method gets all payment accounts as an array. This method requires user authorization.
|
|
56
|
+
* @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}.
|
|
57
|
+
*/
|
|
58
|
+
getAccounts(): Promise<IAccountsEntity[] | IError>;
|
|
59
|
+
/**
|
|
60
|
+
* Get a single payment account object by its identifier.
|
|
61
|
+
* @handleName getAccountById
|
|
62
|
+
* @param {number} id - Identifier of the retrieved payment account object. Example: 12345.
|
|
63
|
+
* @returns {IAccountsEntity} Returns a single payment account object.
|
|
64
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
65
|
+
* @description This method gets a single payment account object by its identifier. This method requires user authorization.
|
|
66
|
+
* @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}.
|
|
67
|
+
*/
|
|
68
|
+
getAccountById(id: number): Promise<IAccountsEntity | IError>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @interface ISessionsEntity
|
|
72
|
+
* @property {number} total - Total number of found records. Example: 100.
|
|
73
|
+
* @property {ISessionEntity[]} items - Array of session objects.
|
|
74
|
+
* @example
|
|
75
|
+
[
|
|
76
|
+
{
|
|
77
|
+
"id": 27,
|
|
78
|
+
"createdDate": "2025-06-04T04:38:32.849Z",
|
|
79
|
+
"updatedDate": "2025-06-04T04:38:32.849Z",
|
|
80
|
+
"type": "session",
|
|
81
|
+
"status": "waiting",
|
|
82
|
+
"paymentAccountId": 1,
|
|
83
|
+
"orderId": 55,
|
|
84
|
+
"paymentUrl": null
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
* @description Represents a response from the payments API containing a total count and an array of session entities.
|
|
88
|
+
*/
|
|
89
|
+
interface ISessionsEntity {
|
|
90
|
+
total: number;
|
|
91
|
+
items: ISessionEntity[];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @interface ISessionEntity
|
|
95
|
+
* @property {number} id - Object identifier. Example: 1764.
|
|
96
|
+
* @property {string} createdDate - Object creation date. Example: "2025-02-26T10:13:16.839Z".
|
|
97
|
+
* @property {string} updatedDate - Object modification date. Example: "2025-02-26T10:13:16.839Z".
|
|
98
|
+
* @property {'session' | 'intent'} type - Type may be 'session' or 'intent'. Example: "session".
|
|
99
|
+
* @property {string} status - Payment status. Example: "completed".
|
|
100
|
+
* @property {number} paymentAccountId - Payment account identifier. Example: 1.
|
|
101
|
+
* @property {number} orderId - Order identifier. Example: 1.
|
|
102
|
+
* @property {string | null} paymentUrl - payment link. Example: " https://www.sandbox.paypal.com/checkoutnow?token=9BE88048TU058770M".
|
|
103
|
+
* @property {number | null} [amount] - Amount of the payment session. Example: 100.
|
|
104
|
+
* @property {string} [clientSecret] - Client secret key returned by payment provider (e.g. Stripe) when creating a session. Example: "pi_3MtwBwLkdIwHu7ix28a3tqPa_secret_YrKJUKribcBjcG8HVhfZluoGH".
|
|
105
|
+
* @description This interface defines the structure of a session entity, including its quantity, amount, currency, name, and description.
|
|
106
|
+
*/
|
|
107
|
+
interface ISessionEntity {
|
|
108
|
+
id: number;
|
|
109
|
+
createdDate: string;
|
|
110
|
+
updatedDate: string;
|
|
111
|
+
type: 'session' | 'intent';
|
|
112
|
+
status: string;
|
|
113
|
+
paymentAccountId: number;
|
|
114
|
+
orderId: number;
|
|
115
|
+
paymentUrl: string | null;
|
|
116
|
+
amount?: number | null;
|
|
117
|
+
clientSecret?: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* @interface IIntent
|
|
121
|
+
* @property {number} amount - Amount of the payment intent. Example: 100.00.
|
|
122
|
+
* @property {string} currency - Currency of the payment intent. Example: "USD".
|
|
123
|
+
* @description This interface defines the structure of a payment intent, including its amount and currency.
|
|
124
|
+
*/
|
|
125
|
+
interface IIntent {
|
|
126
|
+
amount: number;
|
|
127
|
+
currency: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* @interface IAccountsEntity
|
|
131
|
+
* @property {number} id - Object identifier. Example: 12345.
|
|
132
|
+
* @property {ILocalizeInfo} localizeInfos - Json description of the payment account object.
|
|
133
|
+
* @property {string} identifier - Text identifier for the recording field. Example: "payment_12345".
|
|
134
|
+
* @property {'stripe' | 'yookassa' | 'midtrans' | 'xendit' | 'custom'} type - Payment provider type. Example: 'stripe'.
|
|
135
|
+
* @property {boolean} isVisible - Visibility indicator of the payment account. Example: true.
|
|
136
|
+
* @property {boolean} isUsed - Usage indicator of the payment account. Example: false.
|
|
137
|
+
* @property {boolean} testMode - Indicates whether the payment account is in test mode. Example: true.
|
|
138
|
+
* @property {IPaymentAccountSettings} settings - Payment account settings. Example: `{ "status": "connected" }`.
|
|
139
|
+
* @property {object} [testSettings] - Test mode settings for the payment account.
|
|
140
|
+
* @property {string} updatedDate - Object modification date. Example: "2025-02-26T10:13:16.839Z".
|
|
141
|
+
* @description This interface defines the structure of a payment account entity, including its identifiers, localization information, type, visibility, and usage status.
|
|
142
|
+
*/
|
|
143
|
+
interface IAccountsEntity {
|
|
144
|
+
id: number;
|
|
145
|
+
localizeInfos: ILocalizeInfo;
|
|
146
|
+
identifier: string;
|
|
147
|
+
type: 'stripe' | 'yookassa' | 'midtrans' | 'xendit' | 'custom';
|
|
148
|
+
isVisible: boolean;
|
|
149
|
+
isUsed: boolean;
|
|
150
|
+
testMode: boolean;
|
|
151
|
+
settings: IPaymentAccountSettings;
|
|
152
|
+
testSettings?: IPaymentAccountTestSettings;
|
|
153
|
+
updatedDate: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* @interface IPaymentAccountSettings
|
|
157
|
+
* @property {string} status - Connection status of the live (non-test) payment account. Example: "connected".
|
|
158
|
+
* @description Live-mode configuration of a payment account; identical shape to test settings minus secrets.
|
|
159
|
+
*/
|
|
160
|
+
interface IPaymentAccountSettings {
|
|
161
|
+
status: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* @interface IPaymentAccountTestSettings
|
|
165
|
+
* @property {string} status - Connection status of the test account. Example: "connected".
|
|
166
|
+
* @property {string} [cancelUrl] - URL the user is redirected to on payment cancellation.
|
|
167
|
+
* @property {string} [successUrl] - URL the user is redirected to on successful payment.
|
|
168
|
+
* @property {number} [sessionTimeout] - Stripe checkout session timeout in minutes. Example: 15.
|
|
169
|
+
* @property {string} [stripeAccountId] - Stripe-issued account identifier. Example: "acct_1QwkKrAcSoNc7iev".
|
|
170
|
+
* @property {string} [stripeRedirectUrl] - Stripe onboarding redirect URL.
|
|
171
|
+
* @property {boolean} [stripeOnboardingComplete] - Whether Stripe onboarding finished. Example: true.
|
|
172
|
+
* @property {string} [stripePublishableKey] - Stripe publishable key.
|
|
173
|
+
* @property {string} [signingSecretKey] - Stripe webhook signing secret. Example: "whsec_...".
|
|
174
|
+
* @property {boolean} [useWebHookValidation] - Whether incoming webhooks must be signature-validated. Example: true.
|
|
175
|
+
* @description Test-mode configuration of a payment account; field set depends on the provider (Stripe-specific fields are optional).
|
|
176
|
+
*/
|
|
177
|
+
interface IPaymentAccountTestSettings {
|
|
178
|
+
status: string;
|
|
179
|
+
cancelUrl?: string;
|
|
180
|
+
successUrl?: string;
|
|
181
|
+
sessionTimeout?: number;
|
|
182
|
+
stripeAccountId?: string;
|
|
183
|
+
stripeRedirectUrl?: string;
|
|
184
|
+
stripeOnboardingComplete?: boolean;
|
|
185
|
+
stripePublishableKey?: string;
|
|
186
|
+
signingSecretKey?: string;
|
|
187
|
+
useWebHookValidation?: boolean;
|
|
188
|
+
}
|
|
189
|
+
export type { IAccountsEntity, IIntent, IPaymentAccountSettings, IPaymentAccountTestSettings, IPaymentsApi, ISessionEntity, ISessionsEntity, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Payment session schema
|
|
4
|
+
* @description Zod schema for validating payment session responses
|
|
5
|
+
*/
|
|
6
|
+
export declare const PaymentSessionSchema: z.ZodObject<{
|
|
7
|
+
id: z.ZodNumber;
|
|
8
|
+
orderId: z.ZodNumber;
|
|
9
|
+
amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
10
|
+
status: z.ZodString;
|
|
11
|
+
createdDate: z.ZodString;
|
|
12
|
+
updatedDate: z.ZodString;
|
|
13
|
+
type: z.ZodString;
|
|
14
|
+
paymentAccountId: z.ZodNumber;
|
|
15
|
+
paymentUrl: z.ZodNullable<z.ZodString>;
|
|
16
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
/**
|
|
19
|
+
* Payment sessions response schema
|
|
20
|
+
* @description Paginated response schema for payment sessions
|
|
21
|
+
*/
|
|
22
|
+
export declare const PaymentSessionsResponseSchema: z.ZodObject<{
|
|
23
|
+
items: z.ZodArray<z.ZodObject<{
|
|
24
|
+
id: z.ZodNumber;
|
|
25
|
+
orderId: z.ZodNumber;
|
|
26
|
+
amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
27
|
+
status: z.ZodString;
|
|
28
|
+
createdDate: z.ZodString;
|
|
29
|
+
updatedDate: z.ZodString;
|
|
30
|
+
type: z.ZodString;
|
|
31
|
+
paymentAccountId: z.ZodNumber;
|
|
32
|
+
paymentUrl: z.ZodNullable<z.ZodString>;
|
|
33
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, z.core.$strip>>;
|
|
35
|
+
total: z.ZodNumber;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
/**
|
|
38
|
+
* Single payment session response schema
|
|
39
|
+
* @description Schema for a single payment session or array of sessions by order
|
|
40
|
+
*/
|
|
41
|
+
export declare const SinglePaymentSessionSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
42
|
+
id: z.ZodNumber;
|
|
43
|
+
orderId: z.ZodNumber;
|
|
44
|
+
amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
45
|
+
status: z.ZodString;
|
|
46
|
+
createdDate: z.ZodString;
|
|
47
|
+
updatedDate: z.ZodString;
|
|
48
|
+
type: z.ZodString;
|
|
49
|
+
paymentAccountId: z.ZodNumber;
|
|
50
|
+
paymentUrl: z.ZodNullable<z.ZodString>;
|
|
51
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
52
|
+
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
53
|
+
id: z.ZodNumber;
|
|
54
|
+
orderId: z.ZodNumber;
|
|
55
|
+
amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
56
|
+
status: z.ZodString;
|
|
57
|
+
createdDate: z.ZodString;
|
|
58
|
+
updatedDate: z.ZodString;
|
|
59
|
+
type: z.ZodString;
|
|
60
|
+
paymentAccountId: z.ZodNumber;
|
|
61
|
+
paymentUrl: z.ZodNullable<z.ZodString>;
|
|
62
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
63
|
+
}, z.core.$strip>>]>;
|
|
64
|
+
/**
|
|
65
|
+
* Payment account schema
|
|
66
|
+
* @description Schema for a payment account
|
|
67
|
+
*/
|
|
68
|
+
export declare const PaymentAccountSchema: z.ZodObject<{
|
|
69
|
+
id: z.ZodNumber;
|
|
70
|
+
identifier: z.ZodString;
|
|
71
|
+
isVisible: z.ZodBoolean;
|
|
72
|
+
isUsed: z.ZodBoolean;
|
|
73
|
+
testMode: z.ZodBoolean;
|
|
74
|
+
type: z.ZodString;
|
|
75
|
+
settings: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
76
|
+
testSettings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
77
|
+
localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
78
|
+
updatedDate: z.ZodString;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
/**
|
|
81
|
+
* Payment accounts response schema
|
|
82
|
+
*/
|
|
83
|
+
export declare const PaymentAccountsResponseSchema: z.ZodArray<z.ZodObject<{
|
|
84
|
+
id: z.ZodNumber;
|
|
85
|
+
identifier: z.ZodString;
|
|
86
|
+
isVisible: z.ZodBoolean;
|
|
87
|
+
isUsed: z.ZodBoolean;
|
|
88
|
+
testMode: z.ZodBoolean;
|
|
89
|
+
type: z.ZodString;
|
|
90
|
+
settings: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
91
|
+
testSettings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
92
|
+
localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
93
|
+
updatedDate: z.ZodString;
|
|
94
|
+
}, z.core.$strip>>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Payment session schema
|
|
4
|
+
* @description Zod schema for validating payment session responses
|
|
5
|
+
*/
|
|
6
|
+
export const PaymentSessionSchema = z.object({
|
|
7
|
+
id: z.number(),
|
|
8
|
+
orderId: z.number(),
|
|
9
|
+
amount: z.number().nullable().optional(),
|
|
10
|
+
status: z.string(),
|
|
11
|
+
createdDate: z.string(),
|
|
12
|
+
updatedDate: z.string(),
|
|
13
|
+
type: z.string(),
|
|
14
|
+
paymentAccountId: z.number(),
|
|
15
|
+
paymentUrl: z.string().nullable(),
|
|
16
|
+
clientSecret: z.string().optional(),
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Payment sessions response schema
|
|
20
|
+
* @description Paginated response schema for payment sessions
|
|
21
|
+
*/
|
|
22
|
+
export const PaymentSessionsResponseSchema = z.object({
|
|
23
|
+
items: z.array(PaymentSessionSchema),
|
|
24
|
+
total: z.number(),
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Single payment session response schema
|
|
28
|
+
* @description Schema for a single payment session or array of sessions by order
|
|
29
|
+
*/
|
|
30
|
+
export const SinglePaymentSessionSchema = z.union([
|
|
31
|
+
PaymentSessionSchema,
|
|
32
|
+
z.array(PaymentSessionSchema),
|
|
33
|
+
]);
|
|
34
|
+
/**
|
|
35
|
+
* Payment account schema
|
|
36
|
+
* @description Schema for a payment account
|
|
37
|
+
*/
|
|
38
|
+
export const PaymentAccountSchema = z.object({
|
|
39
|
+
id: z.number(),
|
|
40
|
+
identifier: z.string(),
|
|
41
|
+
isVisible: z.boolean(),
|
|
42
|
+
isUsed: z.boolean(),
|
|
43
|
+
testMode: z.boolean(),
|
|
44
|
+
type: z.string(),
|
|
45
|
+
settings: z.record(z.string(), z.any()),
|
|
46
|
+
testSettings: z.record(z.string(), z.any()).optional(),
|
|
47
|
+
localizeInfos: z.record(z.string(), z.any()),
|
|
48
|
+
updatedDate: z.string(),
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Payment accounts response schema
|
|
52
|
+
*/
|
|
53
|
+
export const PaymentAccountsResponseSchema = z.array(PaymentAccountSchema);
|
|
@@ -0,0 +1,50 @@
|
|
|
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 { IProductStatusEntity, IProductStatusesApi } from './productStatusesInterfaces.js';
|
|
5
|
+
/**
|
|
6
|
+
* Controllers for working with product statuses
|
|
7
|
+
* @handle /api/content/product-statuses
|
|
8
|
+
* @description Controllers for working with product statuses
|
|
9
|
+
*/
|
|
10
|
+
export default class ProductStatusesApi extends AsyncModules implements IProductStatusesApi {
|
|
11
|
+
protected state: StateModule;
|
|
12
|
+
protected _url: string;
|
|
13
|
+
/**
|
|
14
|
+
* Constructor
|
|
15
|
+
* @param {StateModule} state - State module instance
|
|
16
|
+
* @description Constructor initializes the ProductStatusesApi with a given state.
|
|
17
|
+
*/
|
|
18
|
+
constructor(state: StateModule);
|
|
19
|
+
/**
|
|
20
|
+
* Search for all product status objects.
|
|
21
|
+
* @handleName getProductStatuses
|
|
22
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
23
|
+
* @returns {Promise<IProductStatusEntity[] | IError>} Returns an array of product status objects.
|
|
24
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
25
|
+
* @description Search for all product status objects.
|
|
26
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/product-statuses/getProductStatuses getProductStatuses} documentation.
|
|
27
|
+
*/
|
|
28
|
+
getProductStatuses(langCode?: string): Promise<IProductStatusEntity[] | IError>;
|
|
29
|
+
/**
|
|
30
|
+
* Search for a product status object by its textual identifier (marker).
|
|
31
|
+
* @handleName getProductsByStatusMarker
|
|
32
|
+
* @param {string} marker - Product marker. Example: "in_stock".
|
|
33
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
34
|
+
* @returns {Promise<IProductStatusEntity | IError>} Returns a product status object.
|
|
35
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
36
|
+
* @description Search for a product status object by its textual identifier (marker).
|
|
37
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/product-statuses/getProductsByStatusMarker getProductsByStatusMarker} documentation.
|
|
38
|
+
*/
|
|
39
|
+
getProductsByStatusMarker(marker: string, langCode?: string): Promise<IProductStatusEntity | IError>;
|
|
40
|
+
/**
|
|
41
|
+
* Check the existence of a textual identifier.
|
|
42
|
+
* @handleName validateMarker
|
|
43
|
+
* @param {string} marker - Product marker. Example: "in_stock".
|
|
44
|
+
* @returns {Promise<boolean | IError>} Returns true if the textual identifier (marker) exists or false if it doesn't.
|
|
45
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
46
|
+
* @description Check the existence of a textual identifier.
|
|
47
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/product-statuses/validateMarker validateMarker} documentation.
|
|
48
|
+
*/
|
|
49
|
+
validateMarker(marker: string): Promise<boolean | IError>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules.js';
|
|
2
|
+
import createSchemaLoader from '../base/lazySchema.js';
|
|
3
|
+
const schema = createSchemaLoader(() => import('./productStatusesSchemas.js'));
|
|
4
|
+
/**
|
|
5
|
+
* Controllers for working with product statuses
|
|
6
|
+
* @handle /api/content/product-statuses
|
|
7
|
+
* @description Controllers for working with product statuses
|
|
8
|
+
*/
|
|
9
|
+
export default class ProductStatusesApi extends AsyncModules {
|
|
10
|
+
/**
|
|
11
|
+
* Constructor
|
|
12
|
+
* @param {StateModule} state - State module instance
|
|
13
|
+
* @description Constructor initializes the ProductStatusesApi with a given state.
|
|
14
|
+
*/
|
|
15
|
+
constructor(state) {
|
|
16
|
+
super(state);
|
|
17
|
+
this._url = state.url + '/api/content/product-statuses';
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Search for all product status objects.
|
|
21
|
+
* @handleName getProductStatuses
|
|
22
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
23
|
+
* @returns {Promise<IProductStatusEntity[] | IError>} Returns an array of product status objects.
|
|
24
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
25
|
+
* @description Search for all product status objects.
|
|
26
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/product-statuses/getProductStatuses getProductStatuses} documentation.
|
|
27
|
+
*/
|
|
28
|
+
async getProductStatuses(langCode = this.state.lang) {
|
|
29
|
+
const result = await this._fetchGet('');
|
|
30
|
+
// Validate response if validation is enabled
|
|
31
|
+
const validated = await this._validateResponse(result, schema('ProductStatusesResponseSchema'));
|
|
32
|
+
return this._normalizeData(validated, langCode);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Search for a product status object by its textual identifier (marker).
|
|
36
|
+
* @handleName getProductsByStatusMarker
|
|
37
|
+
* @param {string} marker - Product marker. Example: "in_stock".
|
|
38
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
39
|
+
* @returns {Promise<IProductStatusEntity | IError>} Returns a product status object.
|
|
40
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
41
|
+
* @description Search for a product status object by its textual identifier (marker).
|
|
42
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/product-statuses/getProductsByStatusMarker getProductsByStatusMarker} documentation.
|
|
43
|
+
*/
|
|
44
|
+
async getProductsByStatusMarker(marker, langCode = this.state.lang) {
|
|
45
|
+
const result = await this._fetchGet(`/marker/${marker}`);
|
|
46
|
+
// Validate response if validation is enabled
|
|
47
|
+
const validated = await this._validateResponse(result, schema('ProductStatusEntitySchema'));
|
|
48
|
+
return this._normalizeData(validated, langCode);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Check the existence of a textual identifier.
|
|
52
|
+
* @handleName validateMarker
|
|
53
|
+
* @param {string} marker - Product marker. Example: "in_stock".
|
|
54
|
+
* @returns {Promise<boolean | IError>} Returns true if the textual identifier (marker) exists or false if it doesn't.
|
|
55
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
56
|
+
* @description Check the existence of a textual identifier.
|
|
57
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/product-statuses/validateMarker validateMarker} documentation.
|
|
58
|
+
*/
|
|
59
|
+
async validateMarker(marker) {
|
|
60
|
+
const result = await this._fetchGet(`/marker-validation/${marker}`);
|
|
61
|
+
// Validate response if validation is enabled
|
|
62
|
+
const validated = await this._validateResponse(result, schema('ValidateMarkerResponseSchema'));
|
|
63
|
+
// Extract the 'valid' boolean value from the response object
|
|
64
|
+
return typeof validated === 'object' && 'valid' in validated
|
|
65
|
+
? validated.valid
|
|
66
|
+
: validated;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { IError, ILocalizeInfo } from '../base/utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* @interface IProductStatuses
|
|
4
|
+
* @description This interface defines methods for retrieving and managing product statuses in the system.
|
|
5
|
+
*/
|
|
6
|
+
interface IProductStatusesApi {
|
|
7
|
+
/**
|
|
8
|
+
* Search for all product status objects.
|
|
9
|
+
* @handleName getProductStatuses
|
|
10
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
11
|
+
* @returns {IProductStatusEntity[]} Returns an array of product status objects.
|
|
12
|
+
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
13
|
+
* @description This method searches for all product status objects.
|
|
14
|
+
*/
|
|
15
|
+
getProductStatuses(langCode: string): Promise<IProductStatusEntity[] | IError>;
|
|
16
|
+
/**
|
|
17
|
+
* Search for a product status object by its textual identifier (marker).
|
|
18
|
+
* @handleName getProductsByStatusMarker
|
|
19
|
+
* @param {string} marker - Product marker. Example: "in_stock".
|
|
20
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
21
|
+
* @returns {IProductStatusEntity} Returns a product status object.
|
|
22
|
+
* @throws {IError} If there is an error during the fetch operation, it will return an error object.
|
|
23
|
+
* @description This method searches for a product status object by its textual identifier (marker).
|
|
24
|
+
*/
|
|
25
|
+
getProductsByStatusMarker(marker: string, langCode: string): Promise<IProductStatusEntity | IError>;
|
|
26
|
+
/**
|
|
27
|
+
* Check the existence of a textual identifier.
|
|
28
|
+
* @handleName validateMarker
|
|
29
|
+
* @param {string} marker - Product marker. Example: "in_stock".
|
|
30
|
+
* @returns {boolean} Returns true if the textual identifier (marker) exists or false if it doesn't.
|
|
31
|
+
* @throws {IError} If there is an error during the fetch operation, it will return an error object.
|
|
32
|
+
* @description This method checks the existence of a textual identifier.
|
|
33
|
+
*/
|
|
34
|
+
validateMarker(marker: string): Promise<boolean | IError>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Product status entity structure
|
|
38
|
+
* @interface IProductStatusEntity
|
|
39
|
+
* @property {number} id - The unique identifier of the position. Example: 12345.
|
|
40
|
+
* @property {string} identifier - The textual identifier for the record field. Example: "in_stock".
|
|
41
|
+
* @property {ILocalizeInfo} localizeInfos - The name of the products statuses, taking into account localization.
|
|
42
|
+
* @example
|
|
43
|
+
{
|
|
44
|
+
"title": "Catalog",
|
|
45
|
+
"plainContent": "Content for catalog",
|
|
46
|
+
"htmlContent": "<b>Content for catalog</b>",
|
|
47
|
+
"menuTitle": "Catalog"
|
|
48
|
+
}
|
|
49
|
+
* @property {boolean} isDefault - Default status flag. Example: true.
|
|
50
|
+
* @property {number} version - The version number of the object. Example: 1.
|
|
51
|
+
* @property {number} position - Position number. Example: 1.
|
|
52
|
+
* @description This interface defines the structure of a product status entity, including its identifiers, localization information, position, and default status flag.
|
|
53
|
+
*/
|
|
54
|
+
interface IProductStatusEntity {
|
|
55
|
+
id: number;
|
|
56
|
+
identifier: string;
|
|
57
|
+
localizeInfos: ILocalizeInfo;
|
|
58
|
+
isDefault: boolean;
|
|
59
|
+
version: number;
|
|
60
|
+
position: number;
|
|
61
|
+
}
|
|
62
|
+
export type { IProductStatusEntity, IProductStatusesApi };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|