75 lines
1.4 KiB
PHP
Executable File
75 lines
1.4 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Interface IMailjetSyncApiClient
|
|
*/
|
|
interface IMailjetSyncApiClient
|
|
{
|
|
/**
|
|
* @param string $api_key
|
|
* @param string $secret_key
|
|
* @return bool
|
|
*/
|
|
public static function testAPI($api_key, $secret_key);
|
|
|
|
/**
|
|
* @param int $code
|
|
* @return bool
|
|
*/
|
|
public static function checkResponseCode($code);
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function isConfigured();
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getLists();
|
|
|
|
/**
|
|
* @param string $email
|
|
* @param int $list_id
|
|
* @return bool
|
|
*/
|
|
public function addContactToList($email, $list_id);
|
|
|
|
/**
|
|
* @param string $email
|
|
* @param int $list_id
|
|
* @param bool $delete
|
|
* @return bool
|
|
*/
|
|
public function deleteContactFromList($email, $list_id, $delete = false);
|
|
}
|
|
|
|
/**
|
|
* Class MailjetSyncApiClientFactory
|
|
*/
|
|
class MailjetSyncApiClientFactory
|
|
{
|
|
/**
|
|
* @param int $version
|
|
* @param string $api_key
|
|
* @param string $secret_key
|
|
* @return IMailjetSyncApiClient
|
|
*/
|
|
public static function create($version, $api_key, $secret_key)
|
|
{
|
|
switch ($version)
|
|
{
|
|
case 1:
|
|
require_once('mailjet_api_v1.php');
|
|
$client = new MailjetSyncApiClientV1($api_key, $secret_key);
|
|
break;
|
|
case 3:
|
|
require_once('mailjet_api_v3.php');
|
|
$client = new MailjetSyncApiClientV3($api_key, $secret_key);
|
|
break;
|
|
default:
|
|
throw new InvalidArgumentException("Bad API version [$version] specified");
|
|
}
|
|
return $client;
|
|
}
|
|
}
|