oneentry 1.0.85 → 1.0.86

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.
@@ -149,24 +149,25 @@ class AsyncModules extends syncModules_1.default {
149
149
  return options;
150
150
  }
151
151
  async browserResponse(path, options) {
152
- const response = await fetch(this._getFullPath(path), options);
153
- if (response.status == 401 && !this.state.customAuth) {
154
- const refresh = await this.refreshToken();
155
- if (refresh) {
156
- options.headers['Authorization'] = 'Bearer ' + this.state.accessToken;
157
- const secondResponse = await fetch(this._getFullPath(path), options);
158
- return await secondResponse.json();
159
- }
160
- }
161
- if (!response.ok) {
162
- const error = await response.json();
163
- throw error;
164
- }
165
152
  try {
166
- return await response.json();
153
+ const response = await fetch(this._getFullPath(path), options);
154
+ if (response.ok) {
155
+ return await response.json();
156
+ }
157
+ else {
158
+ if (response.status == 401 && !this.state.customAuth) {
159
+ const refresh = await this.refreshToken();
160
+ if (refresh) {
161
+ options.headers['Authorization'] = 'Bearer ' + this.state.accessToken;
162
+ const secondResponse = await fetch(this._getFullPath(path), options);
163
+ return await secondResponse.json();
164
+ }
165
+ }
166
+ throw response;
167
+ }
167
168
  }
168
169
  catch (e) {
169
- return response;
170
+ console.error(e);
170
171
  }
171
172
  }
172
173
  }
@@ -21,7 +21,7 @@ class SyncModules {
21
21
  if (Array.isArray(data)) {
22
22
  return this._normalizeAttr(data.map(item => this._normalizeData(item, langCode)));
23
23
  }
24
- else {
24
+ else if (typeof data === 'object' && data) {
25
25
  const normalizeData = {};
26
26
  for (let key in data) {
27
27
  if (Array.isArray(data[key])) {
@@ -39,6 +39,9 @@ class SyncModules {
39
39
  }
40
40
  return this._normalizeAttr(normalizeData);
41
41
  }
42
+ else {
43
+ return data;
44
+ }
42
45
  }
43
46
  _normalizePostBody(body, langCode = this.state.lang) {
44
47
  const formData = {};
@@ -24,6 +24,8 @@ export default class BlocksApi extends AsyncModules implements IBlocks {
24
24
  *
25
25
  * @param {string} marker - Marker of Block.
26
26
  * @param {string} [langCode] - Language code. Default "en_US"
27
+ * @param {number} [offset] - Parameter for pagination. Default 0
28
+ * @param {number} [limit] - Parameter for pagination. Default 30
27
29
  *
28
30
  * @returns Return BlocksEntity object.
29
31
  */
@@ -64,6 +64,8 @@ class BlocksApi extends asyncModules_1.default {
64
64
  *
65
65
  * @param {string} marker - Marker of Block.
66
66
  * @param {string} [langCode] - Language code. Default "en_US"
67
+ * @param {number} [offset] - Parameter for pagination. Default 0
68
+ * @param {number} [limit] - Parameter for pagination. Default 30
67
69
  *
68
70
  * @returns Return BlocksEntity object.
69
71
  */
@@ -73,9 +75,9 @@ class BlocksApi extends asyncModules_1.default {
73
75
  const customSettings = normalizeResponse.customSettings;
74
76
  if (customSettings && customSettings.hasOwnProperty('productConfig')) {
75
77
  if (customSettings.productConfig.countElementsPerRow)
76
- customSettings.countElementsPerRow = +customSettings.productConfig.countElementsPerRow;
78
+ normalizeResponse.countElementsPerRow = +customSettings.productConfig.countElementsPerRow;
77
79
  if (customSettings.productConfig.quantity)
78
- customSettings.quantity = +customSettings.productConfig.quantity;
80
+ normalizeResponse.quantity = +customSettings.productConfig.quantity;
79
81
  }
80
82
  delete normalizeResponse.customSettings;
81
83
  delete normalizeResponse.attributesSetIdentifier;
@@ -33,7 +33,7 @@ class EventsApi extends asyncModules_1.default {
33
33
  * @param productId - Product id.
34
34
  */
35
35
  async unsubscribeByMarker(marker, productId, langCode = this.state.lang) {
36
- const result = await this._fetchDelete('', {
36
+ const result = await this._fetchDelete(`/unsubscribe/marker/${marker}`, {
37
37
  "locale": langCode,
38
38
  "productId": productId
39
39
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneentry",
3
- "version": "1.0.85",
3
+ "version": "1.0.86",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",