idosell 0.4.24 → 0.4.27

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 (56) hide show
  1. package/changelog.md +9 -0
  2. package/dist/app.d.ts +2 -1
  3. package/dist/gates.js +51 -15
  4. package/dist/gateways.d.ts +278 -21
  5. package/dist/helpers.js +18 -0
  6. package/dist/index.js +3 -1
  7. package/dist/methods/deletePromotions.js +6 -0
  8. package/dist/methods/deletePromotionsArchive.js +6 -0
  9. package/dist/methods/deletePromotionsElements.js +13 -0
  10. package/dist/methods/getPromotions.js +6 -0
  11. package/dist/methods/getPromotionsArchive.js +6 -0
  12. package/dist/methods/getPromotionsSettings.js +5 -0
  13. package/dist/methods/postPromotions.js +8 -0
  14. package/dist/methods/postPromotionsElements.js +13 -0
  15. package/dist/methods/postPromotionsEnd.js +7 -0
  16. package/dist/methods/postPromotionsStart.js +7 -0
  17. package/dist/methods/putPromotions.js +8 -0
  18. package/dist/methods/putPromotionsSettings.js +6 -0
  19. package/dist/methods/searchPromotionsArchive.js +14 -0
  20. package/dist/methods/searchPromotionsElements.js +15 -0
  21. package/dist/methods/searchPromotionsHistory.js +13 -0
  22. package/dist/methods/searchPromotionsListView.js +21 -0
  23. package/dist/params.js +15 -1
  24. package/dist/reqparams.d.ts +165 -2
  25. package/dist/request.js +36 -10
  26. package/dist/responses.d.ts +111 -0
  27. package/package.json +1 -1
  28. package/tests/deleteProductsToFacebookCatalog.test.js +7 -0
  29. package/tests/deleteProductsToPromotion.test.js +7 -0
  30. package/tests/deletePromotions.test.js +7 -0
  31. package/tests/deletePromotionsArchive.test.js +7 -0
  32. package/tests/deletePromotionsElements.test.js +7 -0
  33. package/tests/getProductsToFacebookCatalog.test.js +8 -0
  34. package/tests/getPromotions.test.js +7 -0
  35. package/tests/getPromotionsArchive.test.js +7 -0
  36. package/tests/postProductsToFacebookCatalog.test.js +7 -0
  37. package/tests/postProductsToPromotion.test.js +7 -0
  38. package/tests/postPromotions.test.js +7 -0
  39. package/tests/postPromotionsElements.test.js +7 -0
  40. package/tests/postPromotionsEnd.test.js +7 -0
  41. package/tests/postPromotionsStart.test.js +7 -0
  42. package/tests/putPromotions.test.js +7 -0
  43. package/tests/putPromotionsSettings.test.js +7 -0
  44. package/tests/searchPromotionsArchive.test.js +12 -0
  45. package/tests/searchPromotionsElements.test.js +12 -0
  46. package/tests/searchPromotionsHistory.test.js +7 -0
  47. package/tests/searchPromotionsListView.test.js +7 -0
  48. package/tests/deleteProductsProductsToFacebookCatalog.test.js +0 -7
  49. package/tests/deleteProductsProductsToPromotion.test.js +0 -7
  50. /package/dist/methods/{deleteProductsProductsToFacebookCatalog.js → deleteProductsToFacebookCatalog.js} +0 -0
  51. /package/dist/methods/{deleteProductsProductsToPromotion.js → deleteProductsToPromotion.js} +0 -0
  52. /package/dist/methods/{getProductsProductsToFacebookCatalog.js → getProductsToFacebookCatalog.js} +0 -0
  53. /package/dist/methods/{postProductsProductsToFacebookCatalog.js → postProductsToFacebookCatalog.js} +0 -0
  54. /package/dist/methods/{postProductsProductsToPromotion.js → postProductsToPromotion.js} +0 -0
  55. /package/dist/methods/{postSubscriptionsItemsList.js → searchSubscriptionsItems.js} +0 -0
  56. /package/dist/methods/{postSubscriptionsListViewList.js → searchSubscriptionsListView.js} +0 -0
@@ -0,0 +1,6 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'delete', node: '/promotions/promotionsArchive/delete' };
4
+ object.req = ["promotionId"];
5
+ return new Proxy(object, paramsProxy);
6
+ };
@@ -0,0 +1,13 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'post', node: '/promotions/elements/remove' };
4
+ object.rootparams = "request";
5
+ object.appendable = {
6
+ except: [],
7
+ arrayNode: "elements",
8
+ index: 0
9
+ };
10
+ object.req = ["promotionId", "type", "id"];
11
+ object.arrays = ["elements"];
12
+ return new Proxy(object, paramsProxy);
13
+ };
@@ -0,0 +1,6 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'get', node: '/promotions/promotions/get' };
4
+ object.req = ["promotionId"];
5
+ return new Proxy(object, paramsProxy);
6
+ };
@@ -0,0 +1,6 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'get', node: '/promotions/promotionsArchive/get' };
4
+ object.req = ["promotionId"];
5
+ return new Proxy(object, paramsProxy);
6
+ };
@@ -0,0 +1,5 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'get', node: '/promotions/settings/get' };
4
+ return new Proxy(object, paramsProxy);
5
+ };
@@ -0,0 +1,8 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'post', node: '/promotions/promotions/add' };
4
+ object.rootparams = "request";
5
+ object.req = ["activeInShops", "newPriceValue", "name"];
6
+ object.arrays = ["activeInShops", "types"];
7
+ return new Proxy(object, paramsProxy);
8
+ };
@@ -0,0 +1,13 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'post', node: '/promotions/elements/add' };
4
+ object.rootparams = "request";
5
+ object.appendable = {
6
+ except: [],
7
+ arrayNode: "elements",
8
+ index: 0
9
+ };
10
+ object.req = ["promotionId", "id", "type"];
11
+ object.arrays = ["elements"];
12
+ return new Proxy(object, paramsProxy);
13
+ };
@@ -0,0 +1,7 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'post', node: '/promotions/promotions/end' };
4
+ object.rootparams = true;
5
+ object.req = ["promotionId"];
6
+ return new Proxy(object, paramsProxy);
7
+ };
@@ -0,0 +1,7 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'post', node: '/promotions/promotions/start' };
4
+ object.rootparams = true;
5
+ object.req = ["promotionId"];
6
+ return new Proxy(object, paramsProxy);
7
+ };
@@ -0,0 +1,8 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'put', node: '/promotions/promotions/edit' };
4
+ object.rootparams = "request";
5
+ object.req = ["promotionId"];
6
+ object.arrays = ["activeInShops", "types"];
7
+ return new Proxy(object, paramsProxy);
8
+ };
@@ -0,0 +1,6 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'put', node: '/promotions/settings/set' };
4
+ object.rootparams = "request";
5
+ return new Proxy(object, paramsProxy);
6
+ };
@@ -0,0 +1,14 @@
1
+ import { paramsProxy } from "../params.js";
2
+ import { orderByProperty, paginationObject, nest } from "../helpers.js";
3
+ export default (object) => {
4
+ object.gate = { method: 'post', node: '/promotions/promotionsArchive/list' };
5
+ object.rootparams = "request";
6
+ object.custom = {
7
+ orderByProperty,
8
+ page: paginationObject,
9
+ shops: nest("shops", "filter", {}, true),
10
+ archivedDate: nest("archivedDate", "filter", {}, false)
11
+ };
12
+ object.paginationObject = true;
13
+ return new Proxy(object, paramsProxy);
14
+ };
@@ -0,0 +1,15 @@
1
+ import { paramsProxy } from "../params.js";
2
+ import { orderByProperty, paginationObject, nest } from "../helpers.js";
3
+ export default (object) => {
4
+ object.gate = { method: 'post', node: '/promotions/elements/list' };
5
+ object.rootparams = "request";
6
+ object.custom = {
7
+ orderByProperty,
8
+ page: paginationObject,
9
+ ids: nest("ids", "filter", {}, true),
10
+ types: nest("types", "filter", {}, true),
11
+ promotionIds: nest("promotionIds", "filter", {}, true)
12
+ };
13
+ object.paginationObject = true;
14
+ return new Proxy(object, paramsProxy);
15
+ };
@@ -0,0 +1,13 @@
1
+ import { paramsProxy } from "../params.js";
2
+ import { paginationObject, nest } from "../helpers.js";
3
+ export default (object) => {
4
+ object.gate = { method: 'post', node: '/promotions/history/get' };
5
+ object.rootparams = "request";
6
+ object.custom = {
7
+ page: paginationObject,
8
+ promotionId: nest("promotionId", "filter", {}, false)
9
+ };
10
+ object.paginationObject = true;
11
+ object.req = ["filter"];
12
+ return new Proxy(object, paramsProxy);
13
+ };
@@ -0,0 +1,21 @@
1
+ import { paramsProxy } from "../params.js";
2
+ import { orderByProperty, paginationObject, nest } from "../helpers.js";
3
+ export default (object) => {
4
+ object.gate = { method: 'post', node: '/promotions/promotions/listView/list' };
5
+ object.rootparams = "request";
6
+ object.custom = {
7
+ orderByProperty,
8
+ page: paginationObject,
9
+ ids: nest("ids", "filter", {}, true),
10
+ name: nest("name", "filter", {}, false),
11
+ changeVisibility: nest("changeVisibility", "filter", {}, false),
12
+ activeInShops: nest("activeInShops", "filter", {}, true),
13
+ types: nest("types", "filter", {}, true),
14
+ priceTypes: nest("priceTypes", "filter", {}, true),
15
+ statuses: nest("statuses", "filter", {}, true),
16
+ dateRange: nest("dateRange", "filter", {}, false),
17
+ productsNotInPromotion: nest("productsNotInPromotion", "filter", {}, true)
18
+ };
19
+ object.paginationObject = true;
20
+ return new Proxy(object, paramsProxy);
21
+ };
package/dist/params.js CHANGED
@@ -13,6 +13,19 @@ const requests = {
13
13
  return receiver;
14
14
  }
15
15
  };
16
+ function deepAssignSecondLevel(target, source) {
17
+ for (const key of Object.keys(source)) {
18
+ if (key in target &&
19
+ typeof target[key] === 'object' && target[key] !== null &&
20
+ typeof source[key] === 'object' && source[key] !== null) {
21
+ Object.assign(target[key], source[key]);
22
+ }
23
+ else {
24
+ target[key] = source[key];
25
+ }
26
+ }
27
+ return target;
28
+ }
16
29
  export const paramsProxy = {
17
30
  get: (object, property, receiver) => {
18
31
  if (property === 'then') {
@@ -48,7 +61,8 @@ export const paramsProxy = {
48
61
  values = [values[0] ?? 0, values[1] ?? 100, Boolean(object.snakeCase)];
49
62
  }
50
63
  const param = object.custom[property](...values);
51
- Object.assign(object.params, param);
64
+ if (param)
65
+ deepAssignSecondLevel(object.params, param);
52
66
  }
53
67
  else if (object.arrays && object.arrays.includes(property)) {
54
68
  if (Array.isArray(values[0]))
@@ -6312,7 +6312,7 @@ export type PostPackagesParams = {
6312
6312
  }[];
6313
6313
  };
6314
6314
 
6315
- export type PostProductsProductsToFacebookCatalogParams = {
6315
+ export type PostProductsToFacebookCatalogParams = {
6316
6316
  /** @description You can read the Facebook Catalog ID in the Marketing & Integrations/Facebook/Facebook Product Catalog admin panel */
6317
6317
  facebookCatalogId?: number;
6318
6318
  /** @description Shop Id */
@@ -6321,7 +6321,7 @@ export type PostProductsProductsToFacebookCatalogParams = {
6321
6321
  products?: number[];
6322
6322
  };
6323
6323
 
6324
- export type PostProductsProductsToPromotionParams = {
6324
+ export type PostProductsToPromotionParams = {
6325
6325
  /** @description Special offer ID */
6326
6326
  promotionId?: number;
6327
6327
  /** @description Products list. */
@@ -7154,4 +7154,167 @@ export type PutWmsStocksdocumentsAcceptMMParams = {
7154
7154
  id: number;
7155
7155
  };
7156
7156
 
7157
+ export type PromotionIdParams = {
7158
+ /** @description ID of promotion */
7159
+ promotionId: number;
7160
+ };
7161
+
7162
+ type PaginationParam = {
7163
+ /** @description Page index (starting from 0)
7164
+ * @default 0 */
7165
+ page?: number;
7166
+ /** @description Number of records per page.
7167
+ * @default 100 */
7168
+ perPage?: number;
7169
+ };
7170
+
7171
+ type DateRangeParam = {
7172
+ /** Format: date
7173
+ * @description Date "from" (RFC) */
7174
+ from?: string | null;
7175
+ /** Format: date
7176
+ * @description Date "to" (RFC) */
7177
+ to?: string | null;
7178
+ } | null;
7179
+
7180
+ type PromotionBody = {
7181
+ /** @description Promotion name */
7182
+ name?: string;
7183
+ /** @description Promotion zones */
7184
+ types?: ("promotion" | "special" | "discount" | "distinguished" | "bestseller" | "new")[];
7185
+ /** @description Promotion start datetime */
7186
+ startTime?: string;
7187
+ /** @description Promotion end datetime */
7188
+ endTime?: string;
7189
+ /** @description Change visibility */
7190
+ changeVisibility?: boolean;
7191
+ /** @description Auto unpin */
7192
+ autoUnpin?: boolean;
7193
+ /** @description Auto unpin own stocks */
7194
+ autoUnpinOwnStocks?: boolean;
7195
+ /** @description Price type */
7196
+ priceType?: "retail" | "wholesale" | "pos";
7197
+ /** @description Currency */
7198
+ currency?: string;
7199
+ /** @description Discount type */
7200
+ newPriceDiscountType?: "percent" | "minus" | "set";
7201
+ /** @description New price round */
7202
+ newPriceRound?: "whole" | "first" | "second";
7203
+ /** @description New price end */
7204
+ newPriceEnd?: number;
7205
+ /** @description Net or gross */
7206
+ netGross?: "gross" | "net";
7207
+ /** @description Charge type */
7208
+ chargeType?: "lowest" | "sum";
7209
+ /** @description Enable in marketplaces */
7210
+ enableInMarketplaces?: "y" | "n" | "yes_for_dynamic_pricing_products";
7211
+ /** @description Status */
7212
+ status?: "waiting" | "active" | "closed";
7213
+ };
7214
+
7215
+ export type PostPromotionsParams = PromotionBody & {
7216
+ /** @description Array of shop ids */
7217
+ activeInShops: number[];
7218
+ /** @description A representation of a floating-point number with precise accuracy. */
7219
+ newPriceValue: { value: string };
7220
+ };
7221
+
7222
+ export type PutPromotionsParams = PromotionBody & PromotionIdParams & {
7223
+ /** @description Array of shop ids */
7224
+ activeInShops?: number[];
7225
+ /** @description A representation of a floating-point number with precise accuracy. */
7226
+ newPriceValue?: { value: string };
7227
+ };
7228
+
7229
+ type PromotionElementsBody = {
7230
+ /** @description Array of PromotionElement objects */
7231
+ elements: {
7232
+ /** @description ID */
7233
+ id: string;
7234
+ /** @description Promotion element type */
7235
+ type: "product" | "series" | "producer" | "category" | "menu";
7236
+ /** @description Promotion ID */
7237
+ promotionId: number;
7238
+ }[];
7239
+ };
7240
+
7241
+ export type PostPromotionsElementsParams = PromotionElementsBody;
7242
+ export type DeletePromotionsElementsParams = PromotionElementsBody;
7243
+
7244
+ export type SearchPromotionsHistoryParams = {
7245
+ filter: {
7246
+ /** @description Promotion ID */
7247
+ promotionId: number;
7248
+ };
7249
+ pagination?: PaginationParam;
7250
+ };
7251
+
7252
+ export type SearchPromotionsElementsParams = {
7253
+ /** @example {"types": ["category", "series"], "ids": ["213"], "promotionIds": [534]} */
7254
+ filter?: {
7255
+ /** @description Elements IDs */
7256
+ ids?: string[];
7257
+ /** @description Element types */
7258
+ types?: ("product" | "series" | "producer" | "category" | "menu")[];
7259
+ /** @description Promotion IDs */
7260
+ promotionIds?: number[];
7261
+ };
7262
+ pagination?: PaginationParam;
7263
+ orderBy?: {
7264
+ /** @default promotion_id */
7265
+ property?: "promotion_id" | "type" | "element_id";
7266
+ /** @default desc */
7267
+ orderByDirection?: "asc" | "desc";
7268
+ };
7269
+ };
7270
+
7271
+ export type SearchPromotionsListViewParams = {
7272
+ filter?: {
7273
+ ids?: number[] | null;
7274
+ name?: string;
7275
+ changeVisibility?: boolean;
7276
+ /** @description Array of shop ids */
7277
+ activeInShops?: number[];
7278
+ types?: ("promotion" | "special" | "discount" | "distinguished" | "bestseller" | "new")[];
7279
+ priceTypes?: ("retail" | "wholesale" | "pos")[];
7280
+ statuses?: ("waiting" | "active" | "closed")[];
7281
+ dateRange?: DateRangeParam;
7282
+ productsNotInPromotion?: number[] | null;
7283
+ };
7284
+ pagination?: PaginationParam;
7285
+ orderBy?: {
7286
+ /** @default id */
7287
+ property?: "id" | "name" | "start_time" | "end_time" | "new_price_value" | "new_price_end" | "elements_modification_date";
7288
+ /** @default desc */
7289
+ orderByDirection?: "asc" | "desc";
7290
+ };
7291
+ };
7292
+
7293
+ export type SearchPromotionsArchiveParams = {
7294
+ filter?: {
7295
+ shops?: number[];
7296
+ archivedDate?: DateRangeParam;
7297
+ };
7298
+ pagination?: PaginationParam;
7299
+ orderBy?: {
7300
+ /** @default id */
7301
+ property?: "id" | "shop_mask" | "archived_date";
7302
+ /** @default desc */
7303
+ orderByDirection?: "asc" | "desc";
7304
+ };
7305
+ };
7306
+
7307
+ export type PutPromotionsSettingsParams = {
7308
+ daysLeftToArchive?: number;
7309
+ daysLeftToRemove?: number;
7310
+ showPriceOnProductsList?: number;
7311
+ automaticallySuggestDefaultStartDate?: "on" | "off";
7312
+ automaticallySuggestDefaultEndDate?: "on" | "off";
7313
+ defaultStartDate?: number;
7314
+ defaultEndDate?: number;
7315
+ defaultStartTime?: number;
7316
+ defaultEndTime?: number;
7317
+ daysLeftToClose?: number;
7318
+ };
7319
+
7157
7320
  export { };
package/dist/request.js CHANGED
@@ -16,9 +16,20 @@ const catchIdosellError = (err) => {
16
16
  if (!err.response.headers['x-error'] && err.response.headers['content-type'].indexOf('json') < 0)
17
17
  throw new Error('500: Invalid response from Api gateway');
18
18
  let message = err.response.headers['x-error'];
19
- for (const [search, replace] of DECODE_TABLE) {
20
- message = message.replaceAll(search, replace);
19
+ if (err.response?.data?.errors) {
20
+ let errorObj = err.response?.data?.errors;
21
+ if (Array.isArray(errorObj))
22
+ errorObj = errorObj[0];
23
+ if (errorObj.message)
24
+ message = errorObj.message;
25
+ }
26
+ if (message) {
27
+ for (const [search, replace] of DECODE_TABLE) {
28
+ message = message.replaceAll(search, replace);
29
+ }
21
30
  }
31
+ else
32
+ message = 'Unknown error';
22
33
  if (err.response.status === 403) {
23
34
  const match = message.match(/Scope: ([a-z]+), level: ([rw]{1,2})/);
24
35
  if (match) {
@@ -41,17 +52,30 @@ const checkNext = (request, response, logPage) => {
41
52
  };
42
53
  throw new IdosellFaultStringError(response.errors.faultString, faultStructure);
43
54
  }
55
+ function handlePagination(currentPage, totalPages, request, paramsUpdate) {
56
+ request.next = currentPage + 1 < totalPages;
57
+ if (paramsUpdate)
58
+ Object.assign(request.params, paramsUpdate);
59
+ if (typeof logPage === 'function') {
60
+ logPage('Page: ' + currentPage + ' / ' + totalPages);
61
+ }
62
+ }
44
63
  if (response.resultsNumberPage) {
45
- request.next = response.resultsPage + 1 < response.resultsNumberPage;
46
- request.params.resultsPage = request.params.resultsPage ? request.params.resultsPage + 1 : 1;
47
- if (logPage)
48
- logPage('Page: ' + response.resultsPage + ' / ' + response.resultsNumberPage);
64
+ handlePagination(response.resultsPage, response.resultsNumberPage, request, { resultsPage: response.resultsPage + 1 });
49
65
  }
50
66
  else if (response.results_number_page) {
51
- request.next = response.results_page + 1 < response.results_number_page;
52
- request.params.results_page = request.params.results_page ? request.params.results_page + 1 : 1;
53
- if (logPage)
54
- logPage('Page: ' + response.results_page + ' / ' + response.results_page);
67
+ handlePagination(response.results_page, response.results_number_page, request, { results_page: response.results_page + 1 });
68
+ }
69
+ else if (response.pagination) {
70
+ console.log({ rp: request.params, qp: response.pagination });
71
+ request.params.pagination.page = response.pagination.resultsPage + 1;
72
+ handlePagination(response.pagination.resultsPage, response.pagination.resultsNumberPage, request);
73
+ }
74
+ else if (response.data?.pagination) {
75
+ if (!request.params.pagination)
76
+ request.params.pagination = {};
77
+ request.params.pagination.page = response.data.pagination.resultsPage + 1;
78
+ handlePagination(response.data.pagination.resultsPage, response.data.pagination.resultsNumberPage, request);
55
79
  }
56
80
  return response;
57
81
  };
@@ -190,6 +214,8 @@ export const countResults = async (request, options) => {
190
214
  return 0;
191
215
  if (request.snakeCase)
192
216
  return parseInt(response.results_number_all);
217
+ else if (request.paginationObject)
218
+ return response.pagination.resultsNumberAll;
193
219
  else
194
220
  return response.resultsNumberAll;
195
221
  };
@@ -20,6 +20,9 @@ type PagedSnakecaseResponse = {
20
20
  results_limit: number;
21
21
  };
22
22
 
23
+ type PaginatedResponse = {
24
+ pagination: PagedResponse
25
+ }
23
26
  type FaultCodeString = {
24
27
  /** @description Error code. */
25
28
  faultCode: number;
@@ -9146,4 +9149,112 @@ export type GetOrdersResponse = {
9146
9149
  }[];
9147
9150
  };
9148
9151
 
9152
+ type PromotionErrorEntry = {
9153
+ /** @description Error code. */
9154
+ code: string;
9155
+ /** @description Field associated with the error. */
9156
+ field: string | null;
9157
+ /** @description Error description. */
9158
+ message: string | null;
9159
+ /** @description Value associated with the error. */
9160
+ value: string | null;
9161
+ /** @description Unique identifier of the error (for support). */
9162
+ uid: string | null;
9163
+ };
9164
+
9165
+ type PromotionApiResponse<T> = {
9166
+ data: T;
9167
+ isError: boolean;
9168
+ errors: PromotionErrorEntry[];
9169
+ };
9170
+
9171
+ type PromotionData = {
9172
+ /** @description ID of promotion */
9173
+ promotionId: number;
9174
+ name: string;
9175
+ /** @description Array of shop ids */
9176
+ activeInShops: number[];
9177
+ types: ("promotion" | "special" | "discount" | "distinguished" | "bestseller" | "new")[];
9178
+ startTime: string;
9179
+ endTime: string;
9180
+ changeVisibility: boolean;
9181
+ autoUnpin: boolean;
9182
+ autoUnpinOwnStocks: boolean;
9183
+ priceType: "retail" | "wholesale" | "pos";
9184
+ /** @description A representation of a floating-point number with precise accuracy. */
9185
+ newPriceValue: { value: string };
9186
+ currency: string;
9187
+ newPriceDiscountType: "percent" | "minus" | "set";
9188
+ newPriceRound: "whole" | "first" | "second";
9189
+ newPriceEnd: number;
9190
+ netGross: "gross" | "net";
9191
+ chargeType: "lowest" | "sum";
9192
+ enableInMarketplaces: "y" | "n" | "yes_for_dynamic_pricing_products";
9193
+ status: "waiting" | "active" | "closed";
9194
+ elementsModificationDate: string | null;
9195
+ /** @description Promotion archive datetime — optional in list/get, required in archive */
9196
+ archivedDate?: string | null;
9197
+ /** @description Promotion elements count e.g. { "products": 1 } */
9198
+ elementsCount: Record<string, number>;
9199
+ elements?: unknown[];
9200
+ };
9201
+
9202
+ type PromotionArchiveData = Omit<PromotionData, "archivedDate" | "elementsCount" | "elements"> & {
9203
+ archivedDate: string | null;
9204
+ elementsCount: Record<string, never>;
9205
+ elements: unknown[];
9206
+ };
9207
+
9208
+ export type SearchPromotionsHistoryResponse = PromotionApiResponse<{
9209
+ list: {
9210
+ readonly id: number;
9211
+ readonly date: string;
9212
+ readonly login: string;
9213
+ readonly description: string;
9214
+ }[];
9215
+ pagination: PagedResponse;
9216
+ }>;
9217
+
9218
+ export type SearchPromotionsElementsResponse = PromotionApiResponse<{
9219
+ list: {
9220
+ id: string;
9221
+ type: "product" | "series" | "producer" | "category" | "menu";
9222
+ name: string;
9223
+ promotionId: number;
9224
+ /** @description Correlated elements id */
9225
+ correlatedElementsId?: number[];
9226
+ }[];
9227
+ pagination: PagedResponse;
9228
+ }>;
9229
+
9230
+ export type SearchPromotionsListViewResponse = PromotionApiResponse<{
9231
+ list: PromotionData[];
9232
+ pagination: PagedResponse;
9233
+ }>;
9234
+
9235
+ export type SearchPromotionsArchiveResponse = PromotionApiResponse<{
9236
+ list: PromotionArchiveData[];
9237
+ pagination: PagedResponse;
9238
+ }>;
9239
+
9240
+ export type GetPromotionsResponse = PromotionApiResponse<PromotionData>;
9241
+ export type GetPromotionsArchiveResponse = PromotionApiResponse<PromotionArchiveData>;
9242
+
9243
+ export type GetPromotionsSettingsResponse = PromotionApiResponse<{
9244
+ daysLeftToArchive: number;
9245
+ daysLeftToRemove: number;
9246
+ showPriceOnProductsList: number;
9247
+ automaticallySuggestDefaultStartDate: "on" | "off";
9248
+ automaticallySuggestDefaultEndDate: "on" | "off";
9249
+ defaultStartDate: number;
9250
+ defaultEndDate: number;
9251
+ defaultStartTime: number;
9252
+ defaultEndTime: number;
9253
+ daysLeftToClose: number;
9254
+ }>;
9255
+
9256
+ export type PromotionIdResponse = PromotionApiResponse<number>;
9257
+
9258
+ export type PromotionBoolResponse = PromotionApiResponse<boolean | null>;
9259
+
9149
9260
  export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idosell",
3
- "version": "0.4.24",
3
+ "version": "0.4.27",
4
4
  "description": "Idosell 3 REST connector",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/gateways.d.ts",
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("deleteProductsToFacebookCatalogFacebookCatalogId", () => {
5
+ const params = idosell().deleteProductsToFacebookCatalog.shopId(1).products([9]).facebookCatalogId(123).checkParams();
6
+ expect(params).toEqual({"shopId":1,"products":[9],"facebookCatalogId":123});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("deleteProductsToPromotionProducts", () => {
5
+ const params = idosell().deleteProductsToPromotion.promotionId(2).products([11]).checkParams();
6
+ expect(params).toEqual({"promotionId":2,"products":[11]});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("deletePromotionsPromotionId", () => {
5
+ const params = idosell().deletePromotions.promotionId(123).checkParams();
6
+ expect(params).toEqual({"promotionId":123});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("deletePromotionsArchivePromotionId", () => {
5
+ const params = idosell().deletePromotionsArchive.promotionId(123).checkParams();
6
+ expect(params).toEqual({"promotionId":123});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("deletePromotionsElementsId", () => {
5
+ const params = idosell().deletePromotionsElements.promotionId(4).type("product").id("288").checkParams();
6
+ expect(params).toEqual({"elements":[{"promotionId":4,"type":"product","id":"288"}]});
7
+ })
@@ -0,0 +1,8 @@
1
+ import idosell from "./dist/index"
2
+ import { expect, test } from "vitest"
3
+
4
+
5
+ test("getProductsToFacebookCatalogFacebookCatalogId", () => {
6
+ const params = idosell().getProductsToFacebookCatalog.shopId(1).facebookCatalogId(123).checkParams();
7
+ expect(params).toEqual({"shopId":1,"facebookCatalogId":123});
8
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("getPromotionsPromotionId", () => {
5
+ const params = idosell().getPromotions.promotionId(123).checkParams();
6
+ expect(params).toEqual({"promotionId":123});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("getPromotionsArchivePromotionId", () => {
5
+ const params = idosell().getPromotionsArchive.promotionId(123).checkParams();
6
+ expect(params).toEqual({"promotionId":123});
7
+ })