idosell 0.1.0 → 0.1.2

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/dist/gates.def.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * @property {(return_elements: Array<String>) => GetClientsBalanceRequest} return_elements Elements to be returned by the endpoint. By default all elements are returned
9
9
  * @property {(results_page: Integer) => GetClientsBalanceRequest} results_page Results page number. Numbering begins at 0. Default value: 0.
10
10
  * @property {(results_limit: Integer) => GetClientsBalanceRequest} results_limit Maximum number of results on a single page. Default is 100.
11
- * @property {(dateFrom: DateLike, dateTo: DateLike) => GetClientsBalanceRequest} lastPurchase Type of date according to the index results
11
+ * @property {(dateFrom: DateLike, dateTo: DateLike) => GetClientsBalanceRequest} lastPurchased Type of date according to the index results
12
12
  * @property {(page: Integer, limit: Integer) => GetClientsBalanceRequest} page Define page number and maximum results per page
13
13
  * @property {() => Integer} count Returns total numer of results
14
14
  * @property {function} exec Excecute request
@@ -39,7 +39,7 @@
39
39
  * @property {(returnElements: Array<String>) => GetClientsRequest} returnElements Elements to be returned by the endpoint. By default all elements are returned
40
40
  * @property {(resultsPage: Integer) => GetClientsRequest} resultsPage Page with results number. Numeration starts from 0
41
41
  * @property {(resultsLimit: Integer) => GetClientsRequest} resultsLimit Number of results on page. Value from 1 to 100
42
- * @property {(dateFrom: DateLike, dateTo: DateLike) => GetClientsRequest} lastPurchase Type of date according to the index results
42
+ * @property {(dateFrom: DateLike, dateTo: DateLike) => GetClientsRequest} lastPurchased Type of date according to the index results
43
43
  * @property {(dateFrom: DateLike, dateTo: DateLike) => GetClientsRequest} lastModified Type of date according to the index results
44
44
  * @property {(page: Integer, limit: Integer) => GetClientsRequest} page Define page number and maximum results per page
45
45
  * @property {() => Integer} count Returns total numer of results
@@ -1367,6 +1367,9 @@
1367
1367
  * @property {(ordersBy: Array<Object>) => ListOrdersUnfinishedRequest} ordersBy Possibility of sorting returned list
1368
1368
  * @property {(searchingOperatorTypeMatch: 'no_assignment'|'no_empty'|'empty') => ListOrdersUnfinishedRequest} searchingOperatorTypeMatch Method of searching orders by handler.
1369
1369
  * @property {(ordersDelayed: 'y'|'n') => ListOrdersUnfinishedRequest} ordersDelayed Orders with the exceeded date of shipment.
1370
+ * @property {(shopIds: Array<Integer>) => ListOrdersUnfinishedRequest} shopIds Define shopsIds value nested inside orderSource
1371
+ * @property {(byPackageNumbers: Array<String>) => ListOrdersUnfinishedRequest} byPackageNumbers Define packagesNumbers value nested inside packages
1372
+ * @property {(dateFrom: DateLike, dateTo: DateLike, dateType: "add"|"modified"|"dispatch"|"payment"|"last_payments_operation"|"declared_payments") => ListOrdersUnfinishedRequest} dates Type of date according to the index results. Possible type values: add, modified, dispatch, payment, last_payments_operation, declared_payments
1370
1373
  * @property {(elementName: "id"|"sn"|"order_time"|"status"|"order_source"|"order_cost"|"discount_code"|"ready_to_send_date", descending: Boolean) => ListOrdersUnfinishedRequest} orderBy Define sorting by element and direction
1371
1374
  * @property {(logins: Array<String>) => ListOrdersUnfinishedRequest} logins Define clients by passing array of values
1372
1375
  * @property {(clientIds: Array<String>) => ListOrdersUnfinishedRequest} clientIds Define clients by passing array of values
package/dist/gates.js CHANGED
@@ -546,7 +546,7 @@ const gates = {
546
546
  deleteWmsSuppliers,
547
547
  getWmsSuppliers,
548
548
  putWmsSuppliers,
549
- };
549
+ }
550
550
 
551
551
  export const gateProxy = {
552
552
  get: (object, property) => gates[property](object)
@@ -4,7 +4,7 @@ import { dateRange, page } from "../helpers.js";
4
4
  export default (object) => {
5
5
  object.gate = { method: 'get', node: '/clients/clients' }
6
6
  object.custom = {
7
- lastPurchase: dateRange({"nodeName":"clientLastPurchaseDate","fromName":"clientLastPurchaseDateBegin","toName":"clientLastPurchaseDateEnd"}),
7
+ lastPurchased: dateRange({"nodeName":"clientLastPurchaseDate","fromName":"clientLastPurchaseDateBegin","toName":"clientLastPurchaseDateEnd"}),
8
8
  lastModified: dateRange({"nodeName":"clientsLastModificationDate","fromName":"clientsLastModificationDateBegin","toName":"clientsLastModificationDateEnd"}),
9
9
  page
10
10
  };
@@ -4,7 +4,7 @@ import { dateRange, page } from "../helpers.js";
4
4
  export default (object) => {
5
5
  object.gate = { method: 'get', node: '/clients/balance' }
6
6
  object.custom = {
7
- lastPurchase: dateRange({"nodeName":"last_purchase_date","fromName":"from","toName":"to"}),
7
+ lastPurchased: dateRange({"nodeName":"last_purchase_date","fromName":"from","toName":"to"}),
8
8
  page
9
9
  };
10
10
  object.snakeCase = true;
@@ -1,9 +1,12 @@
1
1
  import { paramsProxy } from "../params.js";
2
- import { orderBy, arrayOfObjects, page } from "../helpers.js";
2
+ import { nest, dateRangeType, orderBy, arrayOfObjects, page } from "../helpers.js";
3
3
 
4
4
  export default (object) => {
5
5
  object.gate = { method: 'post', node: '/orders/unfinished/get' }
6
6
  object.custom = {
7
+ shopIds: nest("shopsIds", "orderSource", {}, true),
8
+ byPackageNumbers: nest("packagesNumbers", "packages", {"orderHasPackageNumbers":"y"}, true),
9
+ dates: dateRangeType({"nodeName":"ordersDateRange","fromName":"ordersDateBegin","toName":"ordersDateEnd","typeName":"ordersDateType","format":"YYYY-MM-DD HH:mm:ss","nested":"ordersRange","defaultType":"add"}),
7
10
  orderBy,
8
11
  logins: arrayOfObjects("clients", "clientLogin", {"type":"login"}),
9
12
  clientIds: arrayOfObjects("clients", "clientId", {"type":"id"}),
package/dist/request.js CHANGED
@@ -58,9 +58,7 @@ export const sendRequest = async (request, options = {}) => {
58
58
  if (options.dump) return;
59
59
 
60
60
  if (method === 'get') {
61
- // url += '?' + qs.stringify(request.params, { arrayFormat: 'comma' });
62
61
  url += '?' + queryfy(request.params);
63
- console.log({ url })
64
62
  const response = await axios.get(url, { headers }).then(response => response.data).catch(catchIdosellError);
65
63
  return checkNext(request, response);
66
64
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idosell",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Idosell 3 REST connector",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -8,11 +8,13 @@ Package translates awkward gate names into more readable method names using REST
8
8
 
9
9
  ```javascript
10
10
  import idosell from 'idosell';
11
- const idosellRequest = idosell('SHOP_URL', 'API_KEY')
11
+ const idosellRequest = idosell('SHOP_URL', 'API_KEY', API_VERSION)
12
12
  ```
13
13
 
14
14
  **API_KEY** can be obtained in your Idosell panel.
15
- **SHOP_URL** is the base URI of your shop. Here are some examples:
15
+ **SHOP_URL** is the base URI of your shop.
16
+ **API_VERSION** version of the API to call, current default version is **v3**
17
+ Here are some examples:
16
18
  ```
17
19
  https://yourdomain.com
18
20
  https://clientXXXX.idosell.com
@@ -48,14 +50,14 @@ idosellRequest.deleteProductsOpinions.exec() // Translates to POST on products/o
48
50
  Alternatively to setting parameters in an object, you can chain several methods named after top-level parameters to set their value to your request. To execute the request after setting all the parameters, run the *exec()* method.
49
51
 
50
52
  ```javascript
51
- const idosellRequest = idosell('SHOP_URL', 'API_KEY');
52
- const categories = idosellRequest.ids([123, 456, 789]).languages(['pol', 'eng']).result_page(1).result_limit(10).getProductsCategories.exec();
53
+ const idosellRequest = idosell('https://yourdomain.com', 'API_KEY');
54
+ const categories = idosellRequest.getProductsCategories.ids([123, 456, 789]).languages(['pol', 'eng']).result_page(1).result_limit(10).exec();
53
55
  ```
54
56
 
55
57
  This example will generate the following GET request:
56
58
 
57
59
  ```
58
- https://yourdomain.com/api/admin/v1/products/categories?ids=123,456,789&languages=pol,eng&result_page=1&result_limit=10
60
+ https://yourdomain.com/api/admin/v3/products/categories?ids=123,456,789&languages=pol,eng&result_page=1&result_limit=10
59
61
  ```
60
62
 
61
63
  A POST request will generate a JSON body request.
@@ -241,7 +243,7 @@ This will translate to following request parameters:
241
243
  This method is used specifically for updating and creating products and allows you to easily set multiple types of descriptions in different languages and different shops.
242
244
 
243
245
  ```javascript
244
- setText(text, type, languageId, shopId)
246
+ idosellRequest.putProducts.setText(text, type, languageId, shopId)
245
247
  ```
246
248
 
247
249
  | Field | Description | Default | Possible values |
@@ -311,4 +313,8 @@ You can use the *getParams()* function to retrieve request parameters as Javascr
311
313
  ```javascript
312
314
  const orderRequest = idosellRequest.getOrders.ordersSerialNumbers([123, 456, 789]).getParams();
313
315
  // Will return Object: { ordersSerialNumbers: [ 123, 456, 789 ] }
314
- ```
316
+ ```
317
+
318
+ ## examples
319
+
320
+ Read documentation and examples on [This page](https://idosell-converter.vercel.app/examples)
@@ -1,8 +1,8 @@
1
1
  import idosell from "./dist/index.js"
2
- import { expect, test } from 'vitest'
2
+ import { expect, test } from "vitest"
3
3
 
4
- test('getClientsBalanceActive', () => {
5
- const params = idosell().getClientsBalance.active('yes').getParams();
4
+ test("getClientsBalanceActive", () => {
5
+ const params = idosell().getClientsBalance.active("yes").getParams();
6
6
  expect(params).toEqual({ "active": "yes" });
7
7
  })
8
8
 
@@ -16,7 +16,7 @@ test("getClientsBalanceClient_numbers", () => {
16
16
  expect(params).toEqual({"client_numbers":[123,456,678]});
17
17
  })
18
18
 
19
- test("getClientsBalanceLastPurchase", () => {
20
- const params = idosell().getClientsBalance.lastPurchase("2023-01-01", 1672704000000).getParams();
19
+ test("getClientsBalanceLastPurchased", () => {
20
+ const params = idosell().getClientsBalance.lastPurchased("2023-01-01", 1672704000000).getParams();
21
21
  expect(params).toEqual({"last_purchase_date":{"from":"2023-01-01","to":"2023-01-03"}});
22
22
  })
@@ -2,6 +2,11 @@ import idosell from "./dist/index.js"
2
2
  import { expect, test } from "vitest"
3
3
 
4
4
  test("getProductsSizesResult::page", () => {
5
- const params = idosell().getProductsSizes['result::page'](123).getParams();
5
+ const params = idosell().getProductsSizes["result::page"](123).getParams();
6
6
  expect(params).toEqual({"result::page":123});
7
+ })
8
+
9
+ test("getProductsSizesPage", () => {
10
+ const params = idosell().getProductsSizes.page(0,100).getParams();
11
+ expect(params).toEqual({"result::page":0,"result::pageNumber":100});
7
12
  })
@@ -4,4 +4,9 @@ import { expect, test } from "vitest"
4
4
  test("putProductsSetText", () => {
5
5
  const params = idosell().putProducts.productId(33).setText("Krzesło Pavon", "name").getParams();
6
6
  expect(params).toEqual({"products":[{"productId":33,"productNames":{"productNamesLangData":[{"langId":"pol","productName":"Krzesło Pavon"}]}}]});
7
+ })
8
+
9
+ test("putProductsCountryOfOrigin", () => {
10
+ const params = idosell().putProducts.productId(33).countryOfOrigin("PL").getParams();
11
+ expect(params).toEqual({"products":[{"productId":33,"countryOfOrigin":"PL"}]});
7
12
  })
@@ -3,18 +3,18 @@ import { expect, test } from "vitest"
3
3
 
4
4
  // Only partial test
5
5
 
6
- const ROOTPARAMS_NODE = 'rootparams';
6
+ const ROOTPARAMS_NODE = "rootparams";
7
7
  const routes = [
8
- 'postProductsCollectionsProducts',
9
- 'putProductsCollectionsProducts',
10
- 'putProductsCollectionsRenew',
11
- 'deleteProductsSizes',
12
- 'deleteClientsTags',
13
- 'deleteDiscountsRebatesCode',
14
- 'postDiscountsRebatesCard',
15
- 'putSystemCurrencies',
16
- 'putProductsParameters',
17
- 'postProductsRestore'
8
+ "postProductsCollectionsProducts",
9
+ "putProductsCollectionsProducts",
10
+ "putProductsCollectionsRenew",
11
+ "deleteProductsSizes",
12
+ "deleteClientsTags",
13
+ "deleteDiscountsRebatesCode",
14
+ "postDiscountsRebatesCard",
15
+ "putSystemCurrencies",
16
+ "putProductsParameters",
17
+ "postProductsRestore"
18
18
  ]
19
19
 
20
20
  for (const route of routes) {
package/tests/url.test.js CHANGED
@@ -7,5 +7,5 @@ import { expect, test } from "vitest"
7
7
  test("putWmsSuppliersName", () => {
8
8
  const params = idosell().getClients.clientsIds([123,456,789]).lastPurchase("2023-01-01", 1672704000000).getParams();
9
9
  const search = queryfy(params);
10
- expect(search).toEqual('clientsIds=123%2C456%2C789&clientLastPurchaseDate%5BclientLastPurchaseDateBegin%5D=2023-01-01&clientLastPurchaseDate%5BclientLastPurchaseDateEnd%5D=2023-01-03')
10
+ expect(search).toEqual("clientsIds=123%2C456%2C789&clientLastPurchaseDate%5BclientLastPurchaseDateBegin%5D=2023-01-01&clientLastPurchaseDate%5BclientLastPurchaseDateEnd%5D=2023-01-03")
11
11
  })