lightspeed-retail-sdk 1.0.11 → 1.0.13

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 (3) hide show
  1. package/README.md +2 -1
  2. package/index.js +24 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -21,7 +21,8 @@ getVendor()
21
21
  getSales()
22
22
  getSale()
23
23
  getSaleLinesByItem()
24
- getSaleLinesByItems("[7957, 7944]")
24
+ getSaleLinesByItems(`39, 2126, 3505`, startDate?, endDate?)
25
+ getSaleLinesByVendorID(vendorID, startDate?, endDate?)
25
26
  getOrdersByVendorID()
26
27
  getOpenOrdersByVendorID()
27
28
  ```
package/index.js CHANGED
@@ -105,7 +105,7 @@ class LightspeedRetailSDK {
105
105
  if (retries < this.maxRetries) {
106
106
  console.log(`Error: ${err}, retrying in 2 seconds...`);
107
107
  await new Promise((resolve) => setTimeout(resolve, 2000));
108
- return await this.getResource(url, retries + 1);
108
+ return await this.getResource(options.url, retries + 1);
109
109
  } else {
110
110
  console.error(`Failed Request statusText: `, res.statusText);
111
111
  console.log(`Failed data: `, response.data);
@@ -420,13 +420,33 @@ class LightspeedRetailSDK {
420
420
  }
421
421
  }
422
422
 
423
- async getSaleLinesByItems(itemIDs, relations) {
423
+ async getSaleLinesByItems(itemIDs, startDate = undefined, endDate = undefined) {
424
424
  const options = {
425
- url: `${this.baseUrl}/${this.accountID}/SaleLine.json?itemID=IN,${itemIDs}`,
425
+ url: `${this.baseUrl}/${this.accountID}/SaleLine.json?itemID=IN,[${itemIDs}]`,
426
426
  method: "GET",
427
427
  };
428
428
 
429
- if (relations) options.url = options.url + `&load_relations=${relations}`;
429
+ if (startDate && endDate)
430
+ options.url =
431
+ options.url + `&timeStamp=%3E%3C%2C${startDate}%2C${endDate}&sort=timeStamp`;
432
+
433
+ try {
434
+ const response = await this.getAllData(options);
435
+ return response;
436
+ } catch (error) {
437
+ return this.handleError("GET SALE ERROR", error);
438
+ }
439
+ }
440
+
441
+ async getSaleLinesByVendorID(vendorID, startDate = undefined, endDate = undefined) {
442
+ const options = {
443
+ url: `${this.baseUrl}/${this.accountID}/SaleLine.json?load_relations=["Item"]&Item.defaultVendorID=${vendorID}`,
444
+ method: "GET",
445
+ };
446
+
447
+ if (startDate && endDate)
448
+ options.url =
449
+ options.url + `&timeStamp=%3E%3C%2C${startDate}%2C${endDate}&sort=timeStamp`;
430
450
 
431
451
  try {
432
452
  const response = await this.getAllData(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lightspeed-retail-sdk",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Another unofficial Lightspeed Retail API SDK for Node.js",
5
5
  "main": "index.js",
6
6
  "scripts": {