@behio/storefront-sdk 0.38.0 → 0.42.0
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/{chunk-FOUBL2EQ.js → chunk-3TPJG2WV.js} +568 -147
- package/dist/{chunk-MF5LMHZ4.mjs → chunk-QOZYQMK2.mjs} +566 -145
- package/dist/{client-Cb_eHKm9.d.mts → client-B0vlHxB1.d.mts} +312 -6
- package/dist/{client-Cb_eHKm9.d.ts → client-B0vlHxB1.d.ts} +312 -6
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +142 -40
- package/dist/index.mjs +111 -9
- package/dist/next.d.mts +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +2 -2
- package/dist/next.mjs +1 -1
- package/dist/react.d.mts +3022 -4
- package/dist/react.d.ts +3022 -4
- package/dist/react.js +2584 -477
- package/dist/react.mjs +2090 -86
- package/package.json +1 -1
- package/dist/chunk-CZRSJULD.js +0 -118
- package/dist/chunk-QUU76QUB.mjs +0 -118
|
@@ -50,13 +50,19 @@ var BehioApiError = class _BehioApiError extends Error {
|
|
|
50
50
|
if (status === 429) return "RATE_LIMITED";
|
|
51
51
|
if (status >= 500) return "INTERNAL_ERROR";
|
|
52
52
|
const msg = (_optionalChain([body, 'optionalAccess', _ => _.message]) || "").toLowerCase();
|
|
53
|
-
if (msg.includes("invalid") && msg.includes("password"))
|
|
54
|
-
|
|
53
|
+
if (msg.includes("invalid") && msg.includes("password"))
|
|
54
|
+
return "INVALID_CREDENTIALS";
|
|
55
|
+
if (msg.includes("invalid") && msg.includes("email"))
|
|
56
|
+
return "INVALID_CREDENTIALS";
|
|
55
57
|
if (msg.includes("cart") && msg.includes("empty")) return "CART_EMPTY";
|
|
56
|
-
if (msg.includes("product") && msg.includes("not found"))
|
|
57
|
-
|
|
58
|
-
if (msg.includes("discount") && msg.includes("
|
|
59
|
-
|
|
58
|
+
if (msg.includes("product") && msg.includes("not found"))
|
|
59
|
+
return "PRODUCT_NOT_FOUND";
|
|
60
|
+
if (msg.includes("discount") && msg.includes("expired"))
|
|
61
|
+
return "DISCOUNT_EXPIRED";
|
|
62
|
+
if (msg.includes("discount") && msg.includes("invalid"))
|
|
63
|
+
return "INVALID_DISCOUNT";
|
|
64
|
+
if (msg.includes("token") && msg.includes("expired"))
|
|
65
|
+
return "TOKEN_EXPIRED";
|
|
60
66
|
if (msg.includes("cancel")) return "ORDER_NOT_CANCELLABLE";
|
|
61
67
|
if (status === 400) return "VALIDATION_ERROR";
|
|
62
68
|
return "UNKNOWN";
|
|
@@ -125,7 +131,10 @@ var BehioStorefront = class {
|
|
|
125
131
|
// Rate limit tracking
|
|
126
132
|
this.rateLimitRemaining = null;
|
|
127
133
|
this.rateLimitReset = null;
|
|
128
|
-
this.baseUrl = (config.baseUrl || "https://be.behio.com").replace(
|
|
134
|
+
this.baseUrl = (config.baseUrl || "https://be.behio.com").replace(
|
|
135
|
+
/\/$/,
|
|
136
|
+
""
|
|
137
|
+
);
|
|
129
138
|
this.apiKey = config.apiKey;
|
|
130
139
|
this.shopDomain = config.shopDomain;
|
|
131
140
|
this.defaultLocale = config.locale;
|
|
@@ -150,6 +159,7 @@ var BehioStorefront = class {
|
|
|
150
159
|
this.shipping = new ShippingModule(this);
|
|
151
160
|
this.newsletter = new NewsletterModule(this);
|
|
152
161
|
this.subscriptions = new SubscriptionsModule(this);
|
|
162
|
+
this.certificates = new CourseCertificatesModule(this);
|
|
153
163
|
}
|
|
154
164
|
// --- Public methods ---
|
|
155
165
|
/**
|
|
@@ -195,7 +205,9 @@ var BehioStorefront = class {
|
|
|
195
205
|
}
|
|
196
206
|
/** Email-gate completion: trade an e-mail for the personal discount code. */
|
|
197
207
|
async claimOfferByEmail(offerId, input) {
|
|
198
|
-
return this.request("POST", `/offers/${offerId}/claim-email`, {
|
|
208
|
+
return this.request("POST", `/offers/${offerId}/claim-email`, {
|
|
209
|
+
body: input
|
|
210
|
+
});
|
|
199
211
|
}
|
|
200
212
|
/** Get basic shop info */
|
|
201
213
|
async getShopInfo() {
|
|
@@ -291,14 +303,18 @@ var BehioStorefront = class {
|
|
|
291
303
|
addRequestInterceptor(fn) {
|
|
292
304
|
this.requestInterceptors.push(fn);
|
|
293
305
|
return () => {
|
|
294
|
-
this.requestInterceptors = this.requestInterceptors.filter(
|
|
306
|
+
this.requestInterceptors = this.requestInterceptors.filter(
|
|
307
|
+
(f) => f !== fn
|
|
308
|
+
);
|
|
295
309
|
};
|
|
296
310
|
}
|
|
297
311
|
/** Add a response interceptor. Returns an unsubscribe function. */
|
|
298
312
|
addResponseInterceptor(fn) {
|
|
299
313
|
this.responseInterceptors.push(fn);
|
|
300
314
|
return () => {
|
|
301
|
-
this.responseInterceptors = this.responseInterceptors.filter(
|
|
315
|
+
this.responseInterceptors = this.responseInterceptors.filter(
|
|
316
|
+
(f) => f !== fn
|
|
317
|
+
);
|
|
302
318
|
};
|
|
303
319
|
}
|
|
304
320
|
// --- Rate limit ---
|
|
@@ -351,6 +367,33 @@ var BehioStorefront = class {
|
|
|
351
367
|
return { data: null, error: toSdkError(err2) };
|
|
352
368
|
}
|
|
353
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* Binary GET (PDF downloads). Same auth headers as `request()`, but the
|
|
372
|
+
* response is returned as a Blob instead of parsed JSON.
|
|
373
|
+
*
|
|
374
|
+
* @internal — use the typed module methods (behio.certificates.downloadPdf).
|
|
375
|
+
*/
|
|
376
|
+
async requestBlob(path) {
|
|
377
|
+
try {
|
|
378
|
+
const headers = { "X-Api-Key": this.apiKey };
|
|
379
|
+
if (this.accessToken)
|
|
380
|
+
headers.Authorization = `Bearer ${this.accessToken}`;
|
|
381
|
+
const res = await this.fetchFn(`${this.baseUrl}/storefront/v1${path}`, {
|
|
382
|
+
headers
|
|
383
|
+
});
|
|
384
|
+
if (!res.ok) {
|
|
385
|
+
let body = null;
|
|
386
|
+
try {
|
|
387
|
+
body = await res.json();
|
|
388
|
+
} catch (e3) {
|
|
389
|
+
}
|
|
390
|
+
throw new BehioApiError(res.status, body);
|
|
391
|
+
}
|
|
392
|
+
return ok(await res.blob());
|
|
393
|
+
} catch (err2) {
|
|
394
|
+
return { data: null, error: toSdkError(err2) };
|
|
395
|
+
}
|
|
396
|
+
}
|
|
354
397
|
/**
|
|
355
398
|
* Throws on failure (API error / network / timeout). Kept private so
|
|
356
399
|
* internal auth refresh recursion keeps its existing control flow —
|
|
@@ -418,7 +461,9 @@ var BehioStorefront = class {
|
|
|
418
461
|
clearTimeout(timeoutId);
|
|
419
462
|
throw new BehioNetworkError("Request aborted", false);
|
|
420
463
|
}
|
|
421
|
-
options.signal.addEventListener("abort", () => controller.abort(), {
|
|
464
|
+
options.signal.addEventListener("abort", () => controller.abort(), {
|
|
465
|
+
once: true
|
|
466
|
+
});
|
|
422
467
|
}
|
|
423
468
|
let res;
|
|
424
469
|
try {
|
|
@@ -437,7 +482,9 @@ var BehioStorefront = class {
|
|
|
437
482
|
);
|
|
438
483
|
this.emit("error", networkErr);
|
|
439
484
|
if (attempt < this.retries) {
|
|
440
|
-
await new Promise(
|
|
485
|
+
await new Promise(
|
|
486
|
+
(r) => setTimeout(r, this.retryDelay * (attempt + 1))
|
|
487
|
+
);
|
|
441
488
|
continue;
|
|
442
489
|
}
|
|
443
490
|
throw networkErr;
|
|
@@ -449,24 +496,36 @@ var BehioStorefront = class {
|
|
|
449
496
|
if (remaining) this.rateLimitRemaining = parseInt(remaining, 10);
|
|
450
497
|
if (reset) this.rateLimitReset = parseInt(reset, 10);
|
|
451
498
|
if (this.rateLimitRemaining !== null && this.rateLimitRemaining <= 5) {
|
|
452
|
-
this.emit("rate-limit-warning", {
|
|
499
|
+
this.emit("rate-limit-warning", {
|
|
500
|
+
remaining: this.rateLimitRemaining,
|
|
501
|
+
reset: this.rateLimitReset
|
|
502
|
+
});
|
|
453
503
|
}
|
|
454
504
|
this.emit("response", { method, path, status: res.status });
|
|
455
505
|
if (!res.ok) {
|
|
456
506
|
const body = await res.json().catch(() => null);
|
|
457
|
-
const apiError = new BehioApiError(
|
|
507
|
+
const apiError = new BehioApiError(
|
|
508
|
+
res.status,
|
|
509
|
+
body,
|
|
510
|
+
_optionalChain([body, 'optionalAccess', _17 => _17.message]) || `API Error ${res.status}`
|
|
511
|
+
);
|
|
458
512
|
if (res.status === 401 && this.refreshToken && _optionalChain([options, 'optionalAccess', _18 => _18.auth]) !== false && !_optionalChain([options, 'optionalAccess', _19 => _19._isRetryAfterRefresh])) {
|
|
459
513
|
try {
|
|
460
514
|
await this.handleTokenRefresh();
|
|
461
|
-
return this.rawRequest(method, path, {
|
|
462
|
-
|
|
515
|
+
return this.rawRequest(method, path, {
|
|
516
|
+
...options,
|
|
517
|
+
_isRetryAfterRefresh: true
|
|
518
|
+
});
|
|
519
|
+
} catch (e4) {
|
|
463
520
|
this.emit("error", apiError);
|
|
464
521
|
throw apiError;
|
|
465
522
|
}
|
|
466
523
|
}
|
|
467
524
|
this.emit("error", apiError);
|
|
468
525
|
if (attempt < this.retries && apiError.isRetryable) {
|
|
469
|
-
await new Promise(
|
|
526
|
+
await new Promise(
|
|
527
|
+
(r) => setTimeout(r, this.retryDelay * (attempt + 1))
|
|
528
|
+
);
|
|
470
529
|
continue;
|
|
471
530
|
}
|
|
472
531
|
throw apiError;
|
|
@@ -474,8 +533,12 @@ var BehioStorefront = class {
|
|
|
474
533
|
const responseData = res.status === 204 ? null : await res.json();
|
|
475
534
|
for (const interceptor of this.responseInterceptors) {
|
|
476
535
|
try {
|
|
477
|
-
await interceptor({
|
|
478
|
-
|
|
536
|
+
await interceptor({
|
|
537
|
+
status: res.status,
|
|
538
|
+
data: responseData,
|
|
539
|
+
headers: res.headers
|
|
540
|
+
});
|
|
541
|
+
} catch (e5) {
|
|
479
542
|
}
|
|
480
543
|
}
|
|
481
544
|
return responseData;
|
|
@@ -503,25 +566,37 @@ var CatalogModule = class {
|
|
|
503
566
|
if (query.inStock !== void 0) q.inStock = query.inStock;
|
|
504
567
|
if (query.ratingMin !== void 0) q.ratingMin = query.ratingMin;
|
|
505
568
|
if (query.search) q.search = query.search;
|
|
506
|
-
if (query.customFields)
|
|
569
|
+
if (query.customFields)
|
|
570
|
+
q.customFields = JSON.stringify(query.customFields);
|
|
507
571
|
if (query.facets) q.facets = JSON.stringify(query.facets);
|
|
508
572
|
if (query.ids && query.ids.length > 0) q.ids = query.ids;
|
|
509
573
|
if (query.slugs && query.slugs.length > 0) q.slugs = query.slugs;
|
|
510
574
|
if (query.labels && query.labels.length > 0) q.labels = query.labels;
|
|
511
|
-
if (query.categories && query.categories.length > 0)
|
|
512
|
-
|
|
513
|
-
if (query.
|
|
575
|
+
if (query.categories && query.categories.length > 0)
|
|
576
|
+
q.categories = query.categories;
|
|
577
|
+
if (query.excludeIds && query.excludeIds.length > 0)
|
|
578
|
+
q.excludeIds = query.excludeIds;
|
|
579
|
+
if (query.excludeCategories && query.excludeCategories.length > 0)
|
|
580
|
+
q.excludeCategories = query.excludeCategories;
|
|
514
581
|
if (query.hasDiscount !== void 0) q.hasDiscount = query.hasDiscount;
|
|
515
582
|
if (query.isFeatured !== void 0) q.isFeatured = query.isFeatured;
|
|
516
583
|
if (query.createdAfter !== void 0) q.createdAfter = query.createdAfter;
|
|
517
584
|
}
|
|
518
|
-
return this.client.request(
|
|
585
|
+
return this.client.request(
|
|
586
|
+
"GET",
|
|
587
|
+
"/catalog/products",
|
|
588
|
+
{ query: q }
|
|
589
|
+
);
|
|
519
590
|
}
|
|
520
591
|
/** Get product detail by slug */
|
|
521
592
|
async getProduct(slug, options) {
|
|
522
|
-
return this.client.request(
|
|
523
|
-
|
|
524
|
-
|
|
593
|
+
return this.client.request(
|
|
594
|
+
"GET",
|
|
595
|
+
`/catalog/products/${slug}`,
|
|
596
|
+
{
|
|
597
|
+
query: { locale: _optionalChain([options, 'optionalAccess', _20 => _20.locale]), currency: _optionalChain([options, 'optionalAccess', _21 => _21.currency]) }
|
|
598
|
+
}
|
|
599
|
+
);
|
|
525
600
|
}
|
|
526
601
|
/** Get category tree */
|
|
527
602
|
async getCategories(locale) {
|
|
@@ -531,7 +606,11 @@ var CatalogModule = class {
|
|
|
531
606
|
}
|
|
532
607
|
/** Get category detail by slug */
|
|
533
608
|
async getCategory(slug, locale) {
|
|
534
|
-
return this.client.request(
|
|
609
|
+
return this.client.request(
|
|
610
|
+
"GET",
|
|
611
|
+
`/catalog/categories/${slug}`,
|
|
612
|
+
{ query: { locale } }
|
|
613
|
+
);
|
|
535
614
|
}
|
|
536
615
|
/** Get products in a category */
|
|
537
616
|
async getCategoryProducts(slug, query) {
|
|
@@ -543,7 +622,11 @@ var CatalogModule = class {
|
|
|
543
622
|
if (query.locale) q.locale = query.locale;
|
|
544
623
|
if (query.currency) q.currency = query.currency;
|
|
545
624
|
}
|
|
546
|
-
return this.client.request(
|
|
625
|
+
return this.client.request(
|
|
626
|
+
"GET",
|
|
627
|
+
`/catalog/categories/${slug}/products`,
|
|
628
|
+
{ query: q }
|
|
629
|
+
);
|
|
547
630
|
}
|
|
548
631
|
/**
|
|
549
632
|
* Resolved navigation menu by handle (e.g. "main", "footer"), built in the
|
|
@@ -552,9 +635,13 @@ var CatalogModule = class {
|
|
|
552
635
|
* handle is unknown or inactive — callers fall back to their own source.
|
|
553
636
|
*/
|
|
554
637
|
async getMenu(handle, options) {
|
|
555
|
-
return this.client.request(
|
|
556
|
-
|
|
557
|
-
|
|
638
|
+
return this.client.request(
|
|
639
|
+
"GET",
|
|
640
|
+
`/catalog/menu/${encodeURIComponent(handle)}`,
|
|
641
|
+
{
|
|
642
|
+
query: { locale: _optionalChain([options, 'optionalAccess', _22 => _22.locale]) }
|
|
643
|
+
}
|
|
644
|
+
);
|
|
558
645
|
}
|
|
559
646
|
/** Get all labels */
|
|
560
647
|
async getLabels(locale) {
|
|
@@ -564,13 +651,20 @@ var CatalogModule = class {
|
|
|
564
651
|
}
|
|
565
652
|
/** Get featured products */
|
|
566
653
|
async getFeatured(options) {
|
|
567
|
-
return this.client.request(
|
|
568
|
-
|
|
569
|
-
|
|
654
|
+
return this.client.request(
|
|
655
|
+
"GET",
|
|
656
|
+
"/catalog/featured",
|
|
657
|
+
{
|
|
658
|
+
query: { locale: _optionalChain([options, 'optionalAccess', _23 => _23.locale]), currency: _optionalChain([options, 'optionalAccess', _24 => _24.currency]) }
|
|
659
|
+
}
|
|
660
|
+
);
|
|
570
661
|
}
|
|
571
662
|
/** Get available filter fields for dynamic filter UI */
|
|
572
663
|
async getFilters() {
|
|
573
|
-
return this.client.request(
|
|
664
|
+
return this.client.request(
|
|
665
|
+
"GET",
|
|
666
|
+
"/catalog/filters"
|
|
667
|
+
);
|
|
574
668
|
}
|
|
575
669
|
/**
|
|
576
670
|
* Facet groups + selection-aware counts for the current filter set (custom
|
|
@@ -592,14 +686,18 @@ var CatalogModule = class {
|
|
|
592
686
|
if (query.inStock !== void 0) q.inStock = query.inStock;
|
|
593
687
|
if (query.ratingMin !== void 0) q.ratingMin = query.ratingMin;
|
|
594
688
|
if (query.search) q.search = query.search;
|
|
595
|
-
if (query.customFields)
|
|
689
|
+
if (query.customFields)
|
|
690
|
+
q.customFields = JSON.stringify(query.customFields);
|
|
596
691
|
if (query.facets) q.facets = JSON.stringify(query.facets);
|
|
597
692
|
if (query.labels && query.labels.length > 0) q.labels = query.labels;
|
|
598
|
-
if (query.categories && query.categories.length > 0)
|
|
693
|
+
if (query.categories && query.categories.length > 0)
|
|
694
|
+
q.categories = query.categories;
|
|
599
695
|
if (query.excludeCategories && query.excludeCategories.length > 0)
|
|
600
696
|
q.excludeCategories = query.excludeCategories;
|
|
601
697
|
}
|
|
602
|
-
return this.client.request("GET", "/catalog/facets", {
|
|
698
|
+
return this.client.request("GET", "/catalog/facets", {
|
|
699
|
+
query: q
|
|
700
|
+
});
|
|
603
701
|
}
|
|
604
702
|
/** Search products */
|
|
605
703
|
async search(query, options) {
|
|
@@ -620,9 +718,13 @@ var CatalogModule = class {
|
|
|
620
718
|
* missing or inactive — callers should render nothing in that case.
|
|
621
719
|
*/
|
|
622
720
|
async getProductGroup(slug, options) {
|
|
623
|
-
return this.client.request(
|
|
624
|
-
|
|
625
|
-
|
|
721
|
+
return this.client.request(
|
|
722
|
+
"GET",
|
|
723
|
+
`/catalog/product-groups/${encodeURIComponent(slug)}`,
|
|
724
|
+
{
|
|
725
|
+
query: { locale: _optionalChain([options, 'optionalAccess', _25 => _25.locale]), currency: _optionalChain([options, 'optionalAccess', _26 => _26.currency]) }
|
|
726
|
+
}
|
|
727
|
+
);
|
|
626
728
|
}
|
|
627
729
|
/**
|
|
628
730
|
* Cross-sell / related / upsell products for a product. Returns three
|
|
@@ -648,11 +750,17 @@ var CatalogModule = class {
|
|
|
648
750
|
);
|
|
649
751
|
}
|
|
650
752
|
async getProductPromotions(productSlug) {
|
|
651
|
-
return this.client.request(
|
|
753
|
+
return this.client.request(
|
|
754
|
+
"GET",
|
|
755
|
+
`/catalog/products/${productSlug}/promotions`
|
|
756
|
+
);
|
|
652
757
|
}
|
|
653
758
|
/** Check a gift card code — returns validity and remaining balance */
|
|
654
759
|
async checkGiftCard(code) {
|
|
655
|
-
return this.client.request(
|
|
760
|
+
return this.client.request(
|
|
761
|
+
"GET",
|
|
762
|
+
`/catalog/gift-cards/${encodeURIComponent(code)}/check`
|
|
763
|
+
);
|
|
656
764
|
}
|
|
657
765
|
/**
|
|
658
766
|
* Buy a gift card (GAP-39): creates a cart-independent order for the chosen
|
|
@@ -660,13 +768,21 @@ var CatalogModule = class {
|
|
|
660
768
|
* code is generated and emailed to the recipient once the order is paid.
|
|
661
769
|
*/
|
|
662
770
|
async purchaseGiftCard(input) {
|
|
663
|
-
return this.client.request(
|
|
771
|
+
return this.client.request(
|
|
772
|
+
"POST",
|
|
773
|
+
"/gift-cards/purchase",
|
|
774
|
+
{ body: input }
|
|
775
|
+
);
|
|
664
776
|
}
|
|
665
777
|
/** List configured payment methods (filtered by currency). */
|
|
666
778
|
async listPaymentMethods(opts) {
|
|
667
779
|
const query = {};
|
|
668
780
|
if (_optionalChain([opts, 'optionalAccess', _29 => _29.currency])) query.currency = opts.currency;
|
|
669
|
-
return this.client.request(
|
|
781
|
+
return this.client.request(
|
|
782
|
+
"GET",
|
|
783
|
+
"/catalog/payment-methods",
|
|
784
|
+
{ query }
|
|
785
|
+
);
|
|
670
786
|
}
|
|
671
787
|
};
|
|
672
788
|
var AuthModule = class {
|
|
@@ -675,10 +791,14 @@ var AuthModule = class {
|
|
|
675
791
|
}
|
|
676
792
|
/** Register a new customer */
|
|
677
793
|
async register(input) {
|
|
678
|
-
const res = await this.client.request(
|
|
679
|
-
|
|
680
|
-
auth
|
|
681
|
-
|
|
794
|
+
const res = await this.client.request(
|
|
795
|
+
"POST",
|
|
796
|
+
"/auth/register",
|
|
797
|
+
{
|
|
798
|
+
body: input,
|
|
799
|
+
auth: false
|
|
800
|
+
}
|
|
801
|
+
);
|
|
682
802
|
if (res.error) return res;
|
|
683
803
|
if (res.data.accessToken && res.data.refreshToken) {
|
|
684
804
|
this.client.setTokens({
|
|
@@ -725,26 +845,38 @@ var AuthModule = class {
|
|
|
725
845
|
/** Logout (invalidate refresh token) */
|
|
726
846
|
async logout(refreshToken) {
|
|
727
847
|
const token = refreshToken || this.client.getRefreshToken();
|
|
728
|
-
const res = await this.client.request(
|
|
729
|
-
|
|
730
|
-
|
|
848
|
+
const res = await this.client.request(
|
|
849
|
+
"POST",
|
|
850
|
+
"/auth/logout",
|
|
851
|
+
{
|
|
852
|
+
body: { refreshToken: token }
|
|
853
|
+
}
|
|
854
|
+
);
|
|
731
855
|
this.client.clearTokens();
|
|
732
856
|
this.client.emit("auth:logout");
|
|
733
857
|
return res;
|
|
734
858
|
}
|
|
735
859
|
/** Request password reset email */
|
|
736
860
|
async forgotPassword(email) {
|
|
737
|
-
return this.client.request(
|
|
738
|
-
|
|
739
|
-
auth
|
|
740
|
-
|
|
861
|
+
return this.client.request(
|
|
862
|
+
"POST",
|
|
863
|
+
"/auth/forgot-password",
|
|
864
|
+
{
|
|
865
|
+
body: { email },
|
|
866
|
+
auth: false
|
|
867
|
+
}
|
|
868
|
+
);
|
|
741
869
|
}
|
|
742
870
|
/** Reset password with token */
|
|
743
871
|
async resetPassword(token, newPassword) {
|
|
744
|
-
return this.client.request(
|
|
745
|
-
|
|
746
|
-
auth
|
|
747
|
-
|
|
872
|
+
return this.client.request(
|
|
873
|
+
"POST",
|
|
874
|
+
"/auth/reset-password",
|
|
875
|
+
{
|
|
876
|
+
body: { token, newPassword },
|
|
877
|
+
auth: false
|
|
878
|
+
}
|
|
879
|
+
);
|
|
748
880
|
}
|
|
749
881
|
/** Verify email with token */
|
|
750
882
|
async verifyEmail(token) {
|
|
@@ -768,9 +900,13 @@ var CartModule = class {
|
|
|
768
900
|
}
|
|
769
901
|
/** Add item to cart */
|
|
770
902
|
async addItem(input) {
|
|
771
|
-
const res = await this.client.request(
|
|
772
|
-
|
|
773
|
-
|
|
903
|
+
const res = await this.client.request(
|
|
904
|
+
"POST",
|
|
905
|
+
"/cart/items",
|
|
906
|
+
{
|
|
907
|
+
body: { productId: input.productId, quantity: input.quantity }
|
|
908
|
+
}
|
|
909
|
+
);
|
|
774
910
|
if (res.error) return res;
|
|
775
911
|
if (res.data.newSessionToken) {
|
|
776
912
|
this.client.setCartSession(res.data.newSessionToken);
|
|
@@ -780,16 +916,23 @@ var CartModule = class {
|
|
|
780
916
|
}
|
|
781
917
|
/** Update item quantity */
|
|
782
918
|
async updateQuantity(itemId, quantity) {
|
|
783
|
-
const res = await this.client.request(
|
|
784
|
-
|
|
785
|
-
|
|
919
|
+
const res = await this.client.request(
|
|
920
|
+
"PATCH",
|
|
921
|
+
`/cart/items/${itemId}`,
|
|
922
|
+
{
|
|
923
|
+
body: { quantity }
|
|
924
|
+
}
|
|
925
|
+
);
|
|
786
926
|
if (res.error) return res;
|
|
787
927
|
this.client.emit("cart:updated", res.data);
|
|
788
928
|
return res;
|
|
789
929
|
}
|
|
790
930
|
/** Remove item from cart */
|
|
791
931
|
async removeItem(itemId) {
|
|
792
|
-
const res = await this.client.request(
|
|
932
|
+
const res = await this.client.request(
|
|
933
|
+
"DELETE",
|
|
934
|
+
`/cart/items/${itemId}`
|
|
935
|
+
);
|
|
793
936
|
if (res.error) return res;
|
|
794
937
|
this.client.emit("cart:updated", res.data);
|
|
795
938
|
return res;
|
|
@@ -812,7 +955,10 @@ var CartModule = class {
|
|
|
812
955
|
}
|
|
813
956
|
/** Remove a specific applied gift card from the cart by its code. */
|
|
814
957
|
async removeGiftCard(code) {
|
|
815
|
-
const res = await this.client.request(
|
|
958
|
+
const res = await this.client.request(
|
|
959
|
+
"DELETE",
|
|
960
|
+
`/cart/gift-card/${encodeURIComponent(code)}`
|
|
961
|
+
);
|
|
816
962
|
if (res.error) return res;
|
|
817
963
|
this.client.emit("cart:updated", res.data);
|
|
818
964
|
return res;
|
|
@@ -835,7 +981,9 @@ var CartModule = class {
|
|
|
835
981
|
* the bundle's `maxQuantity` if set.
|
|
836
982
|
*/
|
|
837
983
|
async addBundle(identifier, quantity = 1) {
|
|
838
|
-
const body = {
|
|
984
|
+
const body = {
|
|
985
|
+
quantity
|
|
986
|
+
};
|
|
839
987
|
if (typeof identifier === "string") {
|
|
840
988
|
body.bundleId = identifier;
|
|
841
989
|
} else if ("id" in identifier) {
|
|
@@ -843,23 +991,32 @@ var CartModule = class {
|
|
|
843
991
|
} else {
|
|
844
992
|
body.bundleSlug = identifier.slug;
|
|
845
993
|
}
|
|
846
|
-
const res = await this.client.request("POST", "/cart/bundles", {
|
|
994
|
+
const res = await this.client.request("POST", "/cart/bundles", {
|
|
995
|
+
body
|
|
996
|
+
});
|
|
847
997
|
if (res.error) return res;
|
|
848
998
|
this.client.emit("cart:updated", res.data);
|
|
849
999
|
return res;
|
|
850
1000
|
}
|
|
851
1001
|
/** Update quantity of a bundle already in the cart */
|
|
852
1002
|
async updateBundleQuantity(bundleId, quantity) {
|
|
853
|
-
const res = await this.client.request(
|
|
854
|
-
|
|
855
|
-
|
|
1003
|
+
const res = await this.client.request(
|
|
1004
|
+
"PATCH",
|
|
1005
|
+
`/cart/bundles/${bundleId}`,
|
|
1006
|
+
{
|
|
1007
|
+
body: { quantity }
|
|
1008
|
+
}
|
|
1009
|
+
);
|
|
856
1010
|
if (res.error) return res;
|
|
857
1011
|
this.client.emit("cart:updated", res.data);
|
|
858
1012
|
return res;
|
|
859
1013
|
}
|
|
860
1014
|
/** Remove a bundle from the cart */
|
|
861
1015
|
async removeBundle(bundleId) {
|
|
862
|
-
const res = await this.client.request(
|
|
1016
|
+
const res = await this.client.request(
|
|
1017
|
+
"DELETE",
|
|
1018
|
+
`/cart/bundles/${bundleId}`
|
|
1019
|
+
);
|
|
863
1020
|
if (res.error) return res;
|
|
864
1021
|
this.client.emit("cart:updated", res.data);
|
|
865
1022
|
return res;
|
|
@@ -910,9 +1067,13 @@ var OrdersModule = class {
|
|
|
910
1067
|
}
|
|
911
1068
|
/** List customer orders (requires auth) */
|
|
912
1069
|
async list(options) {
|
|
913
|
-
return this.client.request(
|
|
914
|
-
|
|
915
|
-
|
|
1070
|
+
return this.client.request(
|
|
1071
|
+
"GET",
|
|
1072
|
+
"/orders",
|
|
1073
|
+
{
|
|
1074
|
+
query: { page: _optionalChain([options, 'optionalAccess', _30 => _30.page]), limit: _optionalChain([options, 'optionalAccess', _31 => _31.limit]) }
|
|
1075
|
+
}
|
|
1076
|
+
);
|
|
916
1077
|
}
|
|
917
1078
|
/** Get order detail (requires auth) */
|
|
918
1079
|
async get(orderNumber) {
|
|
@@ -920,7 +1081,10 @@ var OrdersModule = class {
|
|
|
920
1081
|
}
|
|
921
1082
|
/** Cancel a PENDING order (requires auth) */
|
|
922
1083
|
async cancel(orderNumber) {
|
|
923
|
-
return this.client.request(
|
|
1084
|
+
return this.client.request(
|
|
1085
|
+
"POST",
|
|
1086
|
+
`/orders/${orderNumber}/cancel`
|
|
1087
|
+
);
|
|
924
1088
|
}
|
|
925
1089
|
/**
|
|
926
1090
|
* Track an order by tracking token (no login, only API key). Returns a
|
|
@@ -929,7 +1093,11 @@ var OrdersModule = class {
|
|
|
929
1093
|
* and e-mails so it must not expose full personal data.
|
|
930
1094
|
*/
|
|
931
1095
|
async track(trackingToken) {
|
|
932
|
-
return this.client.request(
|
|
1096
|
+
return this.client.request(
|
|
1097
|
+
"GET",
|
|
1098
|
+
`/orders/track/${trackingToken}`,
|
|
1099
|
+
{ auth: false }
|
|
1100
|
+
);
|
|
933
1101
|
}
|
|
934
1102
|
/**
|
|
935
1103
|
* Step 1 of guest order-access: request a 6-digit code e-mailed to the
|
|
@@ -938,10 +1106,14 @@ var OrdersModule = class {
|
|
|
938
1106
|
* enumerated. No login, only API key.
|
|
939
1107
|
*/
|
|
940
1108
|
async requestAccessCode(orderNumber, email) {
|
|
941
|
-
return this.client.request(
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
1109
|
+
return this.client.request(
|
|
1110
|
+
"POST",
|
|
1111
|
+
"/orders/access/request",
|
|
1112
|
+
{
|
|
1113
|
+
auth: false,
|
|
1114
|
+
body: { orderNumber, email }
|
|
1115
|
+
}
|
|
1116
|
+
);
|
|
945
1117
|
}
|
|
946
1118
|
/**
|
|
947
1119
|
* Step 2 of guest order-access: verify the e-mailed code. On success returns
|
|
@@ -950,10 +1122,14 @@ var OrdersModule = class {
|
|
|
950
1122
|
* code. No login, only API key.
|
|
951
1123
|
*/
|
|
952
1124
|
async verifyAccessCode(orderNumber, email, code) {
|
|
953
|
-
return this.client.request(
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
1125
|
+
return this.client.request(
|
|
1126
|
+
"POST",
|
|
1127
|
+
"/orders/access/verify",
|
|
1128
|
+
{
|
|
1129
|
+
auth: false,
|
|
1130
|
+
body: { orderNumber, email, code }
|
|
1131
|
+
}
|
|
1132
|
+
);
|
|
957
1133
|
}
|
|
958
1134
|
/**
|
|
959
1135
|
* Re-fetch a guest order's full detail using the `accessToken` returned by
|
|
@@ -972,10 +1148,14 @@ var OrdersModule = class {
|
|
|
972
1148
|
* {@link verifyAccessCode}. Scoped to that one order.
|
|
973
1149
|
*/
|
|
974
1150
|
async getAccessDownloadUrl(accessToken, downloadId) {
|
|
975
|
-
return this.client.request(
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1151
|
+
return this.client.request(
|
|
1152
|
+
"POST",
|
|
1153
|
+
`/orders/access/downloads/${downloadId}/url`,
|
|
1154
|
+
{
|
|
1155
|
+
auth: false,
|
|
1156
|
+
headers: { "X-Order-Access": accessToken }
|
|
1157
|
+
}
|
|
1158
|
+
);
|
|
979
1159
|
}
|
|
980
1160
|
};
|
|
981
1161
|
var CustomerModule = class {
|
|
@@ -988,7 +1168,9 @@ var CustomerModule = class {
|
|
|
988
1168
|
}
|
|
989
1169
|
/** Update customer profile */
|
|
990
1170
|
async updateProfile(data) {
|
|
991
|
-
return this.client.request("PATCH", "/customer/profile", {
|
|
1171
|
+
return this.client.request("PATCH", "/customer/profile", {
|
|
1172
|
+
body: data
|
|
1173
|
+
});
|
|
992
1174
|
}
|
|
993
1175
|
/** Change password */
|
|
994
1176
|
async changePassword(currentPassword, newPassword) {
|
|
@@ -998,19 +1180,31 @@ var CustomerModule = class {
|
|
|
998
1180
|
}
|
|
999
1181
|
/** List addresses */
|
|
1000
1182
|
async getAddresses() {
|
|
1001
|
-
return this.client.request(
|
|
1183
|
+
return this.client.request(
|
|
1184
|
+
"GET",
|
|
1185
|
+
"/customer/addresses"
|
|
1186
|
+
);
|
|
1002
1187
|
}
|
|
1003
1188
|
/** Create address */
|
|
1004
1189
|
async createAddress(address) {
|
|
1005
|
-
return this.client.request("POST", "/customer/addresses", {
|
|
1190
|
+
return this.client.request("POST", "/customer/addresses", {
|
|
1191
|
+
body: address
|
|
1192
|
+
});
|
|
1006
1193
|
}
|
|
1007
1194
|
/** Update address */
|
|
1008
1195
|
async updateAddress(addressId, data) {
|
|
1009
|
-
return this.client.request(
|
|
1196
|
+
return this.client.request(
|
|
1197
|
+
"PATCH",
|
|
1198
|
+
`/customer/addresses/${addressId}`,
|
|
1199
|
+
{ body: data }
|
|
1200
|
+
);
|
|
1010
1201
|
}
|
|
1011
1202
|
/** Delete address */
|
|
1012
1203
|
async deleteAddress(addressId) {
|
|
1013
|
-
return this.client.request(
|
|
1204
|
+
return this.client.request(
|
|
1205
|
+
"DELETE",
|
|
1206
|
+
`/customer/addresses/${addressId}`
|
|
1207
|
+
);
|
|
1014
1208
|
}
|
|
1015
1209
|
/**
|
|
1016
1210
|
* Loyalty program summary for the logged-in customer (points balance +
|
|
@@ -1026,7 +1220,10 @@ var CustomerModule = class {
|
|
|
1026
1220
|
* expiry). Requires an authenticated customer session.
|
|
1027
1221
|
*/
|
|
1028
1222
|
async getDownloads() {
|
|
1029
|
-
return this.client.request(
|
|
1223
|
+
return this.client.request(
|
|
1224
|
+
"GET",
|
|
1225
|
+
"/customer/downloads"
|
|
1226
|
+
);
|
|
1030
1227
|
}
|
|
1031
1228
|
/**
|
|
1032
1229
|
* Mint a short-lived signed URL for one download grant. Counts against the
|
|
@@ -1034,7 +1231,10 @@ var CustomerModule = class {
|
|
|
1034
1231
|
* server-side. Requires an authenticated customer session.
|
|
1035
1232
|
*/
|
|
1036
1233
|
async getDownloadUrl(downloadId) {
|
|
1037
|
-
return this.client.request(
|
|
1234
|
+
return this.client.request(
|
|
1235
|
+
"POST",
|
|
1236
|
+
`/customer/downloads/${downloadId}/url`
|
|
1237
|
+
);
|
|
1038
1238
|
}
|
|
1039
1239
|
/**
|
|
1040
1240
|
* Online courses (LMS): list the logged-in customer's enrolled courses
|
|
@@ -1042,7 +1242,10 @@ var CustomerModule = class {
|
|
|
1042
1242
|
* course product is paid. Requires an authenticated customer session.
|
|
1043
1243
|
*/
|
|
1044
1244
|
async getCourses() {
|
|
1045
|
-
return this.client.request(
|
|
1245
|
+
return this.client.request(
|
|
1246
|
+
"GET",
|
|
1247
|
+
"/customer/courses"
|
|
1248
|
+
);
|
|
1046
1249
|
}
|
|
1047
1250
|
/**
|
|
1048
1251
|
* Course player payload: modules and lessons in order, with per-lesson
|
|
@@ -1050,7 +1253,10 @@ var CustomerModule = class {
|
|
|
1050
1253
|
* withholds `videoUrl`/`content`/`attachments` until `unlockAt`.
|
|
1051
1254
|
*/
|
|
1052
1255
|
async getCourse(courseId) {
|
|
1053
|
-
return this.client.request(
|
|
1256
|
+
return this.client.request(
|
|
1257
|
+
"GET",
|
|
1258
|
+
`/customer/courses/${courseId}`
|
|
1259
|
+
);
|
|
1054
1260
|
}
|
|
1055
1261
|
/** Mark an unlocked lesson as completed (idempotent). */
|
|
1056
1262
|
async completeLesson(courseId, lessonId) {
|
|
@@ -1059,6 +1265,140 @@ var CustomerModule = class {
|
|
|
1059
1265
|
`/customer/courses/${courseId}/lessons/${lessonId}/complete`
|
|
1060
1266
|
);
|
|
1061
1267
|
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Quiz for an unlocked lesson. Correct answers are never included — scoring
|
|
1270
|
+
* happens server-side in `submitLessonQuiz`. Locked lessons return 403.
|
|
1271
|
+
*/
|
|
1272
|
+
async getLessonQuiz(courseId, lessonId) {
|
|
1273
|
+
return this.client.request(
|
|
1274
|
+
"GET",
|
|
1275
|
+
`/customer/courses/${courseId}/lessons/${lessonId}/quiz`
|
|
1276
|
+
);
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Submit quiz answers: returns the score, reveals correct answers and, when
|
|
1280
|
+
* the score reaches `passPercent` (70 %), marks the lesson completed
|
|
1281
|
+
* automatically.
|
|
1282
|
+
*/
|
|
1283
|
+
async submitLessonQuiz(courseId, lessonId, answers) {
|
|
1284
|
+
return this.client.request(
|
|
1285
|
+
"POST",
|
|
1286
|
+
`/customer/courses/${courseId}/lessons/${lessonId}/quiz/submit`,
|
|
1287
|
+
{ body: { answers } }
|
|
1288
|
+
);
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Completion certificates of the logged-in customer. Each carries a public
|
|
1292
|
+
* verification code for sharing (LinkedIn, CV).
|
|
1293
|
+
*/
|
|
1294
|
+
async getCourseCertificates() {
|
|
1295
|
+
return this.client.request(
|
|
1296
|
+
"GET",
|
|
1297
|
+
"/customer/courses/certificates"
|
|
1298
|
+
);
|
|
1299
|
+
}
|
|
1300
|
+
/**
|
|
1301
|
+
* AI tutor "Ask about this lesson": the student's private thread for one
|
|
1302
|
+
* lesson (oldest first). `enabled: false` = the merchant turned the tutor
|
|
1303
|
+
* off — hide the widget. Locked lessons return 403.
|
|
1304
|
+
*/
|
|
1305
|
+
async getLessonTutorThread(courseId, lessonId) {
|
|
1306
|
+
return this.client.request(
|
|
1307
|
+
"GET",
|
|
1308
|
+
`/customer/courses/${courseId}/lessons/${lessonId}/tutor`
|
|
1309
|
+
);
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Ask the AI tutor a question about the lesson. The answer sticks to the
|
|
1313
|
+
* lesson topic and comes back in the language of the question (Czech by
|
|
1314
|
+
* default). Rate limited (20/min); 403 on locked lessons or when the
|
|
1315
|
+
* merchant disabled the tutor.
|
|
1316
|
+
*/
|
|
1317
|
+
async askLessonTutor(courseId, lessonId, question) {
|
|
1318
|
+
return this.client.request(
|
|
1319
|
+
"POST",
|
|
1320
|
+
`/customer/courses/${courseId}/lessons/${lessonId}/tutor`,
|
|
1321
|
+
{ body: { question } }
|
|
1322
|
+
);
|
|
1323
|
+
}
|
|
1324
|
+
/**
|
|
1325
|
+
* Lesson discussion: paginated top-level comments (newest first) with one
|
|
1326
|
+
* level of replies. Only enrolled customers with the lesson unlocked; 403
|
|
1327
|
+
* when the merchant disabled the discussion.
|
|
1328
|
+
*/
|
|
1329
|
+
async getLessonComments(courseId, lessonId, page = 1) {
|
|
1330
|
+
return this.client.request(
|
|
1331
|
+
"GET",
|
|
1332
|
+
`/customer/courses/${courseId}/lessons/${lessonId}/comments`,
|
|
1333
|
+
{ query: { page: String(page) } }
|
|
1334
|
+
);
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Post a comment under the lesson, or a reply when `parentId` points to a
|
|
1338
|
+
* top-level comment (replies go one level deep only). Max 5000 characters.
|
|
1339
|
+
*/
|
|
1340
|
+
async postLessonComment(courseId, lessonId, body, parentId) {
|
|
1341
|
+
return this.client.request(
|
|
1342
|
+
"POST",
|
|
1343
|
+
`/customer/courses/${courseId}/lessons/${lessonId}/comments`,
|
|
1344
|
+
{ body: { body, ...parentId ? { parentId } : {} } }
|
|
1345
|
+
);
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Delete the customer's OWN comment (including its replies). Someone
|
|
1349
|
+
* else's comment returns 404.
|
|
1350
|
+
*/
|
|
1351
|
+
async deleteLessonComment(courseId, lessonId, commentId) {
|
|
1352
|
+
return this.client.request(
|
|
1353
|
+
"DELETE",
|
|
1354
|
+
`/customer/courses/${courseId}/lessons/${lessonId}/comments/${commentId}`
|
|
1355
|
+
);
|
|
1356
|
+
}
|
|
1357
|
+
/**
|
|
1358
|
+
* The student's private note for one lesson. `body` is an empty string
|
|
1359
|
+
* when no note exists yet. Visible only to the logged-in student.
|
|
1360
|
+
*/
|
|
1361
|
+
async getLessonNote(courseId, lessonId) {
|
|
1362
|
+
return this.client.request(
|
|
1363
|
+
"GET",
|
|
1364
|
+
`/customer/courses/${courseId}/lessons/${lessonId}/note`
|
|
1365
|
+
);
|
|
1366
|
+
}
|
|
1367
|
+
/**
|
|
1368
|
+
* Save (upsert) the student's private lesson note. Autosave-friendly; an
|
|
1369
|
+
* empty string clears the note. Max 20 000 characters.
|
|
1370
|
+
*/
|
|
1371
|
+
async saveLessonNote(courseId, lessonId, body) {
|
|
1372
|
+
return this.client.request(
|
|
1373
|
+
"PUT",
|
|
1374
|
+
`/customer/courses/${courseId}/lessons/${lessonId}/note`,
|
|
1375
|
+
{ body: { body } }
|
|
1376
|
+
);
|
|
1377
|
+
}
|
|
1378
|
+
};
|
|
1379
|
+
var CourseCertificatesModule = class {
|
|
1380
|
+
constructor(client) {
|
|
1381
|
+
this.client = client;
|
|
1382
|
+
}
|
|
1383
|
+
/**
|
|
1384
|
+
* Publicly verify a certificate code (no customer login needed) — build a
|
|
1385
|
+
* `/certifikat/{code}` page with this. Unknown codes return a 404 error.
|
|
1386
|
+
*/
|
|
1387
|
+
async verify(code) {
|
|
1388
|
+
return this.client.request(
|
|
1389
|
+
"GET",
|
|
1390
|
+
`/course-certificates/${encodeURIComponent(code)}`
|
|
1391
|
+
);
|
|
1392
|
+
}
|
|
1393
|
+
/**
|
|
1394
|
+
* Download the certificate as a branded PDF (A5 landscape). Returns a Blob;
|
|
1395
|
+
* trigger a browser download via `URL.createObjectURL(blob)`.
|
|
1396
|
+
*/
|
|
1397
|
+
async downloadPdf(code) {
|
|
1398
|
+
return this.client.requestBlob(
|
|
1399
|
+
`/course-certificates/${encodeURIComponent(code)}/pdf`
|
|
1400
|
+
);
|
|
1401
|
+
}
|
|
1062
1402
|
};
|
|
1063
1403
|
var PagesModule = class {
|
|
1064
1404
|
constructor(client) {
|
|
@@ -1066,11 +1406,15 @@ var PagesModule = class {
|
|
|
1066
1406
|
}
|
|
1067
1407
|
/** List CMS pages */
|
|
1068
1408
|
async list(locale) {
|
|
1069
|
-
return this.client.request("GET", "/pages", {
|
|
1409
|
+
return this.client.request("GET", "/pages", {
|
|
1410
|
+
query: { locale }
|
|
1411
|
+
});
|
|
1070
1412
|
}
|
|
1071
1413
|
/** Get page by slug */
|
|
1072
1414
|
async get(slug, locale) {
|
|
1073
|
-
return this.client.request("GET", `/pages/${slug}`, {
|
|
1415
|
+
return this.client.request("GET", `/pages/${slug}`, {
|
|
1416
|
+
query: { locale }
|
|
1417
|
+
});
|
|
1074
1418
|
}
|
|
1075
1419
|
};
|
|
1076
1420
|
var WishlistModule = class {
|
|
@@ -1078,16 +1422,29 @@ var WishlistModule = class {
|
|
|
1078
1422
|
this.client = client;
|
|
1079
1423
|
}
|
|
1080
1424
|
async get() {
|
|
1081
|
-
return this.client.request(
|
|
1425
|
+
return this.client.request(
|
|
1426
|
+
"GET",
|
|
1427
|
+
"/customer/wishlist"
|
|
1428
|
+
);
|
|
1082
1429
|
}
|
|
1083
1430
|
async add(productId) {
|
|
1084
|
-
return this.client.request(
|
|
1431
|
+
return this.client.request(
|
|
1432
|
+
"POST",
|
|
1433
|
+
"/customer/wishlist",
|
|
1434
|
+
{ body: { productId } }
|
|
1435
|
+
);
|
|
1085
1436
|
}
|
|
1086
1437
|
async remove(productId) {
|
|
1087
|
-
return this.client.request(
|
|
1438
|
+
return this.client.request(
|
|
1439
|
+
"DELETE",
|
|
1440
|
+
`/customer/wishlist/${productId}`
|
|
1441
|
+
);
|
|
1088
1442
|
}
|
|
1089
1443
|
async isInWishlist(productId) {
|
|
1090
|
-
return this.client.request(
|
|
1444
|
+
return this.client.request(
|
|
1445
|
+
"GET",
|
|
1446
|
+
`/customer/wishlist/${productId}/check`
|
|
1447
|
+
);
|
|
1091
1448
|
}
|
|
1092
1449
|
};
|
|
1093
1450
|
var SubscriptionsModule = class {
|
|
@@ -1100,7 +1457,10 @@ var SubscriptionsModule = class {
|
|
|
1100
1457
|
* session. Subscriptions are created by the merchant in v1.
|
|
1101
1458
|
*/
|
|
1102
1459
|
async list() {
|
|
1103
|
-
return this.client.request(
|
|
1460
|
+
return this.client.request(
|
|
1461
|
+
"GET",
|
|
1462
|
+
"/customer/subscriptions"
|
|
1463
|
+
);
|
|
1104
1464
|
}
|
|
1105
1465
|
/** Pause an active subscription (no orders are generated while paused). */
|
|
1106
1466
|
async pause(subscriptionId) {
|
|
@@ -1129,15 +1489,25 @@ var ReviewsModule = class {
|
|
|
1129
1489
|
this.client = client;
|
|
1130
1490
|
}
|
|
1131
1491
|
async getProductReviews(productId, page = 1, limit = 20) {
|
|
1132
|
-
return this.client.request(
|
|
1133
|
-
|
|
1134
|
-
|
|
1492
|
+
return this.client.request(
|
|
1493
|
+
"GET",
|
|
1494
|
+
`/catalog/products/${productId}/reviews`,
|
|
1495
|
+
{
|
|
1496
|
+
query: { page: String(page), limit: String(limit) }
|
|
1497
|
+
}
|
|
1498
|
+
);
|
|
1135
1499
|
}
|
|
1136
1500
|
async submit(input) {
|
|
1137
|
-
return this.client.request("POST", "/catalog/reviews", {
|
|
1501
|
+
return this.client.request("POST", "/catalog/reviews", {
|
|
1502
|
+
body: input
|
|
1503
|
+
});
|
|
1138
1504
|
}
|
|
1139
1505
|
async voteHelpful(reviewId, helpful) {
|
|
1140
|
-
return this.client.request(
|
|
1506
|
+
return this.client.request(
|
|
1507
|
+
"POST",
|
|
1508
|
+
`/catalog/reviews/${reviewId}/vote`,
|
|
1509
|
+
{ body: { helpful } }
|
|
1510
|
+
);
|
|
1141
1511
|
}
|
|
1142
1512
|
};
|
|
1143
1513
|
var ReturnsModule = class {
|
|
@@ -1150,16 +1520,26 @@ var ReturnsModule = class {
|
|
|
1150
1520
|
* quantities. POST so the email never appears in a URL.
|
|
1151
1521
|
*/
|
|
1152
1522
|
async lookupOrder(orderNumber, email) {
|
|
1153
|
-
return this.client.request(
|
|
1154
|
-
|
|
1155
|
-
|
|
1523
|
+
return this.client.request(
|
|
1524
|
+
"POST",
|
|
1525
|
+
"/returns/lookup-order",
|
|
1526
|
+
{
|
|
1527
|
+
body: { orderNumber, email }
|
|
1528
|
+
}
|
|
1529
|
+
);
|
|
1156
1530
|
}
|
|
1157
1531
|
async submit(input) {
|
|
1158
|
-
return this.client.request("POST", "/returns", {
|
|
1532
|
+
return this.client.request("POST", "/returns", {
|
|
1533
|
+
body: input
|
|
1534
|
+
});
|
|
1159
1535
|
}
|
|
1160
1536
|
/** Email is the ownership gate; POST so it never lands in a URL / log. */
|
|
1161
1537
|
async getStatus(returnId, email) {
|
|
1162
|
-
return this.client.request(
|
|
1538
|
+
return this.client.request(
|
|
1539
|
+
"POST",
|
|
1540
|
+
`/returns/${returnId}/status`,
|
|
1541
|
+
{ body: { email } }
|
|
1542
|
+
);
|
|
1163
1543
|
}
|
|
1164
1544
|
};
|
|
1165
1545
|
var ConsentModule = class {
|
|
@@ -1167,24 +1547,35 @@ var ConsentModule = class {
|
|
|
1167
1547
|
this.client = client;
|
|
1168
1548
|
}
|
|
1169
1549
|
async record(input) {
|
|
1170
|
-
return this.client.request("POST", "/consent", {
|
|
1550
|
+
return this.client.request("POST", "/consent", {
|
|
1551
|
+
body: input,
|
|
1552
|
+
auth: false
|
|
1553
|
+
});
|
|
1171
1554
|
}
|
|
1172
1555
|
async get(visitorId) {
|
|
1173
|
-
const result = await this.client.request(
|
|
1174
|
-
"GET",
|
|
1175
|
-
`/consent/${visitorId}/status`,
|
|
1176
|
-
{ auth: false }
|
|
1177
|
-
);
|
|
1556
|
+
const result = await this.client.request("GET", `/consent/${visitorId}/status`, { auth: false });
|
|
1178
1557
|
if (result.error && result.error.status === 404) {
|
|
1179
|
-
const legacy = await this.client.request(
|
|
1180
|
-
|
|
1558
|
+
const legacy = await this.client.request(
|
|
1559
|
+
"GET",
|
|
1560
|
+
`/consent/${visitorId}`,
|
|
1561
|
+
{ auth: false }
|
|
1562
|
+
);
|
|
1563
|
+
if (legacy.error && legacy.error.status === 404)
|
|
1564
|
+
return { data: null, error: null };
|
|
1181
1565
|
return legacy;
|
|
1182
1566
|
}
|
|
1183
1567
|
if (result.error) return { data: null, error: result.error };
|
|
1184
|
-
return {
|
|
1568
|
+
return {
|
|
1569
|
+
data: _optionalChain([result, 'access', _32 => _32.data, 'optionalAccess', _33 => _33.consented]) ? result.data.consent : null,
|
|
1570
|
+
error: null
|
|
1571
|
+
};
|
|
1185
1572
|
}
|
|
1186
1573
|
async revoke(visitorId) {
|
|
1187
|
-
return this.client.request(
|
|
1574
|
+
return this.client.request(
|
|
1575
|
+
"DELETE",
|
|
1576
|
+
`/consent/${visitorId}`,
|
|
1577
|
+
{ auth: false }
|
|
1578
|
+
);
|
|
1188
1579
|
}
|
|
1189
1580
|
};
|
|
1190
1581
|
var QuotesModule = class {
|
|
@@ -1192,15 +1583,25 @@ var QuotesModule = class {
|
|
|
1192
1583
|
this.client = client;
|
|
1193
1584
|
}
|
|
1194
1585
|
async submit(input) {
|
|
1195
|
-
return this.client.request("POST", "/catalog/quote-request", {
|
|
1586
|
+
return this.client.request("POST", "/catalog/quote-request", {
|
|
1587
|
+
body: input
|
|
1588
|
+
});
|
|
1196
1589
|
}
|
|
1197
1590
|
async accept(quoteId, email) {
|
|
1198
|
-
return this.client.request(
|
|
1591
|
+
return this.client.request(
|
|
1592
|
+
"POST",
|
|
1593
|
+
`/quotes/${quoteId}/accept`,
|
|
1594
|
+
{ body: { email } }
|
|
1595
|
+
);
|
|
1199
1596
|
}
|
|
1200
1597
|
/** Email is the ownership gate — quotes carry contact PII and negotiated
|
|
1201
1598
|
* prices, so the id alone is never enough. POST keeps it out of URLs. */
|
|
1202
1599
|
async getStatus(quoteId, email) {
|
|
1203
|
-
return this.client.request(
|
|
1600
|
+
return this.client.request(
|
|
1601
|
+
"POST",
|
|
1602
|
+
`/quotes/${quoteId}/status`,
|
|
1603
|
+
{ body: { email } }
|
|
1604
|
+
);
|
|
1204
1605
|
}
|
|
1205
1606
|
/**
|
|
1206
1607
|
* The logged-in customer's own quote requests ("Moje poptávky", GAP-18).
|
|
@@ -1208,7 +1609,10 @@ var QuotesModule = class {
|
|
|
1208
1609
|
* + verified email), never a payload. Newest first.
|
|
1209
1610
|
*/
|
|
1210
1611
|
async listMine() {
|
|
1211
|
-
return this.client.request(
|
|
1612
|
+
return this.client.request(
|
|
1613
|
+
"GET",
|
|
1614
|
+
"/customer/quotes"
|
|
1615
|
+
);
|
|
1212
1616
|
}
|
|
1213
1617
|
};
|
|
1214
1618
|
var AddressModule = class {
|
|
@@ -1218,15 +1622,23 @@ var AddressModule = class {
|
|
|
1218
1622
|
/** Search for address suggestions (debounce on your side, or use the React hook) */
|
|
1219
1623
|
async autocomplete(query, country) {
|
|
1220
1624
|
if (!query || query.length < 2) return ok({ suggestions: [] });
|
|
1221
|
-
return this.client.request(
|
|
1222
|
-
|
|
1223
|
-
|
|
1625
|
+
return this.client.request(
|
|
1626
|
+
"GET",
|
|
1627
|
+
"/addresses/autocomplete",
|
|
1628
|
+
{
|
|
1629
|
+
query: { q: query, country }
|
|
1630
|
+
}
|
|
1631
|
+
);
|
|
1224
1632
|
}
|
|
1225
1633
|
/** Get full structured address from a suggestion's placeId */
|
|
1226
1634
|
async getDetail(placeId) {
|
|
1227
|
-
return this.client.request(
|
|
1228
|
-
|
|
1229
|
-
|
|
1635
|
+
return this.client.request(
|
|
1636
|
+
"GET",
|
|
1637
|
+
"/addresses/place-detail",
|
|
1638
|
+
{
|
|
1639
|
+
query: { placeId }
|
|
1640
|
+
}
|
|
1641
|
+
);
|
|
1230
1642
|
}
|
|
1231
1643
|
};
|
|
1232
1644
|
var ShippingModule = class {
|
|
@@ -1244,7 +1656,8 @@ var ShippingModule = class {
|
|
|
1244
1656
|
if (_optionalChain([opts, 'optionalAccess', _34 => _34.currency])) query.currency = opts.currency;
|
|
1245
1657
|
if (_optionalChain([opts, 'optionalAccess', _35 => _35.country])) query.country = opts.country;
|
|
1246
1658
|
if (_optionalChain([opts, 'optionalAccess', _36 => _36.cartTotal]) != null) query.cartTotal = String(opts.cartTotal);
|
|
1247
|
-
if (_optionalChain([opts, 'optionalAccess', _37 => _37.cartWeightKg]) != null)
|
|
1659
|
+
if (_optionalChain([opts, 'optionalAccess', _37 => _37.cartWeightKg]) != null)
|
|
1660
|
+
query.cartWeightKg = String(opts.cartWeightKg);
|
|
1248
1661
|
return this.client.request(
|
|
1249
1662
|
"GET",
|
|
1250
1663
|
"/catalog/shipping-methods",
|
|
@@ -1294,16 +1707,24 @@ var NewsletterModule = class {
|
|
|
1294
1707
|
this.client = client;
|
|
1295
1708
|
}
|
|
1296
1709
|
async subscribe(input) {
|
|
1297
|
-
return this.client.request(
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1710
|
+
return this.client.request(
|
|
1711
|
+
"POST",
|
|
1712
|
+
"/newsletter/subscribe",
|
|
1713
|
+
{
|
|
1714
|
+
body: input,
|
|
1715
|
+
auth: false
|
|
1716
|
+
}
|
|
1717
|
+
);
|
|
1301
1718
|
}
|
|
1302
1719
|
async unsubscribe(email) {
|
|
1303
|
-
return this.client.request(
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1720
|
+
return this.client.request(
|
|
1721
|
+
"POST",
|
|
1722
|
+
"/newsletter/unsubscribe",
|
|
1723
|
+
{
|
|
1724
|
+
body: { email },
|
|
1725
|
+
auth: false
|
|
1726
|
+
}
|
|
1727
|
+
);
|
|
1307
1728
|
}
|
|
1308
1729
|
};
|
|
1309
1730
|
|