@misiki/gocommerce-connector 0.22.0 → 0.23.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.
@@ -3700,6 +3700,50 @@ function withAmounts(v) {
3700
3700
  }
3701
3701
  var variantService = new VariantService();
3702
3702
 
3703
+ // src/services/whatsapp-service.ts
3704
+ var WhatsappService = class extends BaseService {
3705
+ /**
3706
+ * Whether to show the boxes. Never throws: an engine without the module, or
3707
+ * one that fails, answers both off, because checkout must not depend on it.
3708
+ */
3709
+ async consentOffer() {
3710
+ try {
3711
+ const d = await this.data("/x/notify-whatsapp/consent");
3712
+ const enabled = d?.enabled === true;
3713
+ return { enabled, marketing: enabled && d?.marketing === true };
3714
+ } catch {
3715
+ return { enabled: false, marketing: false };
3716
+ }
3717
+ }
3718
+ /**
3719
+ * Records both answers for the phone as typed, against the bag (with
3720
+ * `marketing`, the engine keeps the phone on it for basket reminders). Throws
3721
+ * the engine's 400 (`validation_failed`) when the phone is not a WhatsApp
3722
+ * number for the store's country.
3723
+ */
3724
+ async setConsent({
3725
+ cartId,
3726
+ phone,
3727
+ orderUpdates,
3728
+ marketing
3729
+ }) {
3730
+ const d = await this.data(
3731
+ "/x/notify-whatsapp/consent",
3732
+ {
3733
+ method: "PUT",
3734
+ body: {
3735
+ cart_id: cartId || storedCartId() || "",
3736
+ phone: String(phone ?? "").trim(),
3737
+ order_updates: orderUpdates === true,
3738
+ marketing: marketing === true
3739
+ }
3740
+ }
3741
+ );
3742
+ return { phone: d.phone, orderUpdates: d.order_updates, marketing: d.marketing };
3743
+ }
3744
+ };
3745
+ var whatsappService = new WhatsappService();
3746
+
3703
3747
  // src/services/b2b-service.ts
3704
3748
  var B2bService = class extends BaseService {
3705
3749
  // ------------------------------------------------------------ company
@@ -4020,6 +4064,7 @@ exports.VarniCustomDesignService = VarniCustomDesignService;
4020
4064
  exports.VarniCustomProductService = VarniCustomProductService;
4021
4065
  exports.VendorService = VendorService;
4022
4066
  exports.WarrantyService = WarrantyService;
4067
+ exports.WhatsappService = WhatsappService;
4023
4068
  exports.WishlistService = WishlistService;
4024
4069
  exports.addressService = addressService;
4025
4070
  exports.authService = authService;
@@ -4082,6 +4127,7 @@ exports.varniCustomDesignService = varniCustomDesignService;
4082
4127
  exports.varniCustomProductService = varniCustomProductService;
4083
4128
  exports.vendorService = vendorService;
4084
4129
  exports.warrantyService = warrantyService;
4130
+ exports.whatsappService = whatsappService;
4085
4131
  exports.wishlistService = wishlistService;
4086
4132
  //# sourceMappingURL=index.cjs.map
4087
4133
  //# sourceMappingURL=index.cjs.map