oneentry 1.0.99 → 1.0.100

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.
@@ -163,37 +163,38 @@ class AsyncModules extends syncModules_1.default {
163
163
  return await secondResponse.json();
164
164
  }
165
165
  }
166
- else if (response.status == 400) {
167
- if (this.state.errorsFunctions["400"]) {
168
- this.state.errorsFunctions["400"](await response.json());
166
+ const status = response.status;
167
+ const res = await response.json();
168
+ if (status == 400) {
169
+ if (this.state.errorsFunctions && this.state.errorsFunctions["400"]) {
170
+ this.state.errorsFunctions["400"](res);
169
171
  }
170
172
  }
171
- else if (response.status == 401) {
172
- if (this.state.errorsFunctions["401"]) {
173
- this.state.errorsFunctions["401"](await response.json());
173
+ else if (status == 401) {
174
+ if (this.state.errorsFunctions && this.state.errorsFunctions["401"]) {
175
+ this.state.errorsFunctions["401"](res);
174
176
  }
175
177
  }
176
- else if (response.status == 403) {
177
- if (this.state.errorsFunctions["403"]) {
178
- this.state.errorsFunctions["403"](await response.json());
178
+ else if (status == 403) {
179
+ if (this.state.errorsFunctions && this.state.errorsFunctions["403"]) {
180
+ this.state.errorsFunctions["403"](res);
179
181
  }
180
182
  }
181
- else if (response.status == 404) {
182
- if (this.state.errorsFunctions["404"]) {
183
- this.state.errorsFunctions["404"](await response.json());
183
+ else if (status == 404) {
184
+ if (this.state.errorsFunctions && this.state.errorsFunctions["404"]) {
185
+ this.state.errorsFunctions["404"](res);
184
186
  }
185
187
  }
186
- else if (response.status == 500) {
187
- if (this.state.errorsFunctions["500"]) {
188
- this.state.errorsFunctions["500"](await response.json());
188
+ else if (status == 500) {
189
+ if (this.state.errorsFunctions && this.state.errorsFunctions["500"]) {
190
+ this.state.errorsFunctions["500"](res);
189
191
  }
190
192
  }
191
193
  if (this.state.isShell) {
192
- return await response.json();
194
+ return res;
193
195
  }
194
196
  else {
195
- const error = await response.json();
196
- throw error;
197
+ throw res;
197
198
  }
198
199
  }
199
200
  }
@@ -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;
@@ -24,8 +24,9 @@ export default class EventsApi extends AsyncModules implements IEvents {
24
24
  * @param {string} marker - Event marker.
25
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
  *
@@ -33,6 +34,7 @@ export default class EventsApi extends AsyncModules implements IEvents {
33
34
  * @param {string} marker - Event marker.
34
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
  }
@@ -26,12 +26,17 @@ class EventsApi extends asyncModules_1.default {
26
26
  * @param {string} marker - Event marker.
27
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 result = await this._fetchPost(`/subscribe/marker/${marker}`, {
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
  /**
@@ -41,12 +46,17 @@ class EventsApi extends asyncModules_1.default {
41
46
  * @param {string} marker - Event marker.
42
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 result = await this._fetchDelete(`/unsubscribe/marker/${marker}`, {
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: string): Promise<any | IError>;
12
- unsubscribeByMarker(marker: string, productId: number, langCode: string): Promise<any | IError>;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneentry",
3
- "version": "1.0.99",
3
+ "version": "1.0.100",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",