oneentry 1.0.39 → 1.0.41

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.
Files changed (41) hide show
  1. package/README.md +42 -133
  2. package/dist/admins/adminsApi.d.ts +2 -1
  3. package/dist/admins/adminsApi.js +3 -3
  4. package/dist/attribute-sets/attributeSetsApi.d.ts +2 -1
  5. package/dist/attribute-sets/attributeSetsApi.js +4 -4
  6. package/dist/base/oneEntry.d.ts +5 -6
  7. package/dist/base/oneEntry.js +21 -67
  8. package/dist/base/utils.d.ts +5 -1
  9. package/dist/blocks/blocksApi.d.ts +2 -1
  10. package/dist/blocks/blocksApi.js +3 -3
  11. package/dist/file-uploding/fileUploadingApi.d.ts +2 -1
  12. package/dist/file-uploding/fileUploadingApi.js +2 -2
  13. package/dist/forms/formsApi.d.ts +2 -1
  14. package/dist/forms/formsApi.js +4 -4
  15. package/dist/formsData/formsDataApi.d.ts +2 -1
  16. package/dist/formsData/formsDataApi.js +4 -4
  17. package/dist/formsData/formsDataInterfaces.d.ts +4 -7
  18. package/dist/general-types/GeneralTypesApi.d.ts +2 -1
  19. package/dist/general-types/GeneralTypesApi.js +2 -2
  20. package/dist/index.d.ts +5 -1
  21. package/dist/index.js +20 -17
  22. package/dist/locales/localesApi.d.ts +2 -1
  23. package/dist/locales/localesApi.js +2 -2
  24. package/dist/markers/markersApi.d.ts +2 -1
  25. package/dist/markers/markersApi.js +2 -2
  26. package/dist/menus/menusApi.d.ts +2 -1
  27. package/dist/menus/menusApi.js +2 -2
  28. package/dist/pages/pagesApi.d.ts +19 -19
  29. package/dist/pages/pagesApi.js +36 -36
  30. package/dist/pages/pagesInterfaces.d.ts +1 -1
  31. package/dist/product-statuses/productStatusesApi.d.ts +2 -1
  32. package/dist/product-statuses/productStatusesApi.js +2 -2
  33. package/dist/products/productsApi.d.ts +16 -16
  34. package/dist/products/productsApi.js +35 -56
  35. package/dist/system/systemApi.d.ts +2 -1
  36. package/dist/system/systemApi.js +2 -2
  37. package/dist/templates/templatesApi.d.ts +2 -2
  38. package/dist/templates/templatesApi.js +2 -2
  39. package/dist/templates-preview/templatesPreviewApi.d.ts +2 -1
  40. package/dist/templates-preview/templatesPreviewApi.js +2 -2
  41. package/package.json +1 -1
package/README.md CHANGED
@@ -50,6 +50,11 @@ Or
50
50
  const api = defineOneEntry('your-url')
51
51
  ```
52
52
 
53
+ The second parameter of the function takes a configuration object with the keys "token" and "langCode".
54
+ Set the token key if your project secure "Security API Token"
55
+
56
+ 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"
57
+
53
58
  >If you chose token protection to ensure connection security, just pass your token to the function as an optional parameter.
54
59
 
55
60
  You can get a token as follows
@@ -65,12 +70,28 @@ Also, you can connect a tls certificate to secure your project. In this case, do
65
70
 
66
71
 
67
72
  ```js
68
- const api = defineOneEntry('your-url', 'your-token')
73
+ const api = defineOneEntry('your-url', {token: 'my-token', langCode:'my-langCode'})
69
74
  ```
75
+ Now you can use the following links to jump to specific entries:
76
+ - [Admins](#admins)
77
+ - [AttributesSets](#attributessets)
78
+ - [Blocks](#blocks)
79
+ - [Forms](#forms)
80
+ - [FormData](#formdata)
81
+ - [FileUploading](#fileuploading)
82
+ - [GeneralTypes](#generaltypes)
83
+ - [Locales](#locales)
84
+ - [Markers](#markers)
85
+ - [Menus](#menus)
86
+ - [Pages](#pages)
87
+ - [Products](#products)
88
+ - [ProductStatuses](#productstatuses)
89
+ - [System](#system)
90
+ - [Templates](#templates)
91
+ - [TemplatePreviews](#templatepreviews)
70
92
 
71
93
 
72
-
73
- ## Admins
94
+ <h2 id="admins"> Admins </h2>
74
95
 
75
96
 
76
97
  ```js
@@ -141,7 +162,7 @@ example: 192
141
162
 
142
163
 
143
164
 
144
- ## AttributesSets
165
+ <h2 id="attributessets"> AttributesSets </h2>
145
166
 
146
167
  ```js
147
168
  const { AttributesSets } = defineOneEntry('your-url');
@@ -307,8 +328,7 @@ example: List [ OrderedMap { "title": "red", "value": 1, "position": 1, "extende
307
328
  ---
308
329
 
309
330
 
310
-
311
- ## Blocks
331
+ <h2 id="blocks"> Blocks </h2>
312
332
 
313
333
  ```js
314
334
  const { Blocks } = defineOneEntry('your-url');
@@ -412,8 +432,7 @@ example: null
412
432
 
413
433
 
414
434
 
415
-
416
- ## FileUploading
435
+ <h2 id="fileuploading"> FileUploading </h2>
417
436
 
418
437
  const { FileUploading } = defineOneEntry('your-url');
419
438
 
@@ -496,8 +515,8 @@ Example return:
496
515
 
497
516
 
498
517
 
518
+ <h2 id="forms"> Forms </h2>
499
519
 
500
- ## Forms
501
520
 
502
521
  const { Forms } = defineOneEntry('your-url');
503
522
 
@@ -705,8 +724,7 @@ example: List [ OrderedMap { "type": "list", "marker": "l1", "position": 2, "lis
705
724
  ---
706
725
 
707
726
 
708
-
709
- ## FormData
727
+ <h2 id="formdata"> FormData </h2>
710
728
 
711
729
  const { FormData } = defineOneEntry('your-url');
712
730
 
@@ -852,8 +870,7 @@ example: test-form
852
870
  ---
853
871
 
854
872
 
855
-
856
- ## GeneralTypes
873
+ <h2 id="generaltypes"> GeneralTypes </h2>
857
874
 
858
875
  const { GeneralTypes } = defineOneEntry('your-url');
859
876
 
@@ -892,8 +909,7 @@ Enum:
892
909
  ---
893
910
 
894
911
 
895
-
896
- ## Locales
912
+ <h2 id="locales"> Locales </h2>
897
913
 
898
914
  ```js
899
915
  const { Locales } = defineOneEntry('your-url')
@@ -963,8 +979,8 @@ description:position number
963
979
 
964
980
 
965
981
 
982
+ <h2 id="markers"> Markers </h2>
966
983
 
967
- ## Markers
968
984
 
969
985
  ```js
970
986
  const { Markers } = defineOneEntry('your-url')
@@ -1134,6 +1150,7 @@ example: OrderedMap { "en_US": OrderedMap { "title": "My marker" } }
1134
1150
 
1135
1151
  ---
1136
1152
 
1153
+ <h2 id="menus"> Menus </h2>
1137
1154
 
1138
1155
  ## Menus
1139
1156
 
@@ -1198,70 +1215,12 @@ example: List [ OrderedMap { "id": 11, "pageUrl": "122", "localizeInfos": Ordere
1198
1215
 
1199
1216
  ---
1200
1217
 
1201
-
1202
- ## Pages
1218
+ <h2 id="pages"> Pages </h2>
1203
1219
 
1204
1220
  ```js
1205
1221
  const { Pages } = defineOneEntry('your-url')
1206
1222
  ```
1207
1223
 
1208
- > In some methods, the langcode parameter can be either a string or an array of strings. It depends on which set of values will contain "attributeValues" and "localizeInfos"
1209
-
1210
- Example:
1211
-
1212
- ```
1213
- const value = await Pages.getRootPages('en_US')
1214
-
1215
- "localizeInfos": {
1216
- {
1217
- "title": "Catalog",
1218
- "content": "Content from catalog",
1219
- "menuTitle": "Catalog"
1220
- }
1221
- },
1222
- "attributeValues": {
1223
- {
1224
- "marker": {
1225
- "value": "Value",
1226
- "type": "string"
1227
- }
1228
- }
1229
- }
1230
- ```
1231
-
1232
- Or
1233
-
1234
- ```
1235
- const value = await Pages.getRootPages([ 'en_US', 'it_IT' ])
1236
-
1237
- "localizeInfos": {
1238
- en_US: {
1239
- "title": "Catalog",
1240
- "content": "Content from catalog",
1241
- "menuTitle": "Catalog"
1242
- },
1243
- it_IT: {
1244
- "title": "Catalogo",
1245
- "content": "Contenuto dal catalogo",
1246
- "menuTitle": "Catalogo"
1247
- }
1248
- },
1249
- "attributeValues": {
1250
- en_US: {
1251
- "marker": {
1252
- "value": "Value",
1253
- "type": "string"
1254
- }
1255
- },
1256
- it_IT: {
1257
- "marker": {
1258
- "value": "Valore",
1259
- "type": "string"
1260
- }
1261
- }
1262
- }
1263
- ```
1264
-
1265
1224
  ### Pages.getRootPages(langCode)
1266
1225
 
1267
1226
  ```js
@@ -2217,8 +2176,8 @@ Example return:
2217
2176
  ---
2218
2177
 
2219
2178
 
2179
+ <h2 id="products"> Products </h2>
2220
2180
 
2221
- ## Products
2222
2181
 
2223
2182
  ```js
2224
2183
  const { Products } = defineOneEntry('your-url')
@@ -2258,62 +2217,6 @@ const userQuery = {
2258
2217
  >
2259
2218
  > 'nexs' - Does not exist
2260
2219
 
2261
- In some methods, the langcode parameter (default 'en_US') can be either a string or an array of strings. It depends on which set of values will contain "attributeValues" and "localizeInfos"
2262
-
2263
- Example
2264
-
2265
- ```
2266
- const value = await Products.getProducts('en_US')
2267
-
2268
- "localizeInfos": {
2269
- {
2270
- "title": "Catalog",
2271
- "content": "Content from catalog",
2272
- "menuTitle": "Catalog"
2273
- }
2274
- },
2275
- "attributeValues": {
2276
- {
2277
- "marker": {
2278
- "value": "Value",
2279
- "type": "string"
2280
- }
2281
- }
2282
- }
2283
- ```
2284
-
2285
- Or
2286
-
2287
- ```
2288
- const value = await Products.getProducts([ 'en_US', 'it_IT' ])
2289
-
2290
- "localizeInfos": {
2291
- en_US: {
2292
- "title": "Catalog",
2293
- "content": "Content from catalog",
2294
- "menuTitle": "Catalog"
2295
- },
2296
- it_IT: {
2297
- "title": "Catalogo",
2298
- "content": "Contenuto dal catalogo",
2299
- "menuTitle": "Catalogo"
2300
- }
2301
- },
2302
- "attributeValues": {
2303
- en_US: {
2304
- "marker": {
2305
- "value": "Value",
2306
- "type": "string"
2307
- }
2308
- },
2309
- it_IT: {
2310
- "marker": {
2311
- "value": "Valore",
2312
- "type": "string"
2313
- }
2314
- }
2315
- }
2316
- ```
2317
2220
 
2318
2221
  ### Products.getProducts(langCode, userQuery)
2319
2222
 
@@ -3137,8 +3040,8 @@ example: my-template-short
3137
3040
  ---
3138
3041
 
3139
3042
 
3043
+ <h2 id="productstatuses"> ProductStatuses </h2>
3140
3044
 
3141
- ## ProductStatuses
3142
3045
 
3143
3046
  ```js
3144
3047
  const { ProductStatuses } = defineOneEntry('your-url');
@@ -3298,6 +3201,7 @@ true
3298
3201
  ---
3299
3202
 
3300
3203
 
3204
+ <h2 id="system"> System </h2>
3301
3205
 
3302
3206
  ## System
3303
3207
 
@@ -3322,6 +3226,8 @@ const value = await System.test500()
3322
3226
  > This method allows you to redirect to the error page.
3323
3227
 
3324
3228
 
3229
+ <h2 id="templates"> Templates </h2>
3230
+
3325
3231
  ## Templates
3326
3232
 
3327
3233
  ```js
@@ -3482,6 +3388,9 @@ general type name
3482
3388
 
3483
3389
  ---
3484
3390
 
3391
+
3392
+ <h2 id="templatepreviews"> TemplatePreviews </h2>
3393
+
3485
3394
  ## TemplatePreviews
3486
3395
 
3487
3396
  ```js
@@ -1,10 +1,11 @@
1
1
  import OneEntry from "../base/oneEntry";
2
2
  import { IAdminEntity, IAdmins } from "./adminsInterfaces";
3
+ import { IConfig } from "../base/utils";
3
4
  /**
4
5
  * Controllers for working with users - admins
5
6
  */
6
7
  export default class AdminsApi extends OneEntry implements IAdmins {
7
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
8
9
  /**
9
10
  * Get all user objects - admins.
10
11
  *
@@ -5,8 +5,8 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for working with users - admins
6
6
  */
7
7
  class AdminsApi extends oneEntry_1.default {
8
- constructor(url, token) {
9
- super(url, token);
8
+ constructor(url, config) {
9
+ super(url, config);
10
10
  this._url += '/api/content/admins';
11
11
  }
12
12
  /**
@@ -18,7 +18,7 @@ class AdminsApi extends oneEntry_1.default {
18
18
  *
19
19
  * @returns Returns all AdminEntity user objects
20
20
  */
21
- async getAdminsInfo(langCode = 'en_US', offset = 0, limit = 30) {
21
+ async getAdminsInfo(langCode = this._defaultLangCode, offset = 0, limit = 30) {
22
22
  const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
23
23
  return this._normalizeData(result);
24
24
  }
@@ -1,10 +1,11 @@
1
1
  import OneEntry from "../base/oneEntry";
2
2
  import { IAttributesSets, IAttributesSetsEntity } from "./attributeSetsInterfaces";
3
+ import { IConfig } from "../base/utils";
3
4
  /**
4
5
  * Controllers for working with attributes.
5
6
  */
6
7
  export default class AttributesSetsApi extends OneEntry implements IAttributesSets {
7
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
8
9
  /**
9
10
  * Get all attributes with data from the attribute sets.
10
11
  *
@@ -5,8 +5,8 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for working with attributes.
6
6
  */
7
7
  class AttributesSetsApi extends oneEntry_1.default {
8
- constructor(url, token) {
9
- super(url, token);
8
+ constructor(url, config) {
9
+ super(url, config);
10
10
  this._url += '/api/content/attributes-sets';
11
11
  }
12
12
  /**
@@ -17,7 +17,7 @@ class AttributesSetsApi extends oneEntry_1.default {
17
17
  *
18
18
  * @returns Returns an array of AttributeInSet objects.
19
19
  */
20
- async getAttributesByMarker(marker, langCode = 'en_US') {
20
+ async getAttributesByMarker(marker, langCode = this._defaultLangCode) {
21
21
  const result = await this._fetchGet(`/${marker}/attributes?langCode=${langCode}`);
22
22
  return this._normalizeData(result);
23
23
  }
@@ -30,7 +30,7 @@ class AttributesSetsApi extends oneEntry_1.default {
30
30
  *
31
31
  * @returns Returns a AttributeInSet object.
32
32
  */
33
- async getSingleAttributeByMarkerSet(attributeMarker, setMarker, langCode = 'en_US') {
33
+ async getSingleAttributeByMarkerSet(attributeMarker, setMarker, langCode = this._defaultLangCode) {
34
34
  const result = await this._fetchGet(`/${setMarker}/attributes/${attributeMarker}?langCode=${langCode}`);
35
35
  return result;
36
36
  }
@@ -1,18 +1,17 @@
1
1
  import { IProductsQuery } from '../products/productsInterfaces';
2
- import { LangType } from "./utils";
2
+ import { IConfig } from "./utils";
3
3
  import { IUploadingQuery } from "../file-uploding/fileUploadingInterfaces";
4
4
  export default abstract class OneEntry {
5
5
  protected _url: string;
6
- protected _token: string;
7
- protected _LANGCODE_KEY: string;
6
+ protected _token: string | undefined;
7
+ protected _defaultLangCode: string;
8
8
  protected _NO_FETCH: boolean;
9
- constructor(url: string, token?: string);
9
+ protected _https: any;
10
+ constructor(url: string, config: IConfig);
10
11
  protected _getFullPath(path: string): string;
11
12
  protected _fetchGet(path: string): Promise<any>;
12
13
  protected _fetchPost(path: string, data: any): Promise<any>;
13
14
  protected _fetchDelete(path: string): Promise<any>;
14
15
  protected _queryParamsToString(query: IProductsQuery | IUploadingQuery): string;
15
- protected _parseLangFromString(str: string, lang: string): string;
16
- protected _fetchRequests(url: string, lang: LangType): Promise<any>;
17
16
  protected _normalizeData(data: any): any;
18
17
  }
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  class OneEntry {
4
- constructor(url, token) {
5
- this._LANGCODE_KEY = '$LANGCODE';
6
- this._NO_FETCH = false;
4
+ constructor(url, config) {
7
5
  this._url = url;
8
- if (token) {
9
- this._token = token;
10
- }
11
- if (typeof process === 'object' && process.versions && process.versions.node) {
12
- this._NO_FETCH = true;
13
- }
6
+ this._token = config.token;
7
+ this._defaultLangCode = config.langCode ? config.langCode : 'en_US';
8
+ this._NO_FETCH = !!(typeof process === 'object' && process.versions);
9
+ this._https = this._NO_FETCH ? require('https') : null;
14
10
  }
15
11
  _getFullPath(path) {
16
12
  return (this._url + path);
@@ -29,9 +25,8 @@ class OneEntry {
29
25
  return result;
30
26
  }
31
27
  else {
32
- const https = require('https');
33
28
  return new Promise((resolve, reject) => {
34
- const req = https.get(this._getFullPath(path), options, (res) => {
29
+ const req = this._https.get(this._getFullPath(path), options, (res) => {
35
30
  let data = '';
36
31
  res.on('data', (chunk) => {
37
32
  data += chunk;
@@ -65,9 +60,8 @@ class OneEntry {
65
60
  return await response.json();
66
61
  }
67
62
  else {
68
- const https = require('https');
69
63
  return new Promise((resolve, reject) => {
70
- const req = https.request(this._getFullPath(path), options, (res) => {
64
+ const req = this._https.request(this._getFullPath(path), options, (res) => {
71
65
  let responseData = '';
72
66
  res.on('data', (chunk) => {
73
67
  responseData += chunk;
@@ -98,9 +92,8 @@ class OneEntry {
98
92
  return result;
99
93
  }
100
94
  else {
101
- const https = require('https');
102
95
  return new Promise((resolve, reject) => {
103
- const req = https.get(this._getFullPath(path), options, (res) => {
96
+ const req = this._https.delete(this._getFullPath(path), options, (res) => {
104
97
  let data = '';
105
98
  res.on('data', (chunk) => {
106
99
  data += chunk;
@@ -124,64 +117,25 @@ class OneEntry {
124
117
  }
125
118
  return result.slice(0, (result.length - 1));
126
119
  }
127
- _parseLangFromString(str, lang) {
128
- const index = str.indexOf(this._LANGCODE_KEY);
129
- if (index === -1) {
130
- console.error('The endpoint does not contain a language template $LANGCODE');
131
- }
132
- else {
133
- return str.slice(0, index) + lang + str.slice(index + this._LANGCODE_KEY.length);
134
- }
135
- }
136
- async _fetchRequests(url, lang) {
137
- const langCode = (typeof lang === 'string') ? [lang] : lang;
138
- if (langCode.length === 1) {
139
- const response = await this._fetchGet(this._parseLangFromString(url, langCode[0]));
140
- if (response.hasOwnProperty('items') || Array.isArray(response)) {
141
- let result = Array.isArray(response) ? response : response.items;
142
- result = result.map(item => this._normalizeData(item));
143
- return result;
144
- }
145
- return this._normalizeData(response);
120
+ _normalizeData(data) {
121
+ if (Array.isArray(data)) {
122
+ return data.map(item => this._normalizeData(item));
146
123
  }
147
124
  else {
148
- const dataList = [];
149
- await Promise.all(langCode.map(async (lang) => {
150
- await this._fetchGet(this._parseLangFromString(url, lang)).then((result) => {
151
- result.hasOwnProperty('items') ? dataList.push(result.items) : dataList.push(result);
152
- });
153
- }));
154
- const baseData = dataList.splice(0, 1)[0];
155
- dataList.map(item => {
156
- if (Array.isArray(item)) {
157
- item.map((subitem, index) => {
158
- Object.assign(baseData[index].attributeValues, subitem.attributeValues);
159
- Object.assign(baseData[index].localizeInfos, subitem.localizeInfos);
160
- });
125
+ const normalizeData = {};
126
+ for (let key in data) {
127
+ if (Array.isArray(data[key]) || !data[key] || typeof data[key] !== 'object') {
128
+ normalizeData[key] = data[key];
129
+ }
130
+ else if (data[key][this._defaultLangCode]) {
131
+ normalizeData[key] = data[key][this._defaultLangCode];
161
132
  }
162
133
  else {
163
- Object.assign(baseData.attributeValues, item.attributeValues);
164
- Object.assign(baseData.localizeInfos, item.localizeInfos);
134
+ normalizeData[key] = this._normalizeData(data[key]);
165
135
  }
166
- });
167
- return baseData;
168
- }
169
- }
170
- _normalizeData(data) {
171
- const normalizeData = Object.assign({}, data);
172
- if (data.hasOwnProperty('attributeValues')) {
173
- const key = Object.keys(data.attributeValues);
174
- normalizeData.attributeValues = data.attributeValues[key[0]];
175
- }
176
- if (data.hasOwnProperty('localizeInfos')) {
177
- const key = Object.keys(data.localizeInfos);
178
- normalizeData.localizeInfos = data.localizeInfos[key[0]];
179
- }
180
- if (data.hasOwnProperty('formData')) {
181
- const key = Object.keys(data.formData);
182
- normalizeData.formData = data.formData[key[0]].flat();
136
+ }
137
+ return normalizeData;
183
138
  }
184
- return normalizeData;
185
139
  }
186
140
  }
187
141
  exports.default = OneEntry;
@@ -19,6 +19,10 @@ declare enum Types {
19
19
  forSlider = "forSlider",
20
20
  service = "service"
21
21
  }
22
+ interface IConfig {
23
+ token?: string;
24
+ langCode?: string;
25
+ }
22
26
  interface IAttributes {
23
27
  listTitles: Array<{
24
28
  title: string;
@@ -65,4 +69,4 @@ interface IAttributeSetEntity {
65
69
  }
66
70
  type LangType = string | Array<string>;
67
71
  type LocalizeType = ILocalizeInfos | ILocalizeInfo;
68
- export { LocalizeType, ILocalizeInfos, ILocalizeInfo, Types, IAttributeSetEntity, LangType, AttributeType, IAttributeValues, IAttributes };
72
+ export { LocalizeType, ILocalizeInfos, ILocalizeInfo, Types, IAttributeSetEntity, LangType, AttributeType, IAttributeValues, IAttributes, IConfig };
@@ -1,10 +1,11 @@
1
1
  import OneEntry from "../base/oneEntry";
2
2
  import { IBlocks, IBlocksEntity } from "./blocksInterfaces";
3
+ import { IConfig } from "../base/utils";
3
4
  /**
4
5
  * Controllers for working with blocks
5
6
  */
6
7
  export default class BlocksApi extends OneEntry implements IBlocks {
7
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
8
9
  /**
9
10
  * Get block by marker.
10
11
  *
@@ -5,8 +5,8 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for working with blocks
6
6
  */
7
7
  class BlocksApi extends oneEntry_1.default {
8
- constructor(url, token) {
9
- super(url, token);
8
+ constructor(url, config) {
9
+ super(url, config);
10
10
  this._url += '/api/content/blocks';
11
11
  }
12
12
  // /**
@@ -30,7 +30,7 @@ class BlocksApi extends oneEntry_1.default {
30
30
  *
31
31
  * @returns Return BlocksEntity object.
32
32
  */
33
- async getBlockByMarker(marker, langCode = 'en_US') {
33
+ async getBlockByMarker(marker, langCode = this._defaultLangCode) {
34
34
  const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
35
35
  return this._normalizeData(result);
36
36
  }
@@ -1,10 +1,11 @@
1
1
  import OneEntry from '../base/oneEntry';
2
2
  import { IUploadingQuery, IUploadingReturns, IFileUploading, IFileEntity } from "./fileUploadingInterfaces";
3
+ import { IConfig } from "../base/utils";
3
4
  /**
4
5
  * Controllers for working with file uploading
5
6
  */
6
7
  export default class FileUploadingApi extends OneEntry implements IFileUploading {
7
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
8
9
  private _defaultQuery;
9
10
  /**
10
11
  * Upload file function.
@@ -5,8 +5,8 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for working with file uploading
6
6
  */
7
7
  class FileUploadingApi extends oneEntry_1.default {
8
- constructor(url, token) {
9
- super(url, token);
8
+ constructor(url, config) {
9
+ super(url, config);
10
10
  this._defaultQuery = {
11
11
  type: null,
12
12
  entity: null,
@@ -1,10 +1,11 @@
1
1
  import OneEntry from "../base/oneEntry";
2
2
  import { IForms, IFormsEntity } from "./formsInterfaces";
3
+ import { IConfig } from "../base/utils";
3
4
  /**
4
5
  * Controllers for forms objects
5
6
  */
6
7
  export default class FormsApi extends OneEntry implements IForms {
7
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
8
9
  /**
9
10
  * Get all forms.
10
11
  *
@@ -5,8 +5,8 @@ const oneEntry_1 = require("../base/oneEntry");
5
5
  * Controllers for forms objects
6
6
  */
7
7
  class FormsApi extends oneEntry_1.default {
8
- constructor(url, token) {
9
- super(url, token);
8
+ constructor(url, config) {
9
+ super(url, config);
10
10
  this._url += '/api/content/forms';
11
11
  }
12
12
  /**
@@ -18,7 +18,7 @@ class FormsApi extends oneEntry_1.default {
18
18
  *
19
19
  * @returns Returns array for all objects of type FormEntity
20
20
  */
21
- async getAllForms(langCode = 'en_US', offset = 0, limit = 30) {
21
+ async getAllForms(langCode = this._defaultLangCode, offset = 0, limit = 30) {
22
22
  const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
23
23
  return this._normalizeData(result);
24
24
  }
@@ -30,7 +30,7 @@ class FormsApi extends oneEntry_1.default {
30
30
  *
31
31
  * @returns Returns object of type FormEntity
32
32
  */
33
- async getFormByMarker(marker, langCode = 'en_US') {
33
+ async getFormByMarker(marker, langCode = this._defaultLangCode) {
34
34
  const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
35
35
  return this._normalizeData(result);
36
36
  }
@@ -1,10 +1,11 @@
1
1
  import OneEntry from '../base/oneEntry';
2
2
  import { IFormsPost, IFormsData, IFormsDataEntity } from './formsDataInterfaces';
3
+ import { IConfig } from "../base/utils";
3
4
  /**
4
5
  * Controllers for working with form data
5
6
  */
6
7
  export default class FormsDataApi extends OneEntry implements IFormsData {
7
- constructor(url: string, token: string);
8
+ constructor(url: string, config: IConfig);
8
9
  /**
9
10
  * Get all forms data.
10
11
  *