@betterstore/sdk 0.3.70 → 0.3.71

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @betterstore/sdk
2
2
 
3
+ ## 0.3.71
4
+
5
+ ### Patch Changes
6
+
7
+ - bug fixes
8
+
3
9
  ## 0.3.70
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,43 +1,3 @@
1
- type Address = {
2
- name: string;
3
- company?: string;
4
- line1: string;
5
- line2?: string;
6
- city: string;
7
- state?: string;
8
- country: string;
9
- countryCode: string;
10
- zipCode: string;
11
- phone: string;
12
- };
13
- interface CustomerCreateParams {
14
- firstName: string;
15
- lastName: string;
16
- email: string;
17
- phone?: string;
18
- address?: Address;
19
- isSubscribedEmail?: boolean;
20
- isSubscribedSMS?: boolean;
21
- }
22
- interface CustomerUpdateParams {
23
- firstName?: string;
24
- lastName?: string;
25
- email?: string;
26
- phone?: string;
27
- address?: Address;
28
- isSubscribedEmail?: boolean;
29
- isSubscribedSMS?: boolean;
30
- }
31
- interface Customer$1 extends CustomerCreateParams {
32
- id: string;
33
- createdAt: string;
34
- updatedAt: string;
35
- }
36
- interface CustomerSubscription {
37
- cancelAtPeriodEnd: boolean;
38
- }
39
- type CustomerSubscriptionUpdateParams = Partial<Pick<CustomerSubscription, "cancelAtPeriodEnd">>;
40
-
41
1
  interface VariantOption {
42
2
  name: string;
43
3
  value: string;
@@ -101,6 +61,24 @@ interface Product {
101
61
  }
102
62
  interface ProductWithoutVariants extends Omit<Product, "productVariants"> {
103
63
  }
64
+ type ListProductsQuery = {
65
+ collectionId: string;
66
+ } | {
67
+ collectionSeoHandle: string;
68
+ };
69
+ type SortBy = "createdAt" | "updatedAt";
70
+ type SortOrder = "asc" | "desc";
71
+ type ListProductsParams = {
72
+ sortBy?: SortBy;
73
+ sortOrder?: SortOrder;
74
+ query?: string;
75
+ };
76
+ type RetrieveProductParams = {
77
+ seoHandle: string;
78
+ } | {
79
+ id: string;
80
+ };
81
+
104
82
  interface Collection {
105
83
  id: string;
106
84
  title: string;
@@ -113,17 +91,65 @@ interface Collection {
113
91
  interface CollectionWithProducts extends Collection {
114
92
  products: ProductWithoutVariants[];
115
93
  }
116
- type ListProductsQuery = {
117
- collectionId: string;
94
+ type RetrieveCollectionParams = {
95
+ seoHandle: string;
118
96
  } | {
119
- collectionSeoHandle: string;
97
+ id: string;
120
98
  };
121
- type SortBy = "createdAt" | "updatedAt" | "bestSelling";
122
- type SortOrder = "asc" | "desc";
123
- type ListProductsParams = {
124
- sortBy?: SortBy;
125
- sortOrder?: SortOrder;
126
- query?: string;
99
+
100
+ type Address = {
101
+ name: string;
102
+ company?: string;
103
+ line1: string;
104
+ line2?: string;
105
+ city: string;
106
+ state?: string;
107
+ country: string;
108
+ countryCode: string;
109
+ zipCode: string;
110
+ phone: string;
111
+ };
112
+ interface CustomerCreateParams {
113
+ firstName: string;
114
+ lastName: string;
115
+ email: string;
116
+ phone?: string;
117
+ address?: Address;
118
+ isSubscribedEmail?: boolean;
119
+ isSubscribedSMS?: boolean;
120
+ }
121
+ interface CustomerUpdateParams {
122
+ firstName?: string;
123
+ lastName?: string;
124
+ email?: string;
125
+ phone?: string;
126
+ address?: Address;
127
+ isSubscribedEmail?: boolean;
128
+ isSubscribedSMS?: boolean;
129
+ }
130
+ interface Customer$1 extends CustomerCreateParams {
131
+ id: string;
132
+ createdAt: string;
133
+ updatedAt: string;
134
+ }
135
+ interface CustomerSubscription {
136
+ cancelAtPeriodEnd: boolean;
137
+ }
138
+ type CustomerSubscriptionUpdateParams = Partial<Pick<CustomerSubscription, "cancelAtPeriodEnd">>;
139
+
140
+ interface Discount$1 {
141
+ id: string;
142
+ title: string;
143
+ description?: string;
144
+ images: string[];
145
+ seoPageTitle?: string;
146
+ seoDescription?: string;
147
+ seoHandle?: string;
148
+ }
149
+ type RetrieveDiscountParams = {
150
+ id: string;
151
+ } | {
152
+ code: string;
127
153
  };
128
154
 
129
155
  type ShippingRate = ZasilkovnaRate;
@@ -338,6 +364,13 @@ declare class Client {
338
364
  updateCustomer(clientSecret: string, customerId: string, params: CustomerUpdateParams): Promise<Customer$1>;
339
365
  }
340
366
 
367
+ declare class Collections {
368
+ private apiClient;
369
+ constructor(apiKey: string, proxy?: string);
370
+ list(): Promise<Collection[]>;
371
+ retrieve(params: RetrieveCollectionParams): Promise<CollectionWithProducts | null>;
372
+ }
373
+
341
374
  declare class Customer {
342
375
  private apiClient;
343
376
  constructor(apiKey: string, proxy?: string);
@@ -363,6 +396,13 @@ declare class Customer {
363
396
  updateCustomerSubscription(stripeSubscriptionId: string, params: CustomerSubscriptionUpdateParams): Promise<CustomerSubscription>;
364
397
  }
365
398
 
399
+ declare class Discounts {
400
+ private apiClient;
401
+ constructor(apiKey: string, proxy?: string);
402
+ list(): Promise<Discount$1[]>;
403
+ retrieve(params: RetrieveDiscountParams): Promise<Discount$1 | null>;
404
+ }
405
+
366
406
  declare class Helpers {
367
407
  proxy?: string;
368
408
  constructor(proxy?: string);
@@ -375,11 +415,7 @@ declare class Products {
375
415
  private apiClient;
376
416
  constructor(apiKey: string, proxy?: string);
377
417
  list(params?: ListProductsParams): Promise<ProductWithoutVariants[]>;
378
- retrieve(productId: string): Promise<Product | null>;
379
- retrieveBySeoHandle(seoHandle: string): Promise<Product | null>;
380
- listCollections(): Promise<Collection[]>;
381
- retrieveCollectionBySeoHandle(collectionSeoHandle: string): Promise<CollectionWithProducts>;
382
- retrieveCollection(collectionId: string): Promise<CollectionWithProducts>;
418
+ retrieve(params: RetrieveProductParams): Promise<Product | null>;
383
419
  }
384
420
 
385
421
  declare function createBetterStore(config: {
@@ -387,8 +423,10 @@ declare function createBetterStore(config: {
387
423
  proxy?: string;
388
424
  }): {
389
425
  checkout: Checkout;
390
- products: Products;
391
426
  customer: Customer;
427
+ discounts: Discounts;
428
+ collections: Collections;
429
+ products: Products;
392
430
  };
393
431
  declare function createStoreClient(config?: {
394
432
  proxy?: string;
@@ -397,4 +435,4 @@ declare function createStoreHelpers(config?: {
397
435
  proxy?: string;
398
436
  }): Helpers;
399
437
 
400
- export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Collection, type CollectionWithProducts, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type LineItem, type LineItemCreate, type ListProductsParams, type ListProductsQuery, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type SortBy, type SortOrder, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
438
+ export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Collection, type CollectionWithProducts, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type Discount$1 as Discount, type LineItem, type LineItemCreate, type ListProductsParams, type ListProductsQuery, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type RetrieveCollectionParams, type RetrieveDiscountParams, type RetrieveProductParams, type ShippingRate, type SortBy, type SortOrder, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
package/dist/index.d.ts CHANGED
@@ -1,43 +1,3 @@
1
- type Address = {
2
- name: string;
3
- company?: string;
4
- line1: string;
5
- line2?: string;
6
- city: string;
7
- state?: string;
8
- country: string;
9
- countryCode: string;
10
- zipCode: string;
11
- phone: string;
12
- };
13
- interface CustomerCreateParams {
14
- firstName: string;
15
- lastName: string;
16
- email: string;
17
- phone?: string;
18
- address?: Address;
19
- isSubscribedEmail?: boolean;
20
- isSubscribedSMS?: boolean;
21
- }
22
- interface CustomerUpdateParams {
23
- firstName?: string;
24
- lastName?: string;
25
- email?: string;
26
- phone?: string;
27
- address?: Address;
28
- isSubscribedEmail?: boolean;
29
- isSubscribedSMS?: boolean;
30
- }
31
- interface Customer$1 extends CustomerCreateParams {
32
- id: string;
33
- createdAt: string;
34
- updatedAt: string;
35
- }
36
- interface CustomerSubscription {
37
- cancelAtPeriodEnd: boolean;
38
- }
39
- type CustomerSubscriptionUpdateParams = Partial<Pick<CustomerSubscription, "cancelAtPeriodEnd">>;
40
-
41
1
  interface VariantOption {
42
2
  name: string;
43
3
  value: string;
@@ -101,6 +61,24 @@ interface Product {
101
61
  }
102
62
  interface ProductWithoutVariants extends Omit<Product, "productVariants"> {
103
63
  }
64
+ type ListProductsQuery = {
65
+ collectionId: string;
66
+ } | {
67
+ collectionSeoHandle: string;
68
+ };
69
+ type SortBy = "createdAt" | "updatedAt";
70
+ type SortOrder = "asc" | "desc";
71
+ type ListProductsParams = {
72
+ sortBy?: SortBy;
73
+ sortOrder?: SortOrder;
74
+ query?: string;
75
+ };
76
+ type RetrieveProductParams = {
77
+ seoHandle: string;
78
+ } | {
79
+ id: string;
80
+ };
81
+
104
82
  interface Collection {
105
83
  id: string;
106
84
  title: string;
@@ -113,17 +91,65 @@ interface Collection {
113
91
  interface CollectionWithProducts extends Collection {
114
92
  products: ProductWithoutVariants[];
115
93
  }
116
- type ListProductsQuery = {
117
- collectionId: string;
94
+ type RetrieveCollectionParams = {
95
+ seoHandle: string;
118
96
  } | {
119
- collectionSeoHandle: string;
97
+ id: string;
120
98
  };
121
- type SortBy = "createdAt" | "updatedAt" | "bestSelling";
122
- type SortOrder = "asc" | "desc";
123
- type ListProductsParams = {
124
- sortBy?: SortBy;
125
- sortOrder?: SortOrder;
126
- query?: string;
99
+
100
+ type Address = {
101
+ name: string;
102
+ company?: string;
103
+ line1: string;
104
+ line2?: string;
105
+ city: string;
106
+ state?: string;
107
+ country: string;
108
+ countryCode: string;
109
+ zipCode: string;
110
+ phone: string;
111
+ };
112
+ interface CustomerCreateParams {
113
+ firstName: string;
114
+ lastName: string;
115
+ email: string;
116
+ phone?: string;
117
+ address?: Address;
118
+ isSubscribedEmail?: boolean;
119
+ isSubscribedSMS?: boolean;
120
+ }
121
+ interface CustomerUpdateParams {
122
+ firstName?: string;
123
+ lastName?: string;
124
+ email?: string;
125
+ phone?: string;
126
+ address?: Address;
127
+ isSubscribedEmail?: boolean;
128
+ isSubscribedSMS?: boolean;
129
+ }
130
+ interface Customer$1 extends CustomerCreateParams {
131
+ id: string;
132
+ createdAt: string;
133
+ updatedAt: string;
134
+ }
135
+ interface CustomerSubscription {
136
+ cancelAtPeriodEnd: boolean;
137
+ }
138
+ type CustomerSubscriptionUpdateParams = Partial<Pick<CustomerSubscription, "cancelAtPeriodEnd">>;
139
+
140
+ interface Discount$1 {
141
+ id: string;
142
+ title: string;
143
+ description?: string;
144
+ images: string[];
145
+ seoPageTitle?: string;
146
+ seoDescription?: string;
147
+ seoHandle?: string;
148
+ }
149
+ type RetrieveDiscountParams = {
150
+ id: string;
151
+ } | {
152
+ code: string;
127
153
  };
128
154
 
129
155
  type ShippingRate = ZasilkovnaRate;
@@ -338,6 +364,13 @@ declare class Client {
338
364
  updateCustomer(clientSecret: string, customerId: string, params: CustomerUpdateParams): Promise<Customer$1>;
339
365
  }
340
366
 
367
+ declare class Collections {
368
+ private apiClient;
369
+ constructor(apiKey: string, proxy?: string);
370
+ list(): Promise<Collection[]>;
371
+ retrieve(params: RetrieveCollectionParams): Promise<CollectionWithProducts | null>;
372
+ }
373
+
341
374
  declare class Customer {
342
375
  private apiClient;
343
376
  constructor(apiKey: string, proxy?: string);
@@ -363,6 +396,13 @@ declare class Customer {
363
396
  updateCustomerSubscription(stripeSubscriptionId: string, params: CustomerSubscriptionUpdateParams): Promise<CustomerSubscription>;
364
397
  }
365
398
 
399
+ declare class Discounts {
400
+ private apiClient;
401
+ constructor(apiKey: string, proxy?: string);
402
+ list(): Promise<Discount$1[]>;
403
+ retrieve(params: RetrieveDiscountParams): Promise<Discount$1 | null>;
404
+ }
405
+
366
406
  declare class Helpers {
367
407
  proxy?: string;
368
408
  constructor(proxy?: string);
@@ -375,11 +415,7 @@ declare class Products {
375
415
  private apiClient;
376
416
  constructor(apiKey: string, proxy?: string);
377
417
  list(params?: ListProductsParams): Promise<ProductWithoutVariants[]>;
378
- retrieve(productId: string): Promise<Product | null>;
379
- retrieveBySeoHandle(seoHandle: string): Promise<Product | null>;
380
- listCollections(): Promise<Collection[]>;
381
- retrieveCollectionBySeoHandle(collectionSeoHandle: string): Promise<CollectionWithProducts>;
382
- retrieveCollection(collectionId: string): Promise<CollectionWithProducts>;
418
+ retrieve(params: RetrieveProductParams): Promise<Product | null>;
383
419
  }
384
420
 
385
421
  declare function createBetterStore(config: {
@@ -387,8 +423,10 @@ declare function createBetterStore(config: {
387
423
  proxy?: string;
388
424
  }): {
389
425
  checkout: Checkout;
390
- products: Products;
391
426
  customer: Customer;
427
+ discounts: Discounts;
428
+ collections: Collections;
429
+ products: Products;
392
430
  };
393
431
  declare function createStoreClient(config?: {
394
432
  proxy?: string;
@@ -397,4 +435,4 @@ declare function createStoreHelpers(config?: {
397
435
  proxy?: string;
398
436
  }): Helpers;
399
437
 
400
- export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Collection, type CollectionWithProducts, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type LineItem, type LineItemCreate, type ListProductsParams, type ListProductsQuery, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type SortBy, type SortOrder, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
438
+ export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Collection, type CollectionWithProducts, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type Discount$1 as Discount, type LineItem, type LineItemCreate, type ListProductsParams, type ListProductsQuery, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type RetrieveCollectionParams, type RetrieveDiscountParams, type RetrieveProductParams, type ShippingRate, type SortBy, type SortOrder, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
package/dist/index.js CHANGED
@@ -334,6 +334,44 @@ var Client = class {
334
334
  };
335
335
  var client_default = Client;
336
336
 
337
+ // src/collections/index.ts
338
+ var Collections = class {
339
+ constructor(apiKey, proxy) {
340
+ this.apiClient = createApiClient(apiKey, proxy);
341
+ }
342
+ list() {
343
+ return __async(this, null, function* () {
344
+ const data = yield this.apiClient.get("/collections");
345
+ return data;
346
+ });
347
+ }
348
+ retrieve(params) {
349
+ return __async(this, null, function* () {
350
+ if ("seoHandle" in params) {
351
+ const data2 = yield this.apiClient.get(
352
+ `/collections/${params.seoHandle}`
353
+ );
354
+ if (!data2) {
355
+ console.error(
356
+ `Collection with seoHandle ${params.seoHandle} not found`
357
+ );
358
+ return null;
359
+ }
360
+ return data2;
361
+ }
362
+ const data = yield this.apiClient.get(
363
+ `/collections/id/${params.id}`
364
+ );
365
+ if (!data) {
366
+ console.error(`Collection with id ${params.id} not found`);
367
+ return null;
368
+ }
369
+ return data;
370
+ });
371
+ }
372
+ };
373
+ var collections_default = Collections;
374
+
337
375
  // src/customer/index.ts
338
376
  var Customer = class {
339
377
  constructor(apiKey, proxy) {
@@ -397,6 +435,42 @@ var Customer = class {
397
435
  };
398
436
  var customer_default = Customer;
399
437
 
438
+ // src/discounts/index.ts
439
+ var Discounts = class {
440
+ constructor(apiKey, proxy) {
441
+ this.apiClient = createApiClient(apiKey, proxy);
442
+ }
443
+ list() {
444
+ return __async(this, null, function* () {
445
+ const data = yield this.apiClient.get("/discounts");
446
+ return data;
447
+ });
448
+ }
449
+ retrieve(params) {
450
+ return __async(this, null, function* () {
451
+ if ("code" in params) {
452
+ const data2 = yield this.apiClient.get(
453
+ `/discounts/code/${params.code}`
454
+ );
455
+ if (!data2) {
456
+ console.error(`Discount with code ${params.code} not found`);
457
+ return null;
458
+ }
459
+ return data2;
460
+ }
461
+ const data = yield this.apiClient.get(
462
+ `/discounts/id/${params.id}`
463
+ );
464
+ if (!data) {
465
+ console.error(`Discount with id ${params.id} not found`);
466
+ return null;
467
+ }
468
+ return data;
469
+ });
470
+ }
471
+ };
472
+ var discounts_default = Discounts;
473
+
400
474
  // src/helpers/index.ts
401
475
  var currencyLocales = {
402
476
  CZK: "cs-CZ",
@@ -521,50 +595,26 @@ var Products = class {
521
595
  return data;
522
596
  });
523
597
  }
524
- retrieve(productId) {
598
+ retrieve(params) {
525
599
  return __async(this, null, function* () {
526
- const data = yield this.apiClient.get(`/products/${productId}`);
527
- if (!data) {
528
- console.error(`Product with id ${productId} not found`);
529
- return null;
600
+ if ("seoHandle" in params) {
601
+ const data2 = yield this.apiClient.get(
602
+ `/products/${params.seoHandle}`
603
+ );
604
+ if (!data2) {
605
+ console.error(`Product with seoHandle ${params.seoHandle} not found`);
606
+ return null;
607
+ }
608
+ return data2;
530
609
  }
531
- return data;
532
- });
533
- }
534
- retrieveBySeoHandle(seoHandle) {
535
- return __async(this, null, function* () {
536
- const data = yield this.apiClient.get(
537
- `/products/seoHandle/${seoHandle}`
538
- );
610
+ const data = yield this.apiClient.get(`/products/${params.id}`);
539
611
  if (!data) {
540
- console.error(`Product with seoHandle ${seoHandle} not found`);
612
+ console.error(`Product with id ${params.id} not found`);
541
613
  return null;
542
614
  }
543
615
  return data;
544
616
  });
545
617
  }
546
- listCollections() {
547
- return __async(this, null, function* () {
548
- const data = yield this.apiClient.get("/collections");
549
- return data;
550
- });
551
- }
552
- retrieveCollectionBySeoHandle(collectionSeoHandle) {
553
- return __async(this, null, function* () {
554
- const data = yield this.apiClient.get(
555
- `/collections/${collectionSeoHandle}`
556
- );
557
- return data;
558
- });
559
- }
560
- retrieveCollection(collectionId) {
561
- return __async(this, null, function* () {
562
- const data = yield this.apiClient.get(
563
- `/collections/id/${collectionId}`
564
- );
565
- return data;
566
- });
567
- }
568
618
  };
569
619
  var products_default = Products;
570
620
 
@@ -575,8 +625,10 @@ function createBetterStore(config) {
575
625
  }
576
626
  return {
577
627
  checkout: new checkout_default(config.apiKey, config.proxy),
578
- products: new products_default(config.apiKey, config.proxy),
579
- customer: new customer_default(config.apiKey, config.proxy)
628
+ customer: new customer_default(config.apiKey, config.proxy),
629
+ discounts: new discounts_default(config.apiKey, config.proxy),
630
+ collections: new collections_default(config.apiKey, config.proxy),
631
+ products: new products_default(config.apiKey, config.proxy)
580
632
  };
581
633
  }
582
634
  function createStoreClient(config) {
package/dist/index.mjs CHANGED
@@ -297,6 +297,44 @@ var Client = class {
297
297
  };
298
298
  var client_default = Client;
299
299
 
300
+ // src/collections/index.ts
301
+ var Collections = class {
302
+ constructor(apiKey, proxy) {
303
+ this.apiClient = createApiClient(apiKey, proxy);
304
+ }
305
+ list() {
306
+ return __async(this, null, function* () {
307
+ const data = yield this.apiClient.get("/collections");
308
+ return data;
309
+ });
310
+ }
311
+ retrieve(params) {
312
+ return __async(this, null, function* () {
313
+ if ("seoHandle" in params) {
314
+ const data2 = yield this.apiClient.get(
315
+ `/collections/${params.seoHandle}`
316
+ );
317
+ if (!data2) {
318
+ console.error(
319
+ `Collection with seoHandle ${params.seoHandle} not found`
320
+ );
321
+ return null;
322
+ }
323
+ return data2;
324
+ }
325
+ const data = yield this.apiClient.get(
326
+ `/collections/id/${params.id}`
327
+ );
328
+ if (!data) {
329
+ console.error(`Collection with id ${params.id} not found`);
330
+ return null;
331
+ }
332
+ return data;
333
+ });
334
+ }
335
+ };
336
+ var collections_default = Collections;
337
+
300
338
  // src/customer/index.ts
301
339
  var Customer = class {
302
340
  constructor(apiKey, proxy) {
@@ -360,6 +398,42 @@ var Customer = class {
360
398
  };
361
399
  var customer_default = Customer;
362
400
 
401
+ // src/discounts/index.ts
402
+ var Discounts = class {
403
+ constructor(apiKey, proxy) {
404
+ this.apiClient = createApiClient(apiKey, proxy);
405
+ }
406
+ list() {
407
+ return __async(this, null, function* () {
408
+ const data = yield this.apiClient.get("/discounts");
409
+ return data;
410
+ });
411
+ }
412
+ retrieve(params) {
413
+ return __async(this, null, function* () {
414
+ if ("code" in params) {
415
+ const data2 = yield this.apiClient.get(
416
+ `/discounts/code/${params.code}`
417
+ );
418
+ if (!data2) {
419
+ console.error(`Discount with code ${params.code} not found`);
420
+ return null;
421
+ }
422
+ return data2;
423
+ }
424
+ const data = yield this.apiClient.get(
425
+ `/discounts/id/${params.id}`
426
+ );
427
+ if (!data) {
428
+ console.error(`Discount with id ${params.id} not found`);
429
+ return null;
430
+ }
431
+ return data;
432
+ });
433
+ }
434
+ };
435
+ var discounts_default = Discounts;
436
+
363
437
  // src/helpers/index.ts
364
438
  var currencyLocales = {
365
439
  CZK: "cs-CZ",
@@ -484,50 +558,26 @@ var Products = class {
484
558
  return data;
485
559
  });
486
560
  }
487
- retrieve(productId) {
561
+ retrieve(params) {
488
562
  return __async(this, null, function* () {
489
- const data = yield this.apiClient.get(`/products/${productId}`);
490
- if (!data) {
491
- console.error(`Product with id ${productId} not found`);
492
- return null;
563
+ if ("seoHandle" in params) {
564
+ const data2 = yield this.apiClient.get(
565
+ `/products/${params.seoHandle}`
566
+ );
567
+ if (!data2) {
568
+ console.error(`Product with seoHandle ${params.seoHandle} not found`);
569
+ return null;
570
+ }
571
+ return data2;
493
572
  }
494
- return data;
495
- });
496
- }
497
- retrieveBySeoHandle(seoHandle) {
498
- return __async(this, null, function* () {
499
- const data = yield this.apiClient.get(
500
- `/products/seoHandle/${seoHandle}`
501
- );
573
+ const data = yield this.apiClient.get(`/products/${params.id}`);
502
574
  if (!data) {
503
- console.error(`Product with seoHandle ${seoHandle} not found`);
575
+ console.error(`Product with id ${params.id} not found`);
504
576
  return null;
505
577
  }
506
578
  return data;
507
579
  });
508
580
  }
509
- listCollections() {
510
- return __async(this, null, function* () {
511
- const data = yield this.apiClient.get("/collections");
512
- return data;
513
- });
514
- }
515
- retrieveCollectionBySeoHandle(collectionSeoHandle) {
516
- return __async(this, null, function* () {
517
- const data = yield this.apiClient.get(
518
- `/collections/${collectionSeoHandle}`
519
- );
520
- return data;
521
- });
522
- }
523
- retrieveCollection(collectionId) {
524
- return __async(this, null, function* () {
525
- const data = yield this.apiClient.get(
526
- `/collections/id/${collectionId}`
527
- );
528
- return data;
529
- });
530
- }
531
581
  };
532
582
  var products_default = Products;
533
583
 
@@ -538,8 +588,10 @@ function createBetterStore(config) {
538
588
  }
539
589
  return {
540
590
  checkout: new checkout_default(config.apiKey, config.proxy),
541
- products: new products_default(config.apiKey, config.proxy),
542
- customer: new customer_default(config.apiKey, config.proxy)
591
+ customer: new customer_default(config.apiKey, config.proxy),
592
+ discounts: new discounts_default(config.apiKey, config.proxy),
593
+ collections: new collections_default(config.apiKey, config.proxy),
594
+ products: new products_default(config.apiKey, config.proxy)
543
595
  };
544
596
  }
545
597
  function createStoreClient(config) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/sdk",
3
- "version": "0.3.70",
3
+ "version": "0.3.71",
4
4
  "description": "E-commerce for Developers",
5
5
  "private": false,
6
6
  "publishConfig": {