Class NewsletterServiceMain

java.lang.Object
com.endurancetrio.business.newsletter.service.NewsletterServiceMain
All Implemented Interfaces:
NewsletterService

@Service public class NewsletterServiceMain extends Object implements NewsletterService
Kit.com-backed implementation of NewsletterService.

Orchestrates the two-step Kit.com subscription flow:

  1. Create or update the subscriber via KitClient.createOrUpdateSubscriber(com.endurancetrio.business.newsletter.dto.NewsletterSubscriptionDTO).
  2. Add the subscriber to the language-specific form via KitClient.addSubscriberToForm(java.lang.Long, java.lang.String), triggering the double opt-in e-mail configured on that form in Kit.com.
Outbound HTTP calls are delegated to KitClient so this module remains free of web/HTTP dependencies.
  • Constructor Details

    • NewsletterServiceMain

      @Autowired public NewsletterServiceMain(KitClient kitClient, @Value("${kit.form-id-en}") String formIdEn, @Value("${kit.form-id-pt}") String formIdPt)
  • Method Details

    • subscribe

      public void subscribe(NewsletterSubscriptionDTO dto, String language) throws EnduranceTrioException
      Description copied from interface: NewsletterService
      Subscribes the given subscriber to the Kit.com form that corresponds to the requested language.

      The Kit.com v4 API is called in two steps: first the subscriber is created or updated via POST /v4/subscribers, then the resulting subscriber ID is used to add them to the language-specific form via POST /v4/forms/{form_id}/subscribers/{id}, which triggers the double opt-in confirmation email configured on that form.

      Specified by:
      subscribe in interface NewsletterService
      Parameters:
      dto - the subscriber's first name and email address
      language - the page language code ("en" or "pt") used to select the correct Kit.com form
      Throws:
      EnduranceTrioException - if the subscription fails