Epsilon Harmony Documentation
Follow the below procedure to install and use the Epsilon Harmony Client module for Drupal 7.
Installation
- Download the module from https://www.drupal.org/project/epsilon_harmony
- Copy the module content in
/sites/all/modules
directory in your Drupal installation. - Enable the module from
/admin/modules
.
Configuration
- Go to
/admin/config/epsilon_harmony/configurations
and fill in all the required fields. - To add multiple message ID's from Epsilon -- API navigate to
/admin/config/epsilon_harmony/message_configuration
and add the desired message identifier along with the message ID received from the Epsilon Team.
Usage
In order to use the module, call Epsilon Harmony API service.
Please use the following code to call the API.
<?php
$service = \Drupal::service('epsilon_harmony.api_service');
?>
Method 1 (Create 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 Record)
To update 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->updateRecord($record);
?>
*Note* In the above request only "CustomerKey" is a mandatory attribute rest can be removed.
Method 3 (Delete Record)
To delete a record pass customer key.
<?php
$service = \Drupal::service('epsilon_harmony.api_service');
$service->deleteRecord(<CustomerKey>);
?>
*Note* In the above request only "CustomerKey" is a mandatory.
Method 4 (Retrieve Record)
To retrieve a record pass customer key.
<?php
$service = \Drupal::service('epsilon_harmony.api_service');
$service->retrieveRecord(<CustomerKey>);
?>
*Note* In the above request only "CustomerKey" is a mandatory.
Method 5 (Send a Message)
To send a Email via Epsilon Harmony first add the desired message key(received) from Epsilon in the admin/config/epsilon_harmony/message_configuration
.
In the above form you can add multiple message ID's and trigger the API by passing the respective message identifier.
<?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.
Method 6 (Create List 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->createListRecord($record, <list_id>);
?>
*Note* In the above request only "CustomerKey" is a mandatory attribute rest can be removed.
Method 7 (Update List 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->updateListRecord($record, <list_id>);
?>
*Note* In the above request only "CustomerKey" is a mandatory attribute rest can be removed.
Logging
All the API triggers are logged in admin/config/epsilon_harmony/logs
which can be used for debugging purpose.