Usage of the method's available from the module.

Last updated on
12 April 2019

In order to use the module call Epsilon Harmony API service.

<?php
  $service = \Drupal::service('epsilon_harmony.api_service');
?>

Currently there are 3 method's that are available in module. Further support for more API's will be added in future.

  1. Create a Profile Record
  2. Update a Profile Record
  3. Delete a Profile Record
  4. Retrieve a Profile Record
  5. Send a Real Time Message (RTM)

Method 1 (Create a Profile Record)

To create a record pass the desired attributes in a key=>value pair.

<?php
  $service = \Drupal::service('epsilon_harmony.api_service');
  
  $record = [];
  $record['CustomerKey'] = "<CustomerKey>";
  $record['FirstName'] = "<Firstname>";
  $record['LastName'] = "<Lastname>";
  $record['PreferredChannel'] = "<PreferredChannel>";
  $record['GlobalOptOutFlag'] = "<GlobalOptOutFlag>";
  $record['AddressLine1'] = "<AddressLine1>";
  ...etc
  $service->createRecord($record);
?>

Note: In the above request only "CustomerKey" is a mandatory attribute rest can be removed.

Method 2 (Update a Profile Record)

<?php
  $service = \Drupal::service('epsilon_harmony.api_service');
  
  $record = [];
  $record['CustomerKey'] = "<CustomerKey>";
  $record['FirstName'] = "<Firstname>";
  $record['LastName'] = "<Lastname>";
  $record['PreferredChannel'] = "<PreferredChannel>";
  $record['GlobalOptOutFlag'] = "<GlobalOptOutFlag>";
  $record['AddressLine1'] = "<AddressLine1>";
  ...etc
  $service->updateRecord($record);
?>

Note: In the above request only "CustomerKey" is a mandatory attribute rest can be removed.

Method 3 (Delete a Profile Record)

<?php
  $service = \Drupal::service('epsilon_harmony.api_service');
  $service->deleteRecord(<CustomerKey>);
?>

Note: In the above request only "CustomerKey" is a mandatory attribute rest can be removed.

Method 4 (Retrieve a Profile Record)

<?php
  $service = \Drupal::service('epsilon_harmony.api_service');
  $service->retrieveRecord(<CustomerKey>);
?>

Note: In the above request only "CustomerKey" is a mandatory attribute rest can be removed.

Method 5 (Send a Real Time Message (RTM))

To send an Email via Epsilon Harmony first add the desired message key(received from Epsilon) in admin/config/epsilon_harmony/message_configuration.
In the above form you can add multiple message ID's and trigger the API by passing their respective message identifiers.

<?php
  $service = \Drupal::service('epsilon_harmony.api_service');
  
  $record = [];
  $record['subjectOverride'] = "<Override if necessary not a required attribute>";
  $record['recipients'][] = array(
    "customerKey" => "<CustomerKey>",
    "emailAddress" => "<Email ID>",
    'attributes' => [
      array(
        'attributeName' => "FIRST_NAME",
        'attributeType' => "String",
        'attributeValue' => "<FirstName>",
      ),
      array(
        'attributeName' => "LAST_NAME",
        'attributeType' => "String",
        'attributeValue' => "<LastName>",
      )
      ...etc
    ]
  );
  $service->sendMessage("<message-identifier>", $record);
?>

Note: In the above request only "customerKey" and "emailAddress" are mandatory attributes rest can be removed.

Logging

All the API triggers are logged in admin/config/epsilon_harmony/logs.

Help improve this page

Page status: No known problems

You can: