oneentry 1.0.99 → 1.0.101
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.
|
@@ -152,7 +152,12 @@ class AsyncModules extends syncModules_1.default {
|
|
|
152
152
|
try {
|
|
153
153
|
const response = await fetch(this._getFullPath(path), options);
|
|
154
154
|
if (response.ok) {
|
|
155
|
-
|
|
155
|
+
try {
|
|
156
|
+
return await response.json();
|
|
157
|
+
}
|
|
158
|
+
catch (e) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
156
161
|
}
|
|
157
162
|
else {
|
|
158
163
|
if (response.status == 401 && !this.state.customAuth) {
|
|
@@ -163,37 +168,38 @@ class AsyncModules extends syncModules_1.default {
|
|
|
163
168
|
return await secondResponse.json();
|
|
164
169
|
}
|
|
165
170
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
171
|
+
const status = response.status;
|
|
172
|
+
const res = await response.json();
|
|
173
|
+
if (status == 400) {
|
|
174
|
+
if (this.state.errorsFunctions && this.state.errorsFunctions["400"]) {
|
|
175
|
+
this.state.errorsFunctions["400"](res);
|
|
169
176
|
}
|
|
170
177
|
}
|
|
171
|
-
else if (
|
|
172
|
-
if (this.state.errorsFunctions["401"]) {
|
|
173
|
-
this.state.errorsFunctions["401"](
|
|
178
|
+
else if (status == 401) {
|
|
179
|
+
if (this.state.errorsFunctions && this.state.errorsFunctions["401"]) {
|
|
180
|
+
this.state.errorsFunctions["401"](res);
|
|
174
181
|
}
|
|
175
182
|
}
|
|
176
|
-
else if (
|
|
177
|
-
if (this.state.errorsFunctions["403"]) {
|
|
178
|
-
this.state.errorsFunctions["403"](
|
|
183
|
+
else if (status == 403) {
|
|
184
|
+
if (this.state.errorsFunctions && this.state.errorsFunctions["403"]) {
|
|
185
|
+
this.state.errorsFunctions["403"](res);
|
|
179
186
|
}
|
|
180
187
|
}
|
|
181
|
-
else if (
|
|
182
|
-
if (this.state.errorsFunctions["404"]) {
|
|
183
|
-
this.state.errorsFunctions["404"](
|
|
188
|
+
else if (status == 404) {
|
|
189
|
+
if (this.state.errorsFunctions && this.state.errorsFunctions["404"]) {
|
|
190
|
+
this.state.errorsFunctions["404"](res);
|
|
184
191
|
}
|
|
185
192
|
}
|
|
186
|
-
else if (
|
|
187
|
-
if (this.state.errorsFunctions["500"]) {
|
|
188
|
-
this.state.errorsFunctions["500"](
|
|
193
|
+
else if (status == 500) {
|
|
194
|
+
if (this.state.errorsFunctions && this.state.errorsFunctions["500"]) {
|
|
195
|
+
this.state.errorsFunctions["500"](res);
|
|
189
196
|
}
|
|
190
197
|
}
|
|
191
198
|
if (this.state.isShell) {
|
|
192
|
-
return
|
|
199
|
+
return res;
|
|
193
200
|
}
|
|
194
201
|
else {
|
|
195
|
-
|
|
196
|
-
throw error;
|
|
202
|
+
throw res;
|
|
197
203
|
}
|
|
198
204
|
}
|
|
199
205
|
}
|
package/dist/base/stateModule.js
CHANGED
|
@@ -9,6 +9,13 @@ class StateModule {
|
|
|
9
9
|
this.multipleResponse = !!((_b = config.traficLimit) !== null && _b !== void 0 ? _b : true);
|
|
10
10
|
this.refreshToken = (_d = (_c = config.auth) === null || _c === void 0 ? void 0 : _c.refreshToken) !== null && _d !== void 0 ? _d : undefined;
|
|
11
11
|
this.customAuth = (_f = (_e = config.auth) === null || _e === void 0 ? void 0 : _e.customAuth) !== null && _f !== void 0 ? _f : false;
|
|
12
|
+
this.errorsFunctions = {
|
|
13
|
+
'400': null,
|
|
14
|
+
'401': null,
|
|
15
|
+
'403': null,
|
|
16
|
+
'404': null,
|
|
17
|
+
'500': null
|
|
18
|
+
};
|
|
12
19
|
this.saveFunction = (_h = (_g = config.auth) === null || _g === void 0 ? void 0 : _g.saveFunction) !== null && _h !== void 0 ? _h : null;
|
|
13
20
|
if (config.errors) {
|
|
14
21
|
this.isShell = (_j = config.errors.isShell) !== null && _j !== void 0 ? _j : true;
|
|
@@ -22,17 +22,19 @@ export default class EventsApi extends AsyncModules implements IEvents {
|
|
|
22
22
|
*
|
|
23
23
|
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
24
24
|
* @param {string} marker - Event marker.
|
|
25
|
-
* @param {number} langCode - Language code.
|
|
25
|
+
* @param {number} [langCode] - Language code.
|
|
26
26
|
* @param {string} productId - Product id.
|
|
27
|
+
* @param {number} [threshold] - Threshold value for comparing numerical value.
|
|
27
28
|
*/
|
|
28
|
-
subscribeByMarker(marker: string, productId: number, langCode?: string): Promise<any | IError>;
|
|
29
|
+
subscribeByMarker(marker: string, productId: number, langCode?: string, threshold?: number): Promise<any | IError>;
|
|
29
30
|
/**
|
|
30
31
|
* Unsubscribing to an event on a product.
|
|
31
32
|
*
|
|
32
33
|
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
33
34
|
* @param {string} marker - Event marker.
|
|
34
|
-
* @param {number} langCode - Language code.
|
|
35
|
+
* @param {number} [langCode] - Language code.
|
|
35
36
|
* @param {string} productId - Product id.
|
|
37
|
+
* @param {number} [threshold] - Threshold value for comparing numerical value.
|
|
36
38
|
*/
|
|
37
|
-
unsubscribeByMarker(marker: string, productId: number, langCode?: string): Promise<any | IError>;
|
|
39
|
+
unsubscribeByMarker(marker: string, productId: number, langCode?: string, threshold?: number): Promise<any | IError>;
|
|
38
40
|
}
|
package/dist/events/eventsApi.js
CHANGED
|
@@ -24,14 +24,19 @@ class EventsApi extends asyncModules_1.default {
|
|
|
24
24
|
*
|
|
25
25
|
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
26
26
|
* @param {string} marker - Event marker.
|
|
27
|
-
* @param {number} langCode - Language code.
|
|
27
|
+
* @param {number} [langCode] - Language code.
|
|
28
28
|
* @param {string} productId - Product id.
|
|
29
|
+
* @param {number} [threshold] - Threshold value for comparing numerical value.
|
|
29
30
|
*/
|
|
30
|
-
async subscribeByMarker(marker, productId, langCode = this.state.lang) {
|
|
31
|
-
const
|
|
31
|
+
async subscribeByMarker(marker, productId, langCode = this.state.lang, threshold = null) {
|
|
32
|
+
const data = {
|
|
32
33
|
"locale": langCode,
|
|
33
|
-
"productId": productId
|
|
34
|
-
}
|
|
34
|
+
"productId": productId,
|
|
35
|
+
};
|
|
36
|
+
if (threshold) {
|
|
37
|
+
data.threshold = threshold;
|
|
38
|
+
}
|
|
39
|
+
const result = await this._fetchPost(`/subscribe/marker/${marker}`, data);
|
|
35
40
|
return result;
|
|
36
41
|
}
|
|
37
42
|
/**
|
|
@@ -39,14 +44,19 @@ class EventsApi extends asyncModules_1.default {
|
|
|
39
44
|
*
|
|
40
45
|
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
41
46
|
* @param {string} marker - Event marker.
|
|
42
|
-
* @param {number} langCode - Language code.
|
|
47
|
+
* @param {number} [langCode] - Language code.
|
|
43
48
|
* @param {string} productId - Product id.
|
|
49
|
+
* @param {number} [threshold] - Threshold value for comparing numerical value.
|
|
44
50
|
*/
|
|
45
|
-
async unsubscribeByMarker(marker, productId, langCode = this.state.lang) {
|
|
46
|
-
const
|
|
51
|
+
async unsubscribeByMarker(marker, productId, langCode = this.state.lang, threshold = null) {
|
|
52
|
+
const data = {
|
|
47
53
|
"locale": langCode,
|
|
48
|
-
"productId": productId
|
|
49
|
-
}
|
|
54
|
+
"productId": productId,
|
|
55
|
+
};
|
|
56
|
+
if (threshold) {
|
|
57
|
+
data.threshold = threshold;
|
|
58
|
+
}
|
|
59
|
+
const result = await this._fetchDelete(`/unsubscribe/marker/${marker}`, data);
|
|
50
60
|
return result;
|
|
51
61
|
}
|
|
52
62
|
}
|
|
@@ -8,8 +8,8 @@ import { IError } from "../base/utils";
|
|
|
8
8
|
*/
|
|
9
9
|
interface IEvents {
|
|
10
10
|
getAllSubscriptions(limit?: number, offset?: number): Promise<ISubscriptions | IError>;
|
|
11
|
-
subscribeByMarker(marker: string, productId: number, langCode
|
|
12
|
-
unsubscribeByMarker(marker: string, productId: number, langCode
|
|
11
|
+
subscribeByMarker(marker: string, productId: number, langCode?: string, threshold?: number): Promise<any | IError>;
|
|
12
|
+
unsubscribeByMarker(marker: string, productId: number, langCode?: string, threshold?: number): Promise<any | IError>;
|
|
13
13
|
}
|
|
14
14
|
interface ISubscriptions {
|
|
15
15
|
total: number;
|