Class NewsletterServiceMain
java.lang.Object
com.endurancetrio.business.newsletter.service.NewsletterServiceMain
- All Implemented Interfaces:
NewsletterService
Kit.com-backed implementation of
NewsletterService.
Orchestrates the two-step Kit.com subscription flow:
- Create or update the subscriber via
KitClient.createOrUpdateSubscriber(com.endurancetrio.business.newsletter.dto.NewsletterSubscriptionDTO). - 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.
KitClient so this module remains free of
web/HTTP dependencies.-
Constructor Summary
ConstructorsConstructorDescriptionNewsletterServiceMain(KitClient kitClient, String formIdEn, String formIdPt) -
Method Summary
Modifier and TypeMethodDescriptionvoidsubscribe(NewsletterSubscriptionDTO dto, String language) Subscribes the given subscriber to the Kit.com form that corresponds to the requested language.
-
Constructor Details
-
NewsletterServiceMain
-
-
Method Details
-
subscribe
Description copied from interface:NewsletterServiceSubscribes 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 viaPOST /v4/forms/{form_id}/subscribers/{id}, which triggers the double opt-in confirmation email configured on that form.- Specified by:
subscribein interfaceNewsletterService- Parameters:
dto- the subscriber's first name and email addresslanguage- the page language code ("en"or"pt") used to select the correct Kit.com form- Throws:
EnduranceTrioException- if the subscription fails
-