Example #1
0
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* @author Abhik Chakraborty
*/
use sendwithus\API;
require_once BASE_PATH . '/plugins/EmailerSendWithUs/libs/sendwithus/vendor/autoload.php';
$emailer = new EmailerSendWithUs();
$api_key = $emailer->get_api_key();
$entity_selected = false;
$templates_found = false;
$groups_found = false;
$api = new API($api_key);
// get the templates
$templates = $api->emails();
$templates_array = array();
if (is_array($templates) && count($templates) > 0) {
    foreach ($templates as $key => $templateObj) {
        if (property_exists($templateObj, 'name') && property_exists($templateObj, 'id')) {
            $templates_array[$templateObj->id] = $templateObj->name;
        }
    }
    $templates_found = true;
}
//get the groups, sending email to a selected group feature is not added yet
/*$groups = $api->list_groups();
$groups_array = array();
if (is_array($groups->groups) && count($groups->groups) > 0) { 
	foreach ($groups->groups as $key=>$groupsObj) {
		$groups_array[$groupsObj->id] = $groupsObj->name;