@betterstore/sdk 0.6.5 → 0.6.7
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/index.js +10 -10
- package/dist/index.mjs +10 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -420,7 +420,7 @@ var Client = class {
|
|
|
420
420
|
const { data } = await apiClient.get("/helpers/address/autosuggest", {
|
|
421
421
|
params
|
|
422
422
|
});
|
|
423
|
-
return data;
|
|
423
|
+
return data ?? [];
|
|
424
424
|
}
|
|
425
425
|
async lookupAddress(clientSecret, params) {
|
|
426
426
|
const apiClient = createApiClient(clientSecret, this.proxy);
|
|
@@ -439,15 +439,15 @@ var Collections = class {
|
|
|
439
439
|
this.apiClient = createApiClient(apiKey, proxy);
|
|
440
440
|
}
|
|
441
441
|
async list(params) {
|
|
442
|
-
const data = await this.apiClient.post(`/collections`, params);
|
|
443
|
-
if (!data ||
|
|
442
|
+
const data = await this.apiClient.post(`/collections`, params ?? {});
|
|
443
|
+
if (!data || "isError" in data && data.isError || !("collections" in data)) {
|
|
444
444
|
return [];
|
|
445
445
|
}
|
|
446
446
|
return data.collections;
|
|
447
447
|
}
|
|
448
448
|
async retrieve(params) {
|
|
449
449
|
const data = await this.apiClient.post(`/collections/retrieve`, params);
|
|
450
|
-
if ("isError" in data && data.isError || !data || !("
|
|
450
|
+
if ("isError" in data && data.isError || !data || !("collection" in data)) {
|
|
451
451
|
console.error(`Collection not found`);
|
|
452
452
|
return null;
|
|
453
453
|
}
|
|
@@ -533,9 +533,9 @@ var Discounts = class {
|
|
|
533
533
|
async list(params) {
|
|
534
534
|
const data = await this.apiClient.post(
|
|
535
535
|
"/discounts",
|
|
536
|
-
params
|
|
536
|
+
params ?? {}
|
|
537
537
|
);
|
|
538
|
-
if (!data ||
|
|
538
|
+
if (!data || "isError" in data && data.isError || !("discounts" in data)) {
|
|
539
539
|
return [];
|
|
540
540
|
}
|
|
541
541
|
return data.discounts;
|
|
@@ -545,7 +545,7 @@ var Discounts = class {
|
|
|
545
545
|
`/discounts/retrieve`,
|
|
546
546
|
params
|
|
547
547
|
);
|
|
548
|
-
if ("isError" in data && data.isError || !data || !("
|
|
548
|
+
if ("isError" in data && data.isError || !data || !("discount" in data)) {
|
|
549
549
|
console.error(`Discount not found`);
|
|
550
550
|
return null;
|
|
551
551
|
}
|
|
@@ -563,16 +563,16 @@ var Products = class {
|
|
|
563
563
|
async list(params) {
|
|
564
564
|
const data = await this.apiClient.post(
|
|
565
565
|
"/products",
|
|
566
|
-
params
|
|
566
|
+
params ?? {}
|
|
567
567
|
);
|
|
568
|
-
if (!data ||
|
|
568
|
+
if (!data || "isError" in data && data.isError || !("products" in data)) {
|
|
569
569
|
return [];
|
|
570
570
|
}
|
|
571
571
|
return data.products;
|
|
572
572
|
}
|
|
573
573
|
async retrieve(params) {
|
|
574
574
|
const data = await this.apiClient.post("/products/retrieve", params);
|
|
575
|
-
if ("isError" in data && data.isError || !data || !("
|
|
575
|
+
if ("isError" in data && data.isError || !data || !("product" in data)) {
|
|
576
576
|
console.error(`Product not found`);
|
|
577
577
|
return null;
|
|
578
578
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -380,7 +380,7 @@ var Client = class {
|
|
|
380
380
|
const { data } = await apiClient.get("/helpers/address/autosuggest", {
|
|
381
381
|
params
|
|
382
382
|
});
|
|
383
|
-
return data;
|
|
383
|
+
return data ?? [];
|
|
384
384
|
}
|
|
385
385
|
async lookupAddress(clientSecret, params) {
|
|
386
386
|
const apiClient = createApiClient(clientSecret, this.proxy);
|
|
@@ -399,15 +399,15 @@ var Collections = class {
|
|
|
399
399
|
this.apiClient = createApiClient(apiKey, proxy);
|
|
400
400
|
}
|
|
401
401
|
async list(params) {
|
|
402
|
-
const data = await this.apiClient.post(`/collections`, params);
|
|
403
|
-
if (!data ||
|
|
402
|
+
const data = await this.apiClient.post(`/collections`, params ?? {});
|
|
403
|
+
if (!data || "isError" in data && data.isError || !("collections" in data)) {
|
|
404
404
|
return [];
|
|
405
405
|
}
|
|
406
406
|
return data.collections;
|
|
407
407
|
}
|
|
408
408
|
async retrieve(params) {
|
|
409
409
|
const data = await this.apiClient.post(`/collections/retrieve`, params);
|
|
410
|
-
if ("isError" in data && data.isError || !data || !("
|
|
410
|
+
if ("isError" in data && data.isError || !data || !("collection" in data)) {
|
|
411
411
|
console.error(`Collection not found`);
|
|
412
412
|
return null;
|
|
413
413
|
}
|
|
@@ -493,9 +493,9 @@ var Discounts = class {
|
|
|
493
493
|
async list(params) {
|
|
494
494
|
const data = await this.apiClient.post(
|
|
495
495
|
"/discounts",
|
|
496
|
-
params
|
|
496
|
+
params ?? {}
|
|
497
497
|
);
|
|
498
|
-
if (!data ||
|
|
498
|
+
if (!data || "isError" in data && data.isError || !("discounts" in data)) {
|
|
499
499
|
return [];
|
|
500
500
|
}
|
|
501
501
|
return data.discounts;
|
|
@@ -505,7 +505,7 @@ var Discounts = class {
|
|
|
505
505
|
`/discounts/retrieve`,
|
|
506
506
|
params
|
|
507
507
|
);
|
|
508
|
-
if ("isError" in data && data.isError || !data || !("
|
|
508
|
+
if ("isError" in data && data.isError || !data || !("discount" in data)) {
|
|
509
509
|
console.error(`Discount not found`);
|
|
510
510
|
return null;
|
|
511
511
|
}
|
|
@@ -523,16 +523,16 @@ var Products = class {
|
|
|
523
523
|
async list(params) {
|
|
524
524
|
const data = await this.apiClient.post(
|
|
525
525
|
"/products",
|
|
526
|
-
params
|
|
526
|
+
params ?? {}
|
|
527
527
|
);
|
|
528
|
-
if (!data ||
|
|
528
|
+
if (!data || "isError" in data && data.isError || !("products" in data)) {
|
|
529
529
|
return [];
|
|
530
530
|
}
|
|
531
531
|
return data.products;
|
|
532
532
|
}
|
|
533
533
|
async retrieve(params) {
|
|
534
534
|
const data = await this.apiClient.post("/products/retrieve", params);
|
|
535
|
-
if ("isError" in data && data.isError || !data || !("
|
|
535
|
+
if ("isError" in data && data.isError || !data || !("product" in data)) {
|
|
536
536
|
console.error(`Product not found`);
|
|
537
537
|
return null;
|
|
538
538
|
}
|