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,312 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules.js';
|
|
2
|
+
import createSchemaLoader from '../base/lazySchema.js';
|
|
3
|
+
const schema = createSchemaLoader(() => import('./usersSchemas.js'));
|
|
4
|
+
/**
|
|
5
|
+
* Controllers for working with users
|
|
6
|
+
* @handle /api/content/users
|
|
7
|
+
* @description This module provides various methods to manage users, including creating, retrieving, updating, and deleting user data. It requires proper authorization to access these endpoints.
|
|
8
|
+
*/
|
|
9
|
+
export default class UsersApi extends AsyncModules {
|
|
10
|
+
/**
|
|
11
|
+
* Constructor for UsersApi class.
|
|
12
|
+
* @param {StateModule} state - The state module containing necessary information for API calls.
|
|
13
|
+
* @description Initializes the UsersApi class with the provided state module.
|
|
14
|
+
*/
|
|
15
|
+
constructor(state) {
|
|
16
|
+
super(state);
|
|
17
|
+
this._url = state.url + '/api/content/users';
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Getting the data of an authorized user.
|
|
21
|
+
* @handleName getUser
|
|
22
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
23
|
+
* @returns {Promise<IUserEntity | IError>} Returns a promise that resolves to the user entity object if successful; otherwise, returns an error object.
|
|
24
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
25
|
+
* @description This method requires user authorization.
|
|
26
|
+
* @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}.
|
|
27
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/users/getUser getUser} documentation.
|
|
28
|
+
*/
|
|
29
|
+
async getUser(langCode = this.state.lang) {
|
|
30
|
+
const result = await this._fetchGet(`/me?langCode=${langCode}`);
|
|
31
|
+
// Validate response if validation is enabled
|
|
32
|
+
const validated = await this._validateResponse(result, schema('UserResponseSchema'));
|
|
33
|
+
return this._normalizeData(validated);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Updating a single user object.
|
|
37
|
+
* @handleName updateUser
|
|
38
|
+
* @param {IUserBody} body - Request body.
|
|
39
|
+
* @example
|
|
40
|
+
{
|
|
41
|
+
"formIdentifier": "reg",
|
|
42
|
+
"authData": [
|
|
43
|
+
{
|
|
44
|
+
"marker": "email_reg",
|
|
45
|
+
"value": "your-email@oneentery.cloud"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"marker": "password_reg",
|
|
49
|
+
"value": "12345"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"formData": [
|
|
53
|
+
{
|
|
54
|
+
"marker": "last_name",
|
|
55
|
+
"type": "string",
|
|
56
|
+
"value": "Username"
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"notificationData": {
|
|
60
|
+
"email": "example@oneentry.cloud",
|
|
61
|
+
"phonePush": ["+99999999999"],
|
|
62
|
+
"phoneSMS": "+99999999999"
|
|
63
|
+
},
|
|
64
|
+
"state": {}
|
|
65
|
+
}
|
|
66
|
+
* @param {string} body.formIdentifier - Identifies the registration form being used. Example: "reg_form".
|
|
67
|
+
* @param {string} body.authData - Contains authentication credentials for the user. Example:
|
|
68
|
+
* @example
|
|
69
|
+
[
|
|
70
|
+
{
|
|
71
|
+
"marker": "email_reg",
|
|
72
|
+
"value": "example@oneentry.cloud"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"marker": "password_reg",
|
|
76
|
+
"value": "password"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
* @param {string} body.authData[].marker - Identifies the field being used. Example: "email_reg".
|
|
80
|
+
* @param {string} body.authData[].value - Contains the value of the field. Example: "example@oneentry.cloud".
|
|
81
|
+
* @param {string} body.formData - Contains additional data for the user.
|
|
82
|
+
* @example
|
|
83
|
+
[
|
|
84
|
+
{
|
|
85
|
+
"marker": "last_name",
|
|
86
|
+
"type": "string",
|
|
87
|
+
"value": "Username"
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
* @param {string} body.formData[].marker - The marker of the field. Example: "last_name".
|
|
91
|
+
* @param {string} body.formData[].type - The type of the field. Example: "string".
|
|
92
|
+
* @param {string} body.formData[].value - The value of the field. Example: "Username".
|
|
93
|
+
* @param {string} body.notificationData - The notification data.
|
|
94
|
+
* @example
|
|
95
|
+
{
|
|
96
|
+
"email": "example@oneentry.cloud",
|
|
97
|
+
"phonePush": ["+99999999999"],
|
|
98
|
+
"phoneSMS": "+99999999999"
|
|
99
|
+
}
|
|
100
|
+
* @param {string} body.notificationData.email - The email address of the user. Example: "example@oneentry.cloud".
|
|
101
|
+
* @param {string} body.notificationData.phonePush - An array of phone numbers for push notifications. Example: ["+99999999999"].
|
|
102
|
+
* @param {string} body.notificationData.phoneSMS - The phone number for SMS notifications. Example: "+99999999999".
|
|
103
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
104
|
+
* @returns {Promise<boolean | IError>} Returns `true` if the user object was successfully updated; otherwise, returns an error object.
|
|
105
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
106
|
+
* @description This method updates the user's data. This method requires user authorization.
|
|
107
|
+
* @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}.
|
|
108
|
+
* @see For more information about {@link https://doc.oneentry.cloud/docs/forms/create-form registration forms}, see the documentation in the {@link https://doc.oneentry.cloud/docs/forms/create-form forms configuration section}.
|
|
109
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/users/updateUser updateUser} documentation.
|
|
110
|
+
*/
|
|
111
|
+
async updateUser(body, langCode = this.state.lang) {
|
|
112
|
+
if (!('langCode' in body))
|
|
113
|
+
body['langCode'] = langCode;
|
|
114
|
+
const result = await this._fetchPut('/me', this._normalizePostBody(body, langCode));
|
|
115
|
+
const validated = await this._validateResponse(result, schema('UpdateUserResponseSchema'));
|
|
116
|
+
return validated;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Archiving one user object (marked for deletion).
|
|
120
|
+
* @handleName archiveUser
|
|
121
|
+
* @returns {Promise<boolean | IError>} Returns `true` if the user was successfully deleted; otherwise, returns an error object.
|
|
122
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
123
|
+
* @description This method archives a user object (marks it for deletion). This method requires user authorization.
|
|
124
|
+
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/auth-provider/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
125
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/users/archiveUser archiveUser} documentation.
|
|
126
|
+
*/
|
|
127
|
+
async archiveUser() {
|
|
128
|
+
const result = await this._fetchDelete('/me');
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Delete a single user.
|
|
133
|
+
* @handleName deleteUser
|
|
134
|
+
* @returns {Promise<boolean | IError>} Returns `true` if the user was successfully deleted; otherwise, returns an error object.
|
|
135
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
136
|
+
* @description This method deletes the user from the system. This method requires user authorization.
|
|
137
|
+
* @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}.
|
|
138
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/users/deleteUser deleteUser} documentation.
|
|
139
|
+
*/
|
|
140
|
+
async deleteUser() {
|
|
141
|
+
const result = await this._fetchDelete('/me/account');
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Adds an FCM (Firebase Cloud Messaging) token for sending push notifications.
|
|
146
|
+
* @handleName addFCMToken
|
|
147
|
+
* @param {string} token - The cloud messaging token to be added. This token is used to identify the user's device for push notifications. Example: "fcm_token_1234567890abcdefg".
|
|
148
|
+
* @returns {Promise<boolean | IError>} Returns `true` if the token was successfully added; otherwise, returns an error object.
|
|
149
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
150
|
+
* @description This method adds an FCM token for sending push notifications. This method requires user authorization.
|
|
151
|
+
* @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}.
|
|
152
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/users/addFCMToken addFCMToken} documentation.
|
|
153
|
+
*/
|
|
154
|
+
async addFCMToken(token) {
|
|
155
|
+
const result = await this._fetchPost(`/me/fcm-token/${token}`);
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Deletes an FCM (Firebase Cloud Messaging) token.
|
|
160
|
+
* @handleName deleteFCMToken
|
|
161
|
+
* @param {string} token - The cloud messaging token to be deleted. This token is used to identify the user's device for push notifications and will be removed. Example: "fcm_token_1234567890abcdefg".
|
|
162
|
+
* @returns {Promise<boolean | IError>} Returns `true` if the token was successfully deleted; otherwise, returns an error object.
|
|
163
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
164
|
+
* @description This method deletes an existing FCM token. This method requires user authorization.
|
|
165
|
+
* @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}.
|
|
166
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/users/deleteFCMToken deleteFCMToken} documentation.
|
|
167
|
+
*/
|
|
168
|
+
async deleteFCMToken(token) {
|
|
169
|
+
const result = await this._fetchDelete(`/me/fcm-token/${token}`);
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get the current user's or guest's cart.
|
|
174
|
+
* @handleName getCart
|
|
175
|
+
* @returns {Promise<ICartResponse | IError>} Returns the cart with its items and total.
|
|
176
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
177
|
+
* @description This method requires user authorization (or a guest context).
|
|
178
|
+
* @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}.
|
|
179
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/users/getCart getCart} documentation.
|
|
180
|
+
*/
|
|
181
|
+
async getCart() {
|
|
182
|
+
const result = await this._fetchGet('/me/cart');
|
|
183
|
+
const validated = await this._validateResponse(result, schema('CartResponseSchema'));
|
|
184
|
+
return this._normalizeData(validated);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Replace the current user's or guest's cart.
|
|
188
|
+
* @handleName setCart
|
|
189
|
+
* @param {ICartSet} body - New cart contents. Example: `{ items: [{ productId: 1, qty: 2 }] }`.
|
|
190
|
+
* @returns {Promise<ICartResponse | IError>} Returns the updated cart.
|
|
191
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
192
|
+
* @description This method requires user authorization (or a guest context).
|
|
193
|
+
* @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}.
|
|
194
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/users/setCart setCart} documentation.
|
|
195
|
+
*/
|
|
196
|
+
async setCart(body) {
|
|
197
|
+
const result = await this._fetchPut('/me/cart', body);
|
|
198
|
+
const validated = await this._validateResponse(result, schema('CartResponseSchema'));
|
|
199
|
+
return this._normalizeData(validated);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Add an item to the cart (or update qty of an existing one).
|
|
203
|
+
* @handleName addCartItem
|
|
204
|
+
* @param {ICartAddItem} body - Item to add. Example: `{ productId: 1, qty: 2 }`.
|
|
205
|
+
* @returns {Promise<ICartResponse | IError>} Returns the updated cart.
|
|
206
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
207
|
+
* @description This method requires user authorization (or a guest context).
|
|
208
|
+
* @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}.
|
|
209
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/users/addCartItem addCartItem} documentation.
|
|
210
|
+
*/
|
|
211
|
+
async addCartItem(body) {
|
|
212
|
+
const result = await this._fetchPost('/me/cart/items', body);
|
|
213
|
+
const validated = await this._validateResponse(result, schema('CartResponseSchema'));
|
|
214
|
+
return this._normalizeData(validated);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Remove an item from the cart.
|
|
218
|
+
* @handleName removeCartItem
|
|
219
|
+
* @param {number} productId - Product identifier. Example: 12345.
|
|
220
|
+
* @returns {Promise<ICartResponse | IError>} Returns the updated cart.
|
|
221
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
222
|
+
* @description This method requires user authorization (or a guest context).
|
|
223
|
+
* @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}.
|
|
224
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/users/removeCartItem removeCartItem} documentation.
|
|
225
|
+
*/
|
|
226
|
+
async removeCartItem(productId) {
|
|
227
|
+
const result = await this._fetchDelete(`/me/cart/items/${productId}`);
|
|
228
|
+
const validated = await this._validateResponse(result, schema('CartResponseSchema'));
|
|
229
|
+
return this._normalizeData(validated);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Get the current user's or guest's wishlist.
|
|
233
|
+
* @handleName getWishlist
|
|
234
|
+
* @returns {Promise<IWishlistResponse | IError>} Returns the wishlist with its items and total.
|
|
235
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
236
|
+
* @description This method requires user authorization (or a guest context).
|
|
237
|
+
* @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}.
|
|
238
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/users/getWishlist getWishlist} documentation.
|
|
239
|
+
*/
|
|
240
|
+
async getWishlist() {
|
|
241
|
+
const result = await this._fetchGet('/me/wishlist');
|
|
242
|
+
const validated = await this._validateResponse(result, schema('WishlistResponseSchema'));
|
|
243
|
+
return this._normalizeData(validated);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Replace the current user's or guest's wishlist.
|
|
247
|
+
* @handleName setWishlist
|
|
248
|
+
* @param {IWishlistSet} body - New wishlist contents. Example: `{ items: [{ productId: 1 }] }`.
|
|
249
|
+
* @returns {Promise<IWishlistResponse | IError>} Returns the updated wishlist.
|
|
250
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
251
|
+
* @description This method requires user authorization (or a guest context).
|
|
252
|
+
* @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}.
|
|
253
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/users/setWishlist setWishlist} documentation.
|
|
254
|
+
*/
|
|
255
|
+
async setWishlist(body) {
|
|
256
|
+
const result = await this._fetchPut('/me/wishlist', body);
|
|
257
|
+
const validated = await this._validateResponse(result, schema('WishlistResponseSchema'));
|
|
258
|
+
return this._normalizeData(validated);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Add an item to the wishlist.
|
|
262
|
+
* @handleName addWishlistItem
|
|
263
|
+
* @param {IWishlistAddItem} body - Item to add. Example: `{ productId: 1 }`.
|
|
264
|
+
* @returns {Promise<IWishlistResponse | IError>} Returns the updated wishlist.
|
|
265
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
266
|
+
* @description This method requires user authorization (or a guest context).
|
|
267
|
+
* @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}.
|
|
268
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/users/addWishlistItem addWishlistItem} documentation.
|
|
269
|
+
*/
|
|
270
|
+
async addWishlistItem(body) {
|
|
271
|
+
const result = await this._fetchPost('/me/wishlist/items', body);
|
|
272
|
+
const validated = await this._validateResponse(result, schema('WishlistResponseSchema'));
|
|
273
|
+
return this._normalizeData(validated);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Remove an item from the wishlist.
|
|
277
|
+
* @handleName removeWishlistItem
|
|
278
|
+
* @param {number} productId - Product identifier. Example: 12345.
|
|
279
|
+
* @returns {Promise<IWishlistResponse | IError>} Returns the updated wishlist.
|
|
280
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
281
|
+
* @description This method requires user authorization (or a guest context).
|
|
282
|
+
* @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}.
|
|
283
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/users/removeWishlistItem removeWishlistItem} documentation.
|
|
284
|
+
*/
|
|
285
|
+
async removeWishlistItem(productId) {
|
|
286
|
+
const result = await this._fetchDelete(`/me/wishlist/items/${productId}`);
|
|
287
|
+
const validated = await this._validateResponse(result, schema('WishlistResponseSchema'));
|
|
288
|
+
return this._normalizeData(validated);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Semantic (vector) search for users.
|
|
292
|
+
* @handleName getUsersByVectorSearch
|
|
293
|
+
* @param {IUsersVectorSearch} body - Vector search body. Example: `{ queryText: "john" }`.
|
|
294
|
+
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
295
|
+
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
296
|
+
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
297
|
+
* @returns {Promise<IUsersResponse | IError>} Returns an object with an array of found users and total count.
|
|
298
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
299
|
+
* @description This method performs a semantic (vector) search for users. It requires user authorization.
|
|
300
|
+
* @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}.
|
|
301
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/users/getUsersByVectorSearch getUsersByVectorSearch} documentation.
|
|
302
|
+
*/
|
|
303
|
+
async getUsersByVectorSearch(body, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
304
|
+
const query = {
|
|
305
|
+
langCode,
|
|
306
|
+
offset,
|
|
307
|
+
limit,
|
|
308
|
+
};
|
|
309
|
+
const result = await this._fetchPost(`/vector/search?` + this._queryParamsToString(query), body);
|
|
310
|
+
return this._normalizeData(result, langCode);
|
|
311
|
+
}
|
|
312
|
+
}
|