Problem/Motivation

Provide an API to (un)subscribe from newsletters programmatically as the foundation for UI features.

  1. Provide Brevo SDK integration https://github.com/getbrevo/brevo-php
  2. Provide UI to enter the API Key
  3. Allow other modules to interact with the authenticated SDK

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

anybody created an issue. See original summary.

anybody’s picture

Title: Brevo newsletter (un)subscribe API » Brevo newsletter (un)subscribe (via SDK)
Issue summary: View changes

  • renrhaf committed 9d6fa6b5 on 1.0.x
    Issue #3470738 by renrhaf: Brevo newsletter (un)subscribe (via SDK)
    
renrhaf’s picture

Status: Active » Fixed

The module in the 1.0.x-dev version will provide the necessary APIs.
For example, you can subscribe/unsubscribe a contact from a list using the following code :

  $clientFactory = \Drupal::service('brevo.brevo_client_factory');
  $listsApiClient = $clientFactory->createListsApiClient();
  $contactsApiClient = $clientFactory->createContactsApiClient();

  // Get a contact by email
  // @see https://developers.brevo.com/reference/getcontactinfo-1
  $contact = $contactsApiClient->getContactInfo('example@gmail.com', 'email_id');

  // Get a list by identifier
  $list = $listsApiClient->getList(2);

  // Add a contact to a list
  $contactsApiClient->addContactToList($list->getId(), new \Brevo\Client\Model\AddContactToList(['ids' => [$contact->getId()]]));

  // Remove a contact from a list
  $contactsApiClient->removeContactFromList($list->getId(), new \Brevo\Client\Model\RemoveContactFromList(['ids' => [$contact->getId()]]));

Will this be fine to implement what you need ?

anybody’s picture

Whaooo thank you so much @renrhaf!! That's great news. Sadly I didn't have the time yet to look into it deeper, but definitely going to do that!

I think we might add

in the near future based on that, if you're interested! :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

grevil’s picture