oneentry 1.0.67 → 1.0.68

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 CHANGED
@@ -55,7 +55,7 @@ const api = defineOneEntry('your-url');
55
55
 
56
56
  The second parameter of the function takes a configuration object with the keys "token", "langCode" and "multipleResponse".
57
57
  Set the token key if your project secure "Security API Token"
58
- If your project uses user authorization, pass the user access token to the "userToken" variable to use methods that require authorization.
58
+ If your project uses user authorization, pass the user REFRESH TOKEN to the "userToken" variable to use methods that require authorization.
59
59
  Set the "langCode" to set the default language. By specifying this parameter once, you don't have to pass the langCode to the methods ONEENTRY API. If you have not passed the default language, it will be set "en_US"
60
60
  Some methods use more than one request to the CMS so that the data you receive is complete and easy to work with. Pass the value "false" for this parameter to save traffic and decide for yourself what data you need. The default value "true"
61
61
 
@@ -76,7 +76,7 @@ You can also connect a tls certificate to protect your project. In this case, do
76
76
  ```js
77
77
  const api = defineOneEntry('your-url', {
78
78
  token: 'my-token',
79
- userToken: 'user.token',
79
+ userToken: 'rerfesh.token',
80
80
  langCode:'my-langCode',
81
81
  })
82
82
  ```
@@ -1882,7 +1882,7 @@ const { Orders } = defineOneEntry('your-url');
1882
1882
  ### Orders.getOrderByMarker(marker, langCode)
1883
1883
 
1884
1884
  ```js
1885
- const value = await Orders.getOrderByMarker('my-order', 'en_US')
1885
+ const value = await Orders.getOrderByMarker('my-order')
1886
1886
  ```
1887
1887
 
1888
1888
  > This method retrieves one order storage object by marker.
@@ -1940,31 +1940,31 @@ example: [{ "identifier": "p1" }] <br>
1940
1940
  const body = {
1941
1941
  "formIdentifier": "order_form",
1942
1942
  "paymentAccountIdentifier": "stripe",
1943
- "currency": "USD",
1944
1943
  "formData": [
1945
1944
  {
1946
1945
  "marker": "name_order",
1947
- "value": "Alex"
1946
+ "value": "Alex",
1947
+ "type": "string"
1948
1948
  },
1949
1949
  {
1950
1950
  "marker": "phone_order",
1951
- "value": "+19999999999"
1951
+ "value": "+19999999999",
1952
+ "type": "string"
1952
1953
  },
1953
1954
  {
1954
1955
  "marker": "email_order",
1955
- "value": "example@oneentry.cloud"
1956
+ "value": "example@oneentry.cloud",
1957
+ "type": "string"
1956
1958
  }
1957
1959
  ],
1958
1960
  "products": [
1959
1961
  {
1960
1962
  "productId": 444,
1961
1963
  "quantity": 1,
1962
- "price": "0.1"
1963
1964
  },
1964
1965
  {
1965
1966
  "productId": 446,
1966
1967
  "quantity": 3,
1967
- "price": "123"
1968
1968
  }
1969
1969
  ]
1970
1970
  }
@@ -1977,40 +1977,28 @@ const value = await Orders.createOrder('my-order', body)
1977
1977
  Example return:
1978
1978
  ```json
1979
1979
  {
1980
- "id": 17,
1980
+ "formIdentifier": "bars",
1981
+ "paymentAccountIdentifier": "payment1",
1981
1982
  "statusIdentifier": "inprogress",
1982
- "formIdentifier": "order-form",
1983
- "paymentIdentifier": "payment-1",
1984
1983
  "formData": [
1985
- {
1986
- "marker": "name_1",
1987
- "value": "Name"
1988
- }
1989
- ],
1984
+ {
1985
+ "marker": "Name",
1986
+ "value": "Name"
1987
+ }
1988
+ ],
1990
1989
  "products": [
1991
1990
  {
1992
- "id": 1,
1993
- "title": "Floorwood Maxima Laminate, 9811 Oak Mistral",
1994
- "sku": null,
1995
- "price": "1.00",
1996
- "quantity": 10,
1997
- "previewImage": [
1998
- {
1999
- "filename": "files/project/page/36/image/20240322_77c83b02-4c82-4bea-80eb-3763c469b00e.jpg",
2000
- "downloadLink": "http://my-site.com/files/project/page/36/image/20240322_77c83b02-4c82-4bea-80eb-3763c469b00e.jpg",
2001
- "size": 296391,
2002
- "previewLink": ""
2003
- }
2004
- ]
1991
+ "productId": 1,
1992
+ "quantity": 2
1993
+ },
1994
+ {
1995
+ "productId": 2,
1996
+ "quantity": 3
2005
1997
  }
2006
1998
  ],
2007
- "totalSum": "12.00",
1999
+ "createdDate": "2024-06-04T09:57:38.328Z",
2008
2000
  "currency": "USD",
2009
- "createdDate": "2023-01-01 12:12",
2010
- "paymentAccountIdentifier": "payment-1",
2011
- "paymentAccountLocalizeInfos": {
2012
- "title": "Account 1"
2013
- }
2001
+ "totalSum": 345
2014
2002
  }
2015
2003
  ```
2016
2004
  <details>
@@ -2024,7 +2012,7 @@ example: inprogress <br>
2024
2012
  *text identifier of the form status* <br>
2025
2013
  example: order-form <br>
2026
2014
 
2027
- **paymentIdentifier** string <br>
2015
+ **paymentAccountIdentifier** string <br>
2028
2016
  *text identifier of the order payment* <br>
2029
2017
  example: payment-1 <br>
2030
2018
 
@@ -2047,17 +2035,6 @@ example: USD <br>
2047
2035
  *date when the order was created* <br>
2048
2036
  example: 2023-01-01 12:12 <br>
2049
2037
 
2050
- **price** number <br>
2051
- *price of the product per unit (at the time of ordering)* <br>
2052
- example: 20.00 <br>
2053
-
2054
- **paymentAccountIdentifier** string <br>
2055
- *textual identifier for the order payment* <br>
2056
- example: payment-1 <br>
2057
-
2058
- **paymentAccountLocalizeInfos** CommonLocalizeInfos <br>
2059
- *payment account name considering localization* <br>
2060
- example: { "title": "Account 1" } <br>
2061
2038
  </details>
2062
2039
 
2063
2040
 
@@ -2067,31 +2044,31 @@ example: { "title": "Account 1" } <br>
2067
2044
  const body = {
2068
2045
  "formIdentifier": "order_form",
2069
2046
  "paymentAccountIdentifier": "stripe",
2070
- "currency": "USD",
2071
2047
  "formData": [
2072
2048
  {
2073
2049
  "marker": "name_order",
2074
- "value": "Alex"
2050
+ "value": "Alex",
2051
+ "type": "string"
2075
2052
  },
2076
2053
  {
2077
2054
  "marker": "phone_order",
2078
- "value": "+19999999999"
2055
+ "value": "+19999999999",
2056
+ "type": "string"
2079
2057
  },
2080
2058
  {
2081
2059
  "marker": "email_order",
2082
- "value": "example@oneentry.cloud"
2060
+ "value": "example@oneentry.cloud",
2061
+ "type": "string"
2083
2062
  }
2084
2063
  ],
2085
2064
  "products": [
2086
2065
  {
2087
2066
  "productId": 444,
2088
2067
  "quantity": 1,
2089
- "price": "0.1"
2090
2068
  },
2091
2069
  {
2092
2070
  "productId": 446,
2093
2071
  "quantity": 3,
2094
- "price": "123"
2095
2072
  }
2096
2073
  ]
2097
2074
  }
@@ -2104,40 +2081,28 @@ const value = await Orders.updateOrderByMarkerAndId('my-order', body)
2104
2081
  Example return:
2105
2082
  ```json
2106
2083
  {
2107
- "id": 17,
2084
+ "formIdentifier": "bars",
2085
+ "paymentAccountIdentifier": "payment1",
2108
2086
  "statusIdentifier": "inprogress",
2109
- "formIdentifier": "order-form",
2110
- "paymentIdentifier": "payment-1",
2111
2087
  "formData": [
2112
- {
2113
- "marker": "name_1",
2114
- "value": "Name"
2115
- }
2116
- ],
2088
+ {
2089
+ "marker": "Name",
2090
+ "value": "Name"
2091
+ }
2092
+ ],
2117
2093
  "products": [
2118
2094
  {
2119
- "id": 1,
2120
- "title": "Floorwood Maxima Laminate, 9811 Oak Mistral",
2121
- "sku": null,
2122
- "price": "1.00",
2123
- "quantity": 10,
2124
- "previewImage": [
2125
- {
2126
- "filename": "files/project/page/36/image/20240322_77c83b02-4c82-4bea-80eb-3763c469b00e.jpg",
2127
- "downloadLink": "http://my-site.com/files/project/page/36/image/20240322_77c83b02-4c82-4bea-80eb-3763c469b00e.jpg",
2128
- "size": 296391,
2129
- "previewLink": ""
2130
- }
2131
- ]
2095
+ "productId": 1,
2096
+ "quantity": 2
2097
+ },
2098
+ {
2099
+ "productId": 2,
2100
+ "quantity": 3
2132
2101
  }
2133
2102
  ],
2134
- "totalSum": "12.00",
2103
+ "createdDate": "2024-06-04T09:57:38.328Z",
2135
2104
  "currency": "USD",
2136
- "createdDate": "2023-01-01 12:12",
2137
- "paymentAccountIdentifier": "payment-1",
2138
- "paymentAccountLocalizeInfos": {
2139
- "title": "Account 1"
2140
- }
2105
+ "totalSum": 345
2141
2106
  }
2142
2107
  ```
2143
2108
  <details>
@@ -2151,7 +2116,7 @@ example: inprogress <br>
2151
2116
  *text identifier of the form status* <br>
2152
2117
  example: order-form <br>
2153
2118
 
2154
- **paymentIdentifier** string <br>
2119
+ **paymentAccountIdentifier** string <br>
2155
2120
  *text identifier of the order payment* <br>
2156
2121
  example: payment-1 <br>
2157
2122
 
@@ -2174,17 +2139,6 @@ example: USD <br>
2174
2139
  *date when the order was created* <br>
2175
2140
  example: 2023-01-01 12:12 <br>
2176
2141
 
2177
- **price** number <br>
2178
- *price of the product per unit (at the time of ordering)* <br>
2179
- example: 20.00 <br>
2180
-
2181
- **paymentAccountIdentifier** string <br>
2182
- *textual identifier for the order payment* <br>
2183
- example: payment-1 <br>
2184
-
2185
- **paymentAccountLocalizeInfos** CommonLocalizeInfos <br>
2186
- *payment account name considering localization* <br>
2187
- example: { "title": "Account 1" } <br>
2188
2142
  </details>
2189
2143
 
2190
2144
 
@@ -2245,7 +2199,7 @@ example: [{ "identifier": "p1" }] <br>
2245
2199
  </details>
2246
2200
 
2247
2201
 
2248
- ### Orders.getAllOrdersByMarker(marker, langCode)
2202
+ ### Orders.getAllOrdersByMarker(marker, langCode, limit, offset)
2249
2203
 
2250
2204
  ```js
2251
2205
  const value = await Orders.getAllOrdersByMarker('my-order')
@@ -2254,45 +2208,48 @@ const value = await Orders.getAllOrdersByMarker('my-order')
2254
2208
  > This method getting all order storage object by marker. The method will add the default language to the request body. If you want to change the language, just pass it with the second argument
2255
2209
 
2256
2210
  Example return:
2211
+
2257
2212
  ```json
2258
- {
2259
- "id": 17,
2260
- "statusIdentifier": "inprogress",
2261
- "formIdentifier": "order-form",
2262
- "paymentIdentifier": "payment-1",
2263
- "formData": [
2264
- {
2265
- "marker": "name_1",
2266
- "value": "Name"
2267
- }
2268
- ],
2269
- "products": [
2270
- {
2271
- "id": 1,
2272
- "title": "Floorwood Maxima Laminate, 9811 Oak Mistral",
2273
- "sku": null,
2274
- "price": "1.00",
2275
- "quantity": 10,
2276
- "previewImage": [
2277
- {
2278
- "filename": "files/project/page/36/image/20240322_77c83b02-4c82-4bea-80eb-3763c469b00e.jpg",
2279
- "downloadLink": "http://my-site.com/files/project/page/36/image/20240322_77c83b02-4c82-4bea-80eb-3763c469b00e.jpg",
2280
- "size": 296391,
2281
- "previewLink": ""
2282
- }
2283
- ]
2284
- }
2285
- ],
2286
- "totalSum": "12.00",
2287
- "currency": "USD",
2288
- "createdDate": "2023-01-01 12:12",
2289
- "price": 20,
2290
- "paymentAccountIdentifier": "payment-1",
2291
- "paymentAccountLocalizeInfos": {
2292
- "title": "Account 1"
2293
- },
2294
- "isHistory": true
2295
- }
2213
+ [
2214
+ {
2215
+ "id": 17,
2216
+ "statusIdentifier": "inprogress",
2217
+ "paymentIdentifier": "payment-1",
2218
+ "formData": [
2219
+ {
2220
+ "marker": "name_1",
2221
+ "value": "Name",
2222
+ "type": "string"
2223
+ }
2224
+ ],
2225
+ "products": [
2226
+ {
2227
+ "id": 1,
2228
+ "title": "Floorwood Maxima Laminate, 9811 Oak Mistral",
2229
+ "sku": null,
2230
+ "price": "1.00",
2231
+ "quantity": 10,
2232
+ "previewImage": [
2233
+ {
2234
+ "filename": "files/project/page/36/image/20240322_77c83b02-4c82-4bea-80eb-3763c469b00e.jpg",
2235
+ "downloadLink": "http://my-site.com/files/project/page/36/image/20240322_77c83b02-4c82-4bea-80eb-3763c469b00e.jpg",
2236
+ "size": 296391,
2237
+ "previewLink": ""
2238
+ }
2239
+ ]
2240
+ }
2241
+ ],
2242
+ "totalSum": "12.00",
2243
+ "currency": "USD",
2244
+ "createdDate": "2023-01-01 12:12",
2245
+ "price": 20,
2246
+ "paymentAccountIdentifier": "payment-1",
2247
+ "paymentAccountLocalizeInfos": {
2248
+ "title": "Account 1"
2249
+ },
2250
+ "isHistory": true
2251
+ }
2252
+ ]
2296
2253
  ```
2297
2254
  <details>
2298
2255
  <summary>Schema</summary>
@@ -2305,9 +2262,6 @@ example: inprogress <br>
2305
2262
  *text identifier of the form status* <br>
2306
2263
  example: order-form <br>
2307
2264
 
2308
- **paymentIdentifier** string <br>
2309
- *text identifier of the order payment* <br>
2310
- example: payment-1 <br>
2311
2265
 
2312
2266
  **formData** FormDataType <br>
2313
2267
  *data submitted by the form linked to the order store* <br>
@@ -3838,7 +3792,7 @@ const { Products } = defineOneEntry('your-url');
3838
3792
  ```
3839
3793
 
3840
3794
  >This module accepts a set of user parameters called userQuery. If the parameters are not passed to the method, the default value will be applied.
3841
-
3795
+ >Some methods accept the body as a parameter for filtering. If you don't want to set up sorting, pass an empty array or don't pass anything.
3842
3796
  Parameters:
3843
3797
 
3844
3798
  ```js
@@ -20,7 +20,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
20
20
  * "authData": [
21
21
  * {
22
22
  * "marker": "login",
23
- * "value": "test"
23
+ * "value": "test@test.com"
24
24
  * },
25
25
  * {
26
26
  * "marker": "password",
@@ -36,8 +36,8 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
36
36
  * ],
37
37
  * "notificationData": {
38
38
  * "email": "test@test.com",
39
- * "phonePush": "",
40
- * "phoneSMS": "+79991234567"
39
+ * "phonePush": "+99999999999",
40
+ * "phoneSMS": "+99999999999"
41
41
  * }
42
42
  * }
43
43
  */
@@ -21,7 +21,7 @@ class AuthProviderApi extends asyncModules_1.default {
21
21
  * "authData": [
22
22
  * {
23
23
  * "marker": "login",
24
- * "value": "test"
24
+ * "value": "test@test.com"
25
25
  * },
26
26
  * {
27
27
  * "marker": "password",
@@ -37,12 +37,13 @@ class AuthProviderApi extends asyncModules_1.default {
37
37
  * ],
38
38
  * "notificationData": {
39
39
  * "email": "test@test.com",
40
- * "phonePush": "",
41
- * "phoneSMS": "+79991234567"
40
+ * "phonePush": "+99999999999",
41
+ * "phoneSMS": "+99999999999"
42
42
  * }
43
43
  * }
44
44
  */
45
45
  async signUp(marker, data, langCode = this.state.lang) {
46
+ data['langCode'] = langCode;
46
47
  const body = this._normalizePostBody(data, langCode);
47
48
  const result = await this._fetchPost(`/marker/${marker}/users/sign-up`, body);
48
49
  return this._normalizeData(result);
@@ -95,7 +96,7 @@ class AuthProviderApi extends asyncModules_1.default {
95
96
  */
96
97
  async auth(marker, data) {
97
98
  const result = await this._fetchPost(`/marker/${marker}/users/auth`, data);
98
- this.state.userToken = result.accessToken;
99
+ this.state.accessToken = result.accessToken;
99
100
  this.state.refreshToken = result.refreshToken;
100
101
  return result;
101
102
  }
@@ -108,7 +109,7 @@ class AuthProviderApi extends asyncModules_1.default {
108
109
  async refresh(marker, token) {
109
110
  const data = { refreshToken: token };
110
111
  const result = await this._fetchPost(`/marker/${marker}/users/refresh`, data);
111
- this.state.userToken = result.accessToken;
112
+ this.state.accessToken = result.accessToken;
112
113
  this.state.refreshToken = result.refreshToken;
113
114
  return result;
114
115
  }
@@ -123,7 +124,7 @@ class AuthProviderApi extends asyncModules_1.default {
123
124
  };
124
125
  const result = await this._fetchPost(`/marker/${marker}/users/logout`, data);
125
126
  if (result) {
126
- this.state.userToken = undefined;
127
+ this.state.accessToken = undefined;
127
128
  this.state.refreshToken = undefined;
128
129
  }
129
130
  return result;
@@ -30,6 +30,7 @@ interface IAuthFormData {
30
30
  }
31
31
  interface ISignUpData {
32
32
  formIdentifier: string;
33
+ langCode?: string;
33
34
  authData: Array<{
34
35
  marker: string;
35
36
  value: string;
@@ -107,7 +107,6 @@ class AsyncModules extends syncModules_1.default {
107
107
  }
108
108
  }
109
109
  async refreshToken() {
110
- console.log('ref token', this.state.refreshToken);
111
110
  const response = await fetch(this.state.url + `/api/content/users-auth-providers/marker/email/users/refresh`, {
112
111
  method: 'POST',
113
112
  headers: {
@@ -119,7 +118,7 @@ class AsyncModules extends syncModules_1.default {
119
118
  if (response.ok) {
120
119
  const result = await response.json();
121
120
  this.state.refreshToken = result.refreshToken;
122
- this.state.userToken = result.accessToken;
121
+ this.state.accessToken = result.accessToken;
123
122
  return true;
124
123
  }
125
124
  else {
@@ -140,8 +139,8 @@ class AsyncModules extends syncModules_1.default {
140
139
  if (data) {
141
140
  options['body'] = JSON.stringify(data);
142
141
  }
143
- if (this.state.userToken) {
144
- options.headers['Authorization'] = 'Bearer ' + this.state.userToken;
142
+ if (this.state.accessToken) {
143
+ options.headers['Authorization'] = 'Bearer ' + this.state.accessToken;
145
144
  }
146
145
  return options;
147
146
  }
@@ -150,6 +149,7 @@ class AsyncModules extends syncModules_1.default {
150
149
  if (response.status == 401) {
151
150
  const refresh = await this.refreshToken();
152
151
  if (refresh) {
152
+ options.headers['Authorization'] = 'Bearer ' + this.state.accessToken;
153
153
  const secondResponse = await fetch(this._getFullPath(path), options);
154
154
  return await secondResponse.json();
155
155
  }
@@ -3,7 +3,7 @@ export default class StateModule {
3
3
  url: string | undefined;
4
4
  lang: string | undefined;
5
5
  token: string | undefined;
6
- userToken: string | undefined;
6
+ accessToken: string | undefined;
7
7
  multipleResponse: boolean;
8
8
  refreshToken: string | undefined;
9
9
  constructor(url: string, config: IConfig);
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  class StateModule {
4
4
  constructor(url, config) {
5
- var _a;
5
+ var _a, _b;
6
6
  this.url = url;
7
- this.lang = config.langCode;
7
+ this.lang = (_a = config.langCode) !== null && _a !== void 0 ? _a : 'en_US';
8
8
  this.token = config.token;
9
- this.multipleResponse = (_a = config.multipleRequests) !== null && _a !== void 0 ? _a : true;
10
- this.userToken = config.userToken;
9
+ this.multipleResponse = (_b = config.multipleRequests) !== null && _b !== void 0 ? _b : true;
10
+ this.refreshToken = config.userToken;
11
11
  }
12
12
  }
13
13
  exports.default = StateModule;
@@ -23,7 +23,7 @@ declare enum Types {
23
23
  * @param {string} [token] - If your project is protected by a token, specify this token in this parameter.
24
24
  * @param {string} [langCode] - specify the default language to avoid specifying it in every request.
25
25
  * @param {boolean} [multipleRequests] - Some methods use multiple queries to make it easier to work with the API. Set this parameter to "false" to save traffic and decide for yourself what data you need.
26
- * @param {boolean} [userToken] - If your project uses user authorization, pass the user access token to the "userToken" variable to use methods that require authorization.
26
+ * @param {boolean} [userToken] - If your project uses user authorization, pass the user refresh token to the "userToken" variable to use methods that require authorization.
27
27
  */
28
28
  interface IConfig {
29
29
  token?: string;
@@ -18,19 +18,18 @@ export default class OrdersApi extends AsyncModules implements IOrdersApi {
18
18
  * @example
19
19
  * const body = {
20
20
  * "formIdentifier": "bar-orders-form",
21
- * "paymentIdentifier": "usd-payment",
21
+ * "paymentAccountIdentifier": "usd-payment",
22
22
  * "formData": {
23
23
  * "marker": "name_1",
24
- * "value": "Name"
24
+ * "value": "Name",
25
+ * "type": "string"
25
26
  * },
26
27
  * "products": [
27
28
  * {
28
29
  * "productId": 1,
29
30
  * "quantity": 2,
30
- * "price": "23.02"
31
31
  * }
32
32
  * ],
33
- * "currency": "USD"
34
33
  * }
35
34
  *
36
35
  * @returns Returns object for creating an order.
@@ -39,9 +38,11 @@ export default class OrdersApi extends AsyncModules implements IOrdersApi {
39
38
  /**
40
39
  * Getting all order storage object by marker
41
40
  * @param {number} marker - Textual identifier of the order storage object
42
- * @param {number} [langCode] Optional language field
41
+ * @param {string} [langCode] Optional language field
42
+ * @param {number} [limit] Limit parameter. Default 30
43
+ * @param {number} [offset] Offset parameter. Default 0
43
44
  */
44
- getAllOrdersByMarker(marker: string, langCode?: string): Promise<Array<IOrdersByMarkersEntity>>;
45
+ getAllOrdersByMarker(marker: string, langCode?: string, limit?: number, offset?: number): Promise<Array<IOrdersByMarkersEntity>>;
45
46
  /**
46
47
  * Changing an order in the order store
47
48
  * @param marker - The text identifier of the order storage object
@@ -52,16 +53,16 @@ export default class OrdersApi extends AsyncModules implements IOrdersApi {
52
53
  * @example
53
54
  * const body = {
54
55
  * "formIdentifier": "bar-orders-form",
55
- * "paymentIdentifier": "usd-payment",
56
+ * "paymentAccountIdentifier": "usd-payment",
56
57
  * "formData": {
57
58
  * "marker": "name_1",
58
- * "value": "Name"
59
+ * "value": "Name",
60
+ * "type": "string"
59
61
  * },
60
62
  * "products": [
61
63
  * {
62
64
  * "productId": 1,
63
- * "quantity": 2,
64
- * "price": "23.02"
65
+ * "quantity": 2
65
66
  * }
66
67
  * ],
67
68
  * "currency": "USD"
@@ -19,19 +19,18 @@ class OrdersApi extends asyncModules_1.default {
19
19
  * @example
20
20
  * const body = {
21
21
  * "formIdentifier": "bar-orders-form",
22
- * "paymentIdentifier": "usd-payment",
22
+ * "paymentAccountIdentifier": "usd-payment",
23
23
  * "formData": {
24
24
  * "marker": "name_1",
25
- * "value": "Name"
25
+ * "value": "Name",
26
+ * "type": "string"
26
27
  * },
27
28
  * "products": [
28
29
  * {
29
30
  * "productId": 1,
30
31
  * "quantity": 2,
31
- * "price": "23.02"
32
32
  * }
33
33
  * ],
34
- * "currency": "USD"
35
34
  * }
36
35
  *
37
36
  * @returns Returns object for creating an order.
@@ -46,10 +45,12 @@ class OrdersApi extends asyncModules_1.default {
46
45
  /**
47
46
  * Getting all order storage object by marker
48
47
  * @param {number} marker - Textual identifier of the order storage object
49
- * @param {number} [langCode] Optional language field
48
+ * @param {string} [langCode] Optional language field
49
+ * @param {number} [limit] Limit parameter. Default 30
50
+ * @param {number} [offset] Offset parameter. Default 0
50
51
  */
51
- async getAllOrdersByMarker(marker, langCode = this.state.lang) {
52
- const result = this._fetchGet(`/marker/${marker}/orders?langCode=${langCode}`);
52
+ async getAllOrdersByMarker(marker, langCode = this.state.lang, limit = 30, offset = 0) {
53
+ const result = await this._fetchGet(`/marker/${marker}/orders?langCode=${langCode}&limit=${limit}&offset=${offset}`);
53
54
  return this._normalizeData(result.items);
54
55
  }
55
56
  /**
@@ -62,16 +63,16 @@ class OrdersApi extends asyncModules_1.default {
62
63
  * @example
63
64
  * const body = {
64
65
  * "formIdentifier": "bar-orders-form",
65
- * "paymentIdentifier": "usd-payment",
66
+ * "paymentAccountIdentifier": "usd-payment",
66
67
  * "formData": {
67
68
  * "marker": "name_1",
68
- * "value": "Name"
69
+ * "value": "Name",
70
+ * "type": "string"
69
71
  * },
70
72
  * "products": [
71
73
  * {
72
74
  * "productId": 1,
73
- * "quantity": 2,
74
- * "price": "23.02"
75
+ * "quantity": 2
75
76
  * }
76
77
  * ],
77
78
  * "currency": "USD"
@@ -13,8 +13,14 @@ interface IOrdersApi {
13
13
  createOrder(marker: string, data: IOrderData): Promise<IBaseOrdersEntity>;
14
14
  updateOrderByMarkerAndId(marker: string, id: string, data: IOrderData, langCode?: string): Promise<IBaseOrdersEntity>;
15
15
  getAllOrders(langCode?: string, limit?: number, offset?: number): Promise<Array<IOrdersEntity>>;
16
- getAllOrdersByMarker(marker: string, langCode?: string): Promise<Array<IOrdersByMarkersEntity>>;
16
+ getAllOrdersByMarker(marker: string, langCode?: string, limit?: number, offset?: number): Promise<Array<IOrdersByMarkersEntity>>;
17
17
  }
18
+ /**
19
+ * @property {string} filename
20
+ * @property {string} downloadLink
21
+ * @property {number} size
22
+ * @property {string} previewLink
23
+ */
18
24
  interface IPicture {
19
25
  filename: string;
20
26
  downloadLink: string;
@@ -25,40 +31,49 @@ interface IOrderProducts {
25
31
  id: number;
26
32
  title: string;
27
33
  sku: string | null;
28
- price: string | null;
34
+ price: string;
29
35
  quantity: number | null;
30
- previewImage: Array<IPicture>;
36
+ previewImage: IPicture;
31
37
  }
38
+ /**
39
+ * @property {string} marker - Marker of form field.
40
+ * @property {string} value - Value
41
+ * @property {string} type - Type of value. Example "string"
42
+ */
32
43
  interface IOrdersFormData {
33
44
  marker: string;
34
45
  value: string;
46
+ type: string;
47
+ }
48
+ /**
49
+ * @interface
50
+ * @property {number} productId - Product identifier.
51
+ * @property {number} quantity - Quantity of the product.
52
+ */
53
+ interface IOrderProductData {
54
+ productId: number;
55
+ quantity: number;
35
56
  }
36
57
  /**
37
58
  * @interface
38
- * @property {number} id
39
59
  * @property {string} statusIdentifier - Text identifier of the order status.
40
60
  * @property {string} formIdentifier - Text identifier of the form status.
41
- * @property {string} paymentIdentifier - Text identifier of the order payment.
61
+ * @property {string} paymentAccountIdentifier - Text identifier of the order payment.
42
62
  * @property {Array<IOrdersFormData>} formData - Data submitted by the form linked to the order store.
43
63
  * @property {Array<IOrderProducts>} products - Array of products added to order.
44
64
  * @property {string} totalSum - Total order amount.
45
65
  * @property {string} currency - Currency used to pay for the order.
46
66
  * @property {string} createdDate - Date when the order was created.
47
- * @property {string} paymentAccountIdentifier - Textual identifier for the order payment.
48
- * @property {Record<string, any>} paymentAccountLocalizeInfos - Payment account name considering localization.
49
67
  */
50
68
  interface IBaseOrdersEntity {
51
- id: number;
52
69
  statusIdentifier: string;
53
70
  formIdentifier: string;
54
- paymentIdentifier: string;
71
+ paymentAccountIdentifier: string;
55
72
  formData: Array<IOrdersFormData>;
56
- products: Array<IOrderProducts>;
73
+ products: Array<IOrderProductData>;
57
74
  totalSum: string;
58
75
  currency: string;
59
76
  createdDate: string;
60
- paymentAccountIdentifier: string;
61
- paymentAccountLocalizeInfos: Record<string, any>;
62
77
  }
63
78
  /**
64
79
  * @interface
@@ -79,43 +94,23 @@ interface IOrdersEntity {
79
94
  identifier: string;
80
95
  }>;
81
96
  }
82
- interface IOrderMarkerData {
83
- marker: string;
84
- value: string;
85
- }
86
- /**
87
- * @interface
88
- * @property {number} productId - Product identifier.
89
- * @property {number} quantity - Quantity of the product.
90
- * @property {string} price - Price per unit of the product.
91
- */
92
- interface IOrderProductData {
93
- productId: number;
94
- quantity: number;
95
- price: string;
96
- }
97
97
  /**
98
98
  * @interface
99
99
  * @property {string} formIdentifier - Text identifier of the form object linked to the order repository.
100
- * @property {string} paymentIdentifier - Text identifier of the payment object linked to the order repository.
101
- * @property {string} [statusIdentifier] - Text identifier of the order status object (if not specified, the default status will be assigned).
102
- * @property {IOrderMarkerData | Array<IOrderMarkerData>} formData - Form data linked to the order repositor.
100
+ * @property {string} paymentAccountIdentifier - Text identifier of the payment object linked to the order repository.
101
+ * @property {IOrdersFormData | Array<IOrdersFormData>} formData - Form data linked to the order repositor.
103
102
  * @property {Array<IOrderProductData>} products - An array of ordered products.
104
- * @property {string} currency - Currency used for order paymen.
105
103
  */
106
104
  interface IOrderData {
107
105
  formIdentifier: string;
108
- paymentIdentifier: string;
109
- statusIdentifier?: string;
110
- formData: IOrderMarkerData | Array<IOrderMarkerData>;
106
+ paymentAccountIdentifier: string;
107
+ formData: IOrdersFormData | Array<IOrdersFormData>;
111
108
  products: Array<IOrderProductData>;
112
- currency: string;
113
109
  }
114
110
  /**
115
111
  * @interface
116
112
  * @property {string} statusIdentifier - Text identifier of the order status.
117
113
  * @property {string} formIdentifier - Text identifier of the form status.
118
- * @property {string} paymentIdentifier - Text identifier of the order payment.
119
114
  * @property {Array<IOrdersFormData>} formData - Data submitted by the form linked to the order store.
120
115
  * @property {Array<IOrderProducts>} products - Array of products added to order.
121
116
  * @property {string} totalSum - Total order amount.
@@ -129,7 +124,6 @@ interface IOrderData {
129
124
  interface IOrdersByMarkersEntity {
130
125
  statusIdentifier: string;
131
126
  formIdentifier: string;
132
- paymentIdentifier: string;
133
127
  formData: Array<IOrdersFormData>;
134
128
  products: Array<IOrderProducts>;
135
129
  totalSum: string;
@@ -140,4 +134,4 @@ interface IOrdersByMarkersEntity {
140
134
  paymentAccountLocalizeInfos: Record<string, any>;
141
135
  isHistory: boolean;
142
136
  }
143
- export { IOrdersEntity, IBaseOrdersEntity, IOrderProducts, IPicture, IOrdersApi, IOrderData, IOrderProductData, IOrderMarkerData, IOrdersFormData, IOrdersByMarkersEntity };
137
+ export { IOrdersEntity, IBaseOrdersEntity, IOrderProducts, IPicture, IOrdersApi, IOrderData, IOrderProductData, IOrdersFormData, IOrdersByMarkersEntity };
@@ -12,7 +12,7 @@ export default class ProductApi extends AsyncModules implements IProductApi {
12
12
  private _defaultQuery;
13
13
  /**
14
14
  * Search for all products with pagination and filter.
15
- * @param {Array<IFilterParams>} body - Request body.
15
+ * @param {Array<IFilterParams>} body - Request body. Default [].
16
16
  * @param {string} [langCode] - Language code parameter. Default "en_US"
17
17
  * @param {IProductsQuery} [userQuery] - Optional set query parameters.
18
18
  * @param {number} [userQuery.limit] - Optional parameter for pagination, default is 0
@@ -54,7 +54,7 @@ export default class ProductApi extends AsyncModules implements IProductApi {
54
54
  *
55
55
  * @returns Array with ProductEntity objects
56
56
  */
57
- getProducts(body: Array<IFilterParams>, langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
57
+ getProducts(body?: Array<IFilterParams>, langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
58
58
  /**
59
59
  * Search for all product page objects with pagination that do not have a category.
60
60
  *
@@ -124,7 +124,7 @@ export default class ProductApi extends AsyncModules implements IProductApi {
124
124
  *
125
125
  * @returns Array with ProductEntity objects
126
126
  */
127
- getProductsByPageId(id: number, body: Array<IFilterParams>, langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
127
+ getProductsByPageId(id: number, body?: Array<IFilterParams>, langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
128
128
  /**
129
129
  * Search for information about products and prices for the selected category.
130
130
  * @param {string} url - Page url.
@@ -193,7 +193,7 @@ export default class ProductApi extends AsyncModules implements IProductApi {
193
193
  *
194
194
  * @returns Array with ProductEntity objects
195
195
  */
196
- getProductsByPageUrl(url: string, body: Array<IFilterParams>, langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
196
+ getProductsByPageUrl(url: string, body?: Array<IFilterParams>, langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
197
197
  /**
198
198
  * Find all related product page objects.
199
199
  *
@@ -22,7 +22,7 @@ class ProductApi extends asyncModules_1.default {
22
22
  }
23
23
  /**
24
24
  * Search for all products with pagination and filter.
25
- * @param {Array<IFilterParams>} body - Request body.
25
+ * @param {Array<IFilterParams>} body - Request body. Default [].
26
26
  * @param {string} [langCode] - Language code parameter. Default "en_US"
27
27
  * @param {IProductsQuery} [userQuery] - Optional set query parameters.
28
28
  * @param {number} [userQuery.limit] - Optional parameter for pagination, default is 0
@@ -64,8 +64,8 @@ class ProductApi extends asyncModules_1.default {
64
64
  *
65
65
  * @returns Array with ProductEntity objects
66
66
  */
67
- async getProducts(body, langCode = this.state.lang, userQuery) {
68
- const query = { ...this._defaultQuery, ...userQuery };
67
+ async getProducts(body = [], langCode = this.state.lang, userQuery) {
68
+ const query = { ...this._defaultQuery, ...userQuery, langCode };
69
69
  const result = await this._fetchPost(`/all?` + this._queryParamsToString(query), body);
70
70
  return this._dataPostProcess(result.items, langCode);
71
71
  }
@@ -142,7 +142,7 @@ class ProductApi extends asyncModules_1.default {
142
142
  *
143
143
  * @returns Array with ProductEntity objects
144
144
  */
145
- async getProductsByPageId(id, body, langCode = this.state.lang, userQuery) {
145
+ async getProductsByPageId(id, body = [], langCode = this.state.lang, userQuery) {
146
146
  const query = { ...this._defaultQuery, ...userQuery };
147
147
  const result = await this._fetchPost(`/page/${id}?` + this._queryParamsToString(query), body);
148
148
  return this._dataPostProcess(result.items, langCode);
@@ -219,7 +219,7 @@ class ProductApi extends asyncModules_1.default {
219
219
  *
220
220
  * @returns Array with ProductEntity objects
221
221
  */
222
- async getProductsByPageUrl(url, body, langCode = this.state.lang, userQuery) {
222
+ async getProductsByPageUrl(url, body = [], langCode = this.state.lang, userQuery) {
223
223
  const query = { ...this._defaultQuery, ...userQuery };
224
224
  const result = await this._fetchPost(`/page/url/${url}?` + this._queryParamsToString(query), body);
225
225
  return this._dataPostProcess(result.items, langCode);
@@ -22,11 +22,11 @@ import { IBlocksResponse } from "../blocks/blocksInterfaces";
22
22
  * @property {function} searchProduct - Quick search for product page objects with limited output.
23
23
  */
24
24
  interface IProductApi {
25
- getProducts(body: Array<IFilterParams>, langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
25
+ getProducts(body?: Array<IFilterParams>, langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
26
26
  getProductsEmptyPage(langCode?: LangType, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
27
- getProductsByPageId(id: number, body: Array<IFilterParams>, langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
27
+ getProductsByPageId(id: number, body?: Array<IFilterParams>, langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
28
28
  getProductsPriceByPageUrl(url: string, userQuery?: IProductsQuery): Promise<Array<IProductInfo>>;
29
- getProductsByPageUrl(url: string, body: Array<IFilterParams>, langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
29
+ getProductsByPageUrl(url: string, body?: Array<IFilterParams>, langCode?: string, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
30
30
  getRelatedProductsById(id: number, langCode?: LangType, userQuery?: IProductsQuery): Promise<Array<IProductsEntity>>;
31
31
  getProductById(id: number, langCode: LangType): Promise<IProductsEntity>;
32
32
  getProductBlockById(id: number): Promise<Array<IBlocksResponse>>;
@@ -15,7 +15,7 @@ class UsersApi extends asyncModules_1.default {
15
15
  */
16
16
  async getUser(langCode = this.state.lang) {
17
17
  const result = await this._fetchGet(`/me?langCode=${langCode}`);
18
- return result;
18
+ return this._normalizeData(result);
19
19
  }
20
20
  /**
21
21
  * Updating a single user object.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneentry",
3
- "version": "1.0.67",
3
+ "version": "1.0.68",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",