Class BrevoSynchronisationServiceImpl
java.lang.Object
ch.tocco.nice2.optional.newsletterbrevo.impl.BrevoSynchronisationServiceImpl
- All Implemented Interfaces:
BrevoSynchronisationService
@Component
public class BrevoSynchronisationServiceImpl
extends Object
implements BrevoSynchronisationService
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.tocco.nice2.optional.newsletterbrevo.impl.BrevoSynchronisationService
BrevoSynchronisationService.AttributePath, BrevoSynchronisationService.AttributeType -
Constructor Summary
ConstructorsConstructorDescriptionBrevoSynchronisationServiceImpl(PersistenceService persistenceService, org.slf4j.Logger logger, QueryBuilderResultHelperService queryBuilderResultHelperService) -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateAttribute(String name, BrevoSynchronisationService.AttributeType type, EntityList values) creates a new attributevoiddelete an attributebrevoModel.GetExtendedContactDetailsgetContactInfo(String email) Returns the contact details for a given email addressvoidimportUsers(long listId, Condition synchronisationCondition, List<BrevoSynchronisationService.AttributePath> attributes) Import users to brevo.booleanisEmailAddressInUse(String email) despiteContactsApi.getContactInfoWithHttpInfo(String, String, String, String)(String, Object, Object)} existing, a 404 still throws an exception instead of just returning the code so we can handle it ourselves.normalizeAttributeName(String name) adjust a string to be a valid brevo attribute name this means the string fulfills the following conditions: - is all upper case - starts with a later (prepend X if not fulfilled) - has no spaces (replace with underscores if not fulfilled)voidremoveUsersFromList(long listId, Condition synchronisationCondition) voidsetImportLimit(int importLimit) voidsetRemoveFromListLimit(int removeFromListLimit) longsynchroniseFolder(Entity folder) Synchronises a tocco folder to brevo.longsynchroniseList(long folderId, Entity newsletterCategory) Synchronises a newsletter category with brevo.voidupdateAttribute(String name, BrevoSynchronisationService.AttributeType type, EntityList values) update attribute, only useful for category attributes, others need to be deleted and recreated for changesvoidupdateBlocklists(String email, List<String> selectedBlocklists) update blocklist entries in brevo make sure that the email address exist in Brevo before updating it, seeBrevoSynchronisationService.isEmailAddressInUse(String)voidupdateEmailAddresses(Map<String, String> changes) update email addresses in brevo make sure that the email addresses exist in Brevo before updating them, seeBrevoSynchronisationService.isEmailAddressInUse(String)
-
Constructor Details
-
BrevoSynchronisationServiceImpl
public BrevoSynchronisationServiceImpl(PersistenceService persistenceService, org.slf4j.Logger logger, QueryBuilderResultHelperService queryBuilderResultHelperService)
-
-
Method Details
-
synchroniseFolder
Description copied from interface:BrevoSynchronisationServiceSynchronises a tocco folder to brevo.- Specified by:
synchroniseFolderin interfaceBrevoSynchronisationService- Parameters:
folder- the brevo folder entity to be synchronised- Returns:
- id of the folder in brevo
-
synchroniseList
Description copied from interface:BrevoSynchronisationServiceSynchronises a newsletter category with brevo. Newsletter categories are mapped to lists in brevo.- Specified by:
synchroniseListin interfaceBrevoSynchronisationService- Parameters:
folderId- the folder id to be used to create new newsletter categoriesnewsletterCategory- the newsletter category to be synchronised- Returns:
- id of the list in brevo
-
importUsers
public void importUsers(long listId, Condition synchronisationCondition, List<BrevoSynchronisationService.AttributePath> attributes) Description copied from interface:BrevoSynchronisationServiceImport users to brevo. Users are transformed to "contacts" and then imported to brevo using the import endpoint. The import endpoint handles creating / updating users and maps users using the email address.- Specified by:
importUsersin interfaceBrevoSynchronisationService- Parameters:
listId- the list id to which the users should be added.synchronisationCondition- query builder condition to be used to select the users to be synchronised
-
removeUsersFromList
- Specified by:
removeUsersFromListin interfaceBrevoSynchronisationService
-
getAttributes
- Specified by:
getAttributesin interfaceBrevoSynchronisationService- Returns:
- names of all attributes configured in brevo
-
createAttribute
public void createAttribute(String name, BrevoSynchronisationService.AttributeType type, EntityList values) Description copied from interface:BrevoSynchronisationServicecreates a new attribute- Specified by:
createAttributein interfaceBrevoSynchronisationService- Parameters:
name- the name of the attribute, make sure it is normalized withBrevoSynchronisationService.normalizeAttributeName(String)type- the type of the attributevalues- the Brevo_attribute_value entities the attribute can take, only relevant for category attributes
-
updateAttribute
public void updateAttribute(String name, BrevoSynchronisationService.AttributeType type, EntityList values) Description copied from interface:BrevoSynchronisationServiceupdate attribute, only useful for category attributes, others need to be deleted and recreated for changes- Specified by:
updateAttributein interfaceBrevoSynchronisationService- Parameters:
name- the name of the attribute, make sure it is normalized withBrevoSynchronisationService.normalizeAttributeName(String)type- the type of the attributevalues- the Brevo_attribute_value entities the attribute can take, only relevant for category attributes
-
deleteAttribute
Description copied from interface:BrevoSynchronisationServicedelete an attribute- Specified by:
deleteAttributein interfaceBrevoSynchronisationService- Parameters:
name- the name of the attribute, make sure it is normalized withBrevoSynchronisationService.normalizeAttributeName(String)type- the type of the attribute
-
normalizeAttributeName
Description copied from interface:BrevoSynchronisationServiceadjust a string to be a valid brevo attribute name this means the string fulfills the following conditions: - is all upper case - starts with a later (prepend X if not fulfilled) - has no spaces (replace with underscores if not fulfilled)- Specified by:
normalizeAttributeNamein interfaceBrevoSynchronisationService- Parameters:
name- any string- Returns:
- a valid attribute name
-
updateEmailAddresses
Description copied from interface:BrevoSynchronisationServiceupdate email addresses in brevo make sure that the email addresses exist in Brevo before updating them, seeBrevoSynchronisationService.isEmailAddressInUse(String)- Specified by:
updateEmailAddressesin interfaceBrevoSynchronisationService- Parameters:
changes- a map containing the current email addresses as keys, and the new email addresses as values
-
updateBlocklists
Description copied from interface:BrevoSynchronisationServiceupdate blocklist entries in brevo make sure that the email address exist in Brevo before updating it, seeBrevoSynchronisationService.isEmailAddressInUse(String)- Specified by:
updateBlocklistsin interfaceBrevoSynchronisationService- Parameters:
email- the email for which the blocklist entries should be updatedselectedBlocklists- a list of strings of the selected blocklist unique_ids (possible values: "email", "sms")
-
getContactInfo
Description copied from interface:BrevoSynchronisationServiceReturns the contact details for a given email address- Specified by:
getContactInfoin interfaceBrevoSynchronisationService- Throws:
brevo.ApiException
-
isEmailAddressInUse
despiteContactsApi.getContactInfoWithHttpInfo(String, String, String, String)(String, Object, Object)} existing, a 404 still throws an exception instead of just returning the code so we can handle it ourselves. this means, we have to catch the exception and read the status code from there- Specified by:
isEmailAddressInUsein interfaceBrevoSynchronisationService- Parameters:
email- the email address to check- Returns:
- true if a contact exists, false other
-
setRemoveFromListLimit
@Value("${nice2.brevo.removeFromListLimit}") public void setRemoveFromListLimit(int removeFromListLimit) -
setImportLimit
@Value("${nice2.brevo.importLimit}") public void setImportLimit(int importLimit)
-