diff --git a/src/Mailgun/Address/Address.php b/src/Mailgun/Address/Address.php index ee10dc5..ffbbf57 100644 --- a/src/Mailgun/Address/Address.php +++ b/src/Mailgun/Address/Address.php @@ -7,19 +7,19 @@ namespace Mailgun\Address; class Address{ - private $httpBroker; + private $restClient; private $workingDomain; private $endpointUrl; - public function __construct($httpBroker){ - $this->httpBroker = $httpBroker; + public function __construct($restClient){ + $this->restClient = $restClient; $this->endpointUrl = "address"; } - public function validateAddress($address){ + public function getValidate($address){ $updatedUrl = $this->endpointUrl . "/validate"; $getData = array('address' => $address); - $response = $this->httpBroker->getRequest($updatedUrl, $getData); + $response = $this->restClient->getRequest($updatedUrl, $getData); return $response; } } diff --git a/src/Mailgun/Address/README.md b/src/Mailgun/Address/README.md index 5c30fbf..1aefd26 100644 --- a/src/Mailgun/Address/README.md +++ b/src/Mailgun/Address/README.md @@ -17,13 +17,13 @@ $mgClient = new MailgunClient("pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7", "sample $address = $mgClient->Address(); # Now, validate the address and store the result in $result. -$result = $address->validateAddress("me@samples.mailgun.org"); +$result = $address->getValidate("me@samples.mailgun.org"); ``` Available Functions ------------------- -`validateAddress(string $address);` +`getValidate(string $address);` More Documentation ------------------ diff --git a/src/Mailgun/Bounces/Bounces.php b/src/Mailgun/Bounces/Bounces.php index 31d18a3..9a8d6b2 100644 --- a/src/Mailgun/Bounces/Bounces.php +++ b/src/Mailgun/Bounces/Bounces.php @@ -7,13 +7,13 @@ namespace Mailgun\Bounces; class Bounces{ - private $httpBroker; + private $restClient; private $workingDomain; private $endpointUrl; - public function __construct($httpBroker){ - $this->httpBroker = $httpBroker; - $this->endpointUrl = $this->httpBroker->returnWorkingDomain() . "/bounces"; + public function __construct($restClient){ + $this->restClient = $restClient; + $this->endpointUrl = $this->restClient->returnWorkingDomain() . "/bounces"; } public function addAddress($bounceAddress, $bounceCode, $bounceError = null){ @@ -23,23 +23,23 @@ class Bounces{ else{ $postData = array("address" => $bounceAddress, "code" => $bounceCode); } - $response = $this->httpBroker->postRequest($this->endpointUrl, $postData); + $response = $this->restClient->postRequest($this->endpointUrl, $postData); return $response; } public function deleteAddress($bounceAddress){ $requestUrl = $this->endpointUrl . "/" . urlencode($bounceAddress); - $response = $this->httpBroker->deleteRequest($requestUrl); + $response = $this->restClient->deleteRequest($requestUrl); return $response; } public function getBounce($bounceAddress){ $requestUrl = $this->endpointUrl . "/" . urlencode($bounceAddress); - $response = $this->httpBroker->getRequest($requestUrl); + $response = $this->restClient->getRequest($requestUrl); return $response; } public function getBounces($limit, $skip){ - $response = $this->httpBroker->getRequest($this->endpointUrl, array($limit, $skip)); + $response = $this->restClient->getRequest($this->endpointUrl, array($limit, $skip)); return $response; } diff --git a/src/Mailgun/Campaigns/Campaigns.php b/src/Mailgun/Campaigns/Campaigns.php index 8ac8290..6cc048e 100644 --- a/src/Mailgun/Campaigns/Campaigns.php +++ b/src/Mailgun/Campaigns/Campaigns.php @@ -7,24 +7,24 @@ namespace Mailgun\Campaigns; class Campaigns{ - private $httpBroker; + private $restClient; private $workingDomain; private $endpointUrl; - public function __construct($httpBroker){ - $this->httpBroker = $httpBroker; - $this->endpointUrl = $this->httpBroker->returnWorkingDomain() . "/campaigns"; + public function __construct($restClient){ + $this->restClient = $restClient; + $this->endpointUrl = $this->restClient->returnWorkingDomain() . "/campaigns"; } public function getCampaigns($limit, $skip){ - $response = $this->httpBroker->getRequest($this->endpointUrl, array($limit, $skip)); + $response = $this->restClient->getRequest($this->endpointUrl, array($limit, $skip)); return $response; } public function getCampaign($campaignId){ $updatedUrl = $this->endpointUrl . "/" . $campaignId; - $response = $this->httpBroker->getRequest($updatedUrl); + $response = $this->restClient->getRequest($updatedUrl); return $response; } @@ -33,7 +33,7 @@ class Campaigns{ throw new InvalidParameter("The message ID is too long. Limit is 64 characters."); } $postData = array('name' => $name, 'id' => $id); - $response = $this->httpBroker->postRequest($this->endpointUrl, $postData); + $response = $this->restClient->postRequest($this->endpointUrl, $postData); return $response; } @@ -43,49 +43,49 @@ class Campaigns{ } $updatedUrl = $this->endpointUrl . "/" . $campaignId; $postData = array('name' => $name, 'id' => $id); - $response = $this->httpBroker->putRequest($updatedUrl, $postData); + $response = $this->restClient->putRequest($updatedUrl, $postData); return $response; } public function deleteCampaign($campaignId){ $updatedUrl = $this->endpointUrl . "/" . $campaignId; - $response = $this->httpBroker->deleteRequest($updatedUrl); + $response = $this->restClient->deleteRequest($updatedUrl); return $response; } public function getCampaignEvents($campaignId, $filterParams = array()){ $updatedUrl = $this->endpointUrl . "/" . $campaignId . "/events"; - $response = $this->httpBroker->getRequest($updatedUrl, $filterParams); + $response = $this->restClient->getRequest($updatedUrl, $filterParams); return $response; } public function getCampaignStats($campaignId, $filterParams = array()){ $updatedUrl = $this->endpointUrl . "/" . $campaignId . "/stats"; - $response = $this->httpBroker->getRequest($updatedUrl, $filterParams); + $response = $this->restClient->getRequest($updatedUrl, $filterParams); return $response; } public function getCampaignClicks($campaignId, $filterParams = array()){ $updatedUrl = $this->endpointUrl . "/" . $campaignId . "/clicks"; - $response = $this->httpBroker->getRequest($updatedUrl, $filterParams); + $response = $this->restClient->getRequest($updatedUrl, $filterParams); return $response; } public function getCampaignOpens($campaignId, $filterParams = array()){ $updatedUrl = $this->endpointUrl . "/" . $campaignId . "/opens"; - $response = $this->httpBroker->getRequest($updatedUrl, $filterParams); + $response = $this->restClient->getRequest($updatedUrl, $filterParams); return $response; } public function getCampaignUnsubscribes($campaignId, $filterParams = array()){ $updatedUrl = $this->endpointUrl . "/" . $campaignId . "/unsubscribes"; - $response = $this->httpBroker->getRequest($updatedUrl, $filterParams); + $response = $this->restClient->getRequest($updatedUrl, $filterParams); return $response; } public function getCampaignComplaints($campaignId, $filterParams = array()){ $updatedUrl = $this->endpointUrl . "/" . $campaignId . "/clicks"; - $response = $this->httpBroker->getRequest($updatedUrl, $filterParams); + $response = $this->restClient->getRequest($updatedUrl, $filterParams); return $response; } } diff --git a/src/Mailgun/Complaints/Complaints.php b/src/Mailgun/Complaints/Complaints.php index dddd0fb..5a48974 100644 --- a/src/Mailgun/Complaints/Complaints.php +++ b/src/Mailgun/Complaints/Complaints.php @@ -7,34 +7,34 @@ namespace Mailgun\Complaints; class Complaints{ - private $httpBroker; + private $restClient; private $workingDomain; private $endpointUrl; - public function __construct($httpBroker){ - $this->httpBroker = $httpBroker; - $this->endpointUrl = $this->httpBroker->returnWorkingDomain() . "/complaints"; + public function __construct($restClient){ + $this->restClient = $restClient; + $this->endpointUrl = $this->restClient->returnWorkingDomain() . "/complaints"; } public function addAddress($spamAddress){ $postData = array("address" => $spamAddress); - $response = $this->httpBroker->postRequest($this->endpointUrl, $postData); + $response = $this->restClient->postRequest($this->endpointUrl, $postData); return $response; } public function deleteAddress($spamAddress){ $requestUrl = $this->endpointUrl . "/" . urlencode($spamAddress); - $response = $this->httpBroker->deleteRequest($requestUrl); + $response = $this->restClient->deleteRequest($requestUrl); return $response; } public function getComplaint($spamAddress){ $requestUrl = $this->endpointUrl . "/" . urlencode($spamAddress); - $response = $this->httpBroker->getRequest($requestUrl); + $response = $this->restClient->getRequest($requestUrl); return $response; } public function getComplaints($limit, $skip){ - $response = $this->httpBroker->getRequest($this->endpointUrl, array($limit, $skip)); + $response = $this->restClient->getRequest($this->endpointUrl, array($limit, $skip)); return $response; } diff --git a/src/Mailgun/Connection/HttpBroker.php b/src/Mailgun/Connection/RestClient.php similarity index 99% rename from src/Mailgun/Connection/HttpBroker.php rename to src/Mailgun/Connection/RestClient.php index 8063fc0..530ae3e 100644 --- a/src/Mailgun/Connection/HttpBroker.php +++ b/src/Mailgun/Connection/RestClient.php @@ -13,7 +13,7 @@ use Mailgun\Connection\Exceptions\NoDomainsConfigured; use Mailgun\Connection\Exceptions\MissingRequiredMIMEParameters; use Mailgun\Connection\Exceptions\MissingEndpoint; -class HttpBroker{ +class RestClient{ private $apiKey; protected $workingDomain; diff --git a/src/Mailgun/Lists/Lists.php b/src/Mailgun/Lists/Lists.php index d289dbe..4d68b9e 100644 --- a/src/Mailgun/Lists/Lists.php +++ b/src/Mailgun/Lists/Lists.php @@ -7,72 +7,72 @@ namespace Mailgun\Lists; class Lists{ - private $httpBroker; + private $restClient; private $workingDomain; private $endpointUrl; - public function __construct($httpBroker){ - $this->httpBroker = $httpBroker; + public function __construct($restClient){ + $this->restClient = $restClient; $this->endpointUrl = "lists"; } public function getLists($limit, $skip){ - $response = $this->httpBroker->getRequest($this->endpointUrl, array($limit, $skip)); + $response = $this->restClient->getRequest($this->endpointUrl, array($limit, $skip)); return $response; } public function getList($listAddress){ $updatedUrl = $this->endpointUrl . "/" . $listAddress; - $response = $this->httpBroker->getRequest($updatedUrl); + $response = $this->restClient->getRequest($updatedUrl); return $response; } public function addList($listAddress, $name, $description, $access_level){ $postData = array('address' => $listAddress, 'name' => $name, 'description' => $description, 'access_level' => $access_level); - $response = $this->httpBroker->postRequest($this->endpointUrl, $postData); + $response = $this->restClient->postRequest($this->endpointUrl, $postData); return $response; } public function updateList($listAddress, $name, $description, $access_level){ $updatedUrl = $this->endpointUrl . "/" . $listAddress; $postData = array('address' => $listAddress, 'name' => $name, 'description' => $description, 'access_level' => $access_level); - $response = $this->httpBroker->putRequest($updatedUrl, $postData); + $response = $this->restClient->putRequest($updatedUrl, $postData); return $response; } public function deleteList($listAddress){ $updatedUrl = $this->endpointUrl . "/" . $listAddress; - $response = $this->httpBroker->deleteRequest($updatedUrl); + $response = $this->restClient->deleteRequest($updatedUrl); return $response; } public function getListMembers($listAddress, $filterParams = array()){ $updatedUrl = $this->endpointUrl . "/" . $listAddress . "/members"; - $response = $this->httpBroker->getRequest($updatedUrl, $filterParams); + $response = $this->restClient->getRequest($updatedUrl, $filterParams); return $response; } public function getListMember($listAddress, $memberAddress){ $updatedUrl = $this->endpointUrl . "/" . $listAddress . "/members/" . $memberAddress; - $response = $this->httpBroker->getRequest($updatedUrl); + $response = $this->restClient->getRequest($updatedUrl); return $response; } public function addListMember($listAddress, $memberAddress, $name, $vars, $subscribed = true, $upsert = true){ $updatedUrl = $this->endpointUrl . "/" . $listAddress . "/members"; $postData = array('address' => $memberAddress, 'name' => $name, 'vars' => $vars, 'subscribed' => $subscribed, 'upsert' => $upsert); - $response = $this->httpBroker->postRequest($updatedUrl, $postData); + $response = $this->restClient->postRequest($updatedUrl, $postData); return $response; } public function updateListMember($listAddress, $memberAddress, $name, $vars, $subscribed = true){ $updatedUrl = $this->endpointUrl . "/" . $listAddress . "/members/" . $memberAddress; $postData = array('address' => $memberAddress, 'name' => $name, 'vars' => $vars, 'subscribed' => $subscribed); - $response = $this->httpBroker->putRequest($updatedUrl, $postData); + $response = $this->restClient->putRequest($updatedUrl, $postData); return $response; } public function deleteListMember($listAddress, $memberAddress){ $updatedUrl = $this->endpointUrl . "/" . $listAddress . "/members/" . $memberAddress; - $response = $this->httpBroker->deleteRequest($updatedUrl); + $response = $this->restClient->deleteRequest($updatedUrl); return $response; } public function getListStats($listAddress){ $updatedUrl = $this->endpointUrl . "/" . $listAddress . "/stats"; - $response = $this->httpBroker->getRequest($updatedUrl); + $response = $this->restClient->getRequest($updatedUrl); return $response; } } diff --git a/src/Mailgun/Logs/Logs.php b/src/Mailgun/Logs/Logs.php index 7d21e50..664ef61 100644 --- a/src/Mailgun/Logs/Logs.php +++ b/src/Mailgun/Logs/Logs.php @@ -7,18 +7,18 @@ namespace Mailgun\Logs; class Logs{ - private $httpBroker; + private $restClient; private $workingDomain; private $endpointUrl; - public function __construct($httpBroker){ - $this->httpBroker = $httpBroker; - $this->endpointUrl = $this->httpBroker->returnWorkingDomain() . "/log"; + public function __construct($restClient){ + $this->restClient = $restClient; + $this->endpointUrl = $this->restClient->returnWorkingDomain() . "/log"; } public function getLogs($limit, $skip){ - $response = $this->httpBroker->getRequest($this->endpointUrl, array($limit, $skip)); + $response = $this->restClient->getRequest($this->endpointUrl, array($limit, $skip)); return $response; } } diff --git a/src/Mailgun/Mailgun.php b/src/Mailgun/Mailgun.php new file mode 100644 index 0000000..5c4be6d --- /dev/null +++ b/src/Mailgun/Mailgun.php @@ -0,0 +1,165 @@ +restClient = new RestClient($apiKey, $workingDomain, $debugMode); + } + else{ + $this->apiKey = $apiKey; + $this->workingDomain = $workingDomain; + } + } + + private function InstantiateNewClient($workingDomain, $apiKey){ + if(isset($workingDomain) || isset($apiKey)){ + if(isset($workingDomain)){ + $this->workingDomain = $workingDomain; + } + if(isset($apiKey)){ + $this->apiKey = $apiKey; + } + return true; + } + if(isset($this->restClient)){ + return false; + } + else{ + throw new Exception("A valid set of credentials is required to work with this endpoint."); + } + } + + /* + * Factory methods for instantiating each endpoint class. + * If a new endpoint is added, create a factory method here. + * Each endpoint can accept a new domain and API key if you want to + * switch accounts or domains after instantiating the MailgunClient. + * This is for future support of RBAC. + */ + + public function Messages($workingDomain = null, $apiKey = null){ + if($this->InstantiateNewClient($workingDomain, $apiKey)){ + $newClient = new RestClient($this->apiKey, $this->workingDomain, $this->debugMode); + return new Messages($newClient); + } + else{ + return new Messages($this->restClient); + } + } + + public function Unsubscribes($workingDomain = null, $apiKey = null){ + if($this->InstantiateNewClient($workingDomain, $apiKey)){ + $newClient = new RestClient($this->apiKey, $this->workingDomain, $this->debugMode); + return new Unsubscribes($newClient); + } + else{ + return new Unsubscribes($this->restClient); + } + } + + public function Complaints($workingDomain = null, $apiKey = null){ + if($this->InstantiateNewClient($workingDomain, $apiKey)){ + $newClient = new RestClient($this->apiKey, $this->workingDomain, $this->debugMode); + return new Complaints($newClient); + } + else{ + return new Complaints($this->restClient); + } + } + + public function Bounces($workingDomain = null, $apiKey = null){ + if($this->InstantiateNewClient($workingDomain, $apiKey)){ + $newClient = new RestClient($this->apiKey, $this->workingDomain, $this->debugMode); + return new Bounces($newClient); + } + else{ + return new Bounces($this->restClient); + } + } + + public function Stats($workingDomain = null, $apiKey = null){ + if($this->InstantiateNewClient($workingDomain, $apiKey)){ + $newClient = new RestClient($this->apiKey, $this->workingDomain, $this->debugMode); + return new Stats($newClient); + } + else{ + return new Stats($this->restClient); + } + } + + public function Logs($workingDomain = null, $apiKey = null){ + if($this->InstantiateNewClient($workingDomain, $apiKey)){ + $newClient = new RestClient($this->apiKey, $this->workingDomain, $this->debugMode); + return new Logs($newClient); + } + else{ + return new Logs($this->restClient); + } + } + + public function Routes($workingDomain = null, $apiKey = null){ + if($this->InstantiateNewClient($workingDomain, $apiKey)){ + $newClient = new RestClient($this->apiKey, $this->workingDomain, $this->debugMode); + return new Routes($newClient); + } + else{ + return new Routes($this->restClient); + } + } + + public function Campaigns($workingDomain = null, $apiKey = null){ + if($this->InstantiateNewClient($workingDomain, $apiKey)){ + $newClient = new RestClient($this->apiKey, $this->workingDomain, $this->debugMode); + return new Campaigns($newClient); + } + else{ + return new Campaigns($this->restClient); + } + } + + public function Lists($workingDomain = null, $apiKey = null){ + if($this->InstantiateNewClient($workingDomain, $apiKey)){ + $newClient = new RestClient($this->apiKey, $this->workingDomain, $this->debugMode); + return new Lists($newClient); + } + else{ + return new Lists($this->restClient); + } + } + public function Address($workingDomain = null, $apiKey = null){ + if($this->InstantiateNewClient($workingDomain, $apiKey)){ + $newClient = new RestClient($this->apiKey, $this->workingDomain, $this->debugMode); + return new Address($newClient); + } + else{ + return new Address($this->restClient); + } + } +} + +?> \ No newline at end of file diff --git a/src/Mailgun/MailgunClient.php b/src/Mailgun/MailgunClient.php deleted file mode 100644 index 7fa725b..0000000 --- a/src/Mailgun/MailgunClient.php +++ /dev/null @@ -1,73 +0,0 @@ -httpBroker = new HttpBroker($apiKey, $workingDomain, $debugMode); - } - - /* - * Factory methods for instantiating each endpoint class. - * If a new endpoint is added, create a factory method here. - */ - - public function Messages(){ - return new Messages($this->httpBroker); - } - - public function Unsubscribes(){ - return new Unsubscribes($this->httpBroker); - } - - public function Complaints(){ - return new Complaints($this->httpBroker); - } - - public function Bounces(){ - return new Bounces($this->httpBroker); - } - - public function Stats(){ - return new Stats($this->httpBroker); - } - - public function Logs(){ - return new Logs($this->httpBroker); - } - - public function Routes(){ - return new Routes($this->httpBroker); - } - - public function Campaigns(){ - return new Campaigns($this->httpBroker); - } - - public function Lists(){ - return new Lists($this->httpBroker); - } - public function Address(){ - return new Address($this->httpBroker); - } -} - -?> \ No newline at end of file diff --git a/src/Mailgun/Messages/BatchMessage.php b/src/Mailgun/Messages/BatchMessage.php index f10d9d2..35475f5 100644 --- a/src/Mailgun/Messages/BatchMessage.php +++ b/src/Mailgun/Messages/BatchMessage.php @@ -11,8 +11,8 @@ class BatchMessage extends MessageBuilder{ protected $batchRecipientAttributes; protected $autoSend; - public function __construct($httpBroker, $autoSend){ - parent::__construct($httpBroker); + public function __construct($restClient, $autoSend){ + parent::__construct($restClient); $this->batchRecipientAttributes = array(); $this->autoSend = $autoSend; } @@ -68,7 +68,7 @@ class BatchMessage extends MessageBuilder{ } else{ $this->message["recipient-variables"] = json_encode($this->batchRecipientAttributes); - $response = $this->httpBroker->postRequest($this->endpointUrl, $message, $files); + $response = $this->restClient->postRequest($this->endpointUrl, $message, $files); $this->batchRecipientAttributes = array(); $this->toRecipientCount = 0; unset($this->message["to"]); diff --git a/src/Mailgun/Messages/MessageBuilder.php b/src/Mailgun/Messages/MessageBuilder.php index d4709e9..83ec7f3 100644 --- a/src/Mailgun/Messages/MessageBuilder.php +++ b/src/Mailgun/Messages/MessageBuilder.php @@ -18,11 +18,11 @@ class MessageBuilder extends Messages{ protected $campaignIdCount = 0; protected $customOptionCount = 0; protected $tagCount = 0; - protected $httpBroker; + protected $restClient; - public function __construct($httpBroker){ - parent::__construct($httpBroker); - $this->httpBroker = $httpBroker; + public function __construct($restClient){ + parent::__construct($restClient); + $this->restClient = $restClient; } public function addToRecipient($address, $attributes){ diff --git a/src/Mailgun/Messages/Messages.php b/src/Mailgun/Messages/Messages.php index cceffca..4fffe1a 100644 --- a/src/Mailgun/Messages/Messages.php +++ b/src/Mailgun/Messages/Messages.php @@ -9,17 +9,17 @@ use Mailgun\Messages\Exceptions\MissingRequiredMIMEParameters; class Messages{ - protected $httpBroker; + protected $restClient; protected $workingDomain; protected $endpointUrl; - public function __construct($httpBroker){ - $this->httpBroker = $httpBroker; - $this->workingDomain = $this->httpBroker->returnWorkingDomain(); + public function __construct($restClient){ + $this->restClient = $restClient; + $this->workingDomain = $this->restClient->returnWorkingDomain(); $this->endpointUrl = $this->workingDomain . "/messages"; } - public function sendMessage($message = array(), $files = array()){ + public function send($message = array(), $files = array()){ if(count($message) < 1){ $message = $this->message; $files = $this->files; @@ -37,7 +37,7 @@ class Messages{ throw new MissingRequiredMIMEParameters("You are missing the body of the message."); } else{ - $response = $this->httpBroker->postRequest($this->endpointUrl, $message, $files); + $response = $this->restClient->postRequest($this->endpointUrl, $message, $files); return $response; } } @@ -48,11 +48,11 @@ class Messages{ } public function MessageBuilder(){ - return new MessageBuilder($this->httpBroker); + return new MessageBuilder($this->restClient); } public function BatchMessage($autoSend = true){ - return new BatchMessage($this->httpBroker, $autoSend); + return new BatchMessage($this->restClient, $autoSend); } } ?> \ No newline at end of file diff --git a/src/Mailgun/Routes/Routes.php b/src/Mailgun/Routes/Routes.php index bd2ae5c..87e1c78 100644 --- a/src/Mailgun/Routes/Routes.php +++ b/src/Mailgun/Routes/Routes.php @@ -9,23 +9,23 @@ use Mailgun\Routes\Exceptions\InvalidParameter; class Routes{ - private $httpBroker; + private $restClient; private $workingDomain; private $endpointUrl; - public function __construct($httpBroker){ - $this->httpBroker = $httpBroker; + public function __construct($restClient){ + $this->restClient = $restClient; $this->endpointUrl = "routes"; } public function getRoutes($limit, $skip){ - $response = $this->httpBroker->getRequest($this->endpointUrl, array($limit, $skip)); + $response = $this->restClient->getRequest($this->endpointUrl, array($limit, $skip)); return $response; } public function getRoute($routeId){ $updatedUrl = $this->endpointUrl . "/" . $routeId; - $response = $this->httpBroker->getRequest($updatedUrl); + $response = $this->restClient->getRequest($updatedUrl); return $response; } @@ -48,7 +48,7 @@ class Routes{ $postData = array('priority' => $priority, 'description' => $description, 'expression' => $expression, 'action' => $action); - $response = $this->httpBroker->postRequest($this->endpointUrl, $postData); + $response = $this->restClient->postRequest($this->endpointUrl, $postData); return $response; } @@ -72,13 +72,13 @@ class Routes{ $updatedUrl = $this->endpointUrl . "/" . $routeId; - $response = $this->httpBroker->putRequest($updatedUrl, $postData); + $response = $this->restClient->putRequest($updatedUrl, $postData); return $response; } public function deleteRoute($routeId){ $updatedUrl = $this->endpointUrl . "/" . $routeId; - $response = $this->httpBroker->deleteRequest($updatedUrl); + $response = $this->restClient->deleteRequest($updatedUrl); return $response; } } diff --git a/src/Mailgun/Stats/Stats.php b/src/Mailgun/Stats/Stats.php index 1a11a2f..4b54036 100644 --- a/src/Mailgun/Stats/Stats.php +++ b/src/Mailgun/Stats/Stats.php @@ -7,26 +7,26 @@ namespace Mailgun\Stats; class Stats{ - private $httpBroker; + private $restClient; private $workingDomain; private $endpointUrl; private $statsEndpointUrl; private $tagEndpointUrl; - public function __construct($httpBroker){ - $this->httpBroker = $httpBroker; - $this->statsEndpointUrl = $this->httpBroker->returnWorkingDomain() . "/stats"; - $this->tagEndpointUrl = $this->httpBroker->returnWorkingDomain() . "/tags"; + public function __construct($restClient){ + $this->restClient = $restClient; + $this->statsEndpointUrl = $this->restClient->returnWorkingDomain() . "/stats"; + $this->tagEndpointUrl = $this->restClient->returnWorkingDomain() . "/tags"; } public function deleteTag($tag){ $requestUrl = $this->tagEndpointUrl . "/" . urlencode($tag); - $response = $this->httpBroker->deleteRequest($requestUrl); + $response = $this->restClient->deleteRequest($requestUrl); return $response; } public function getStats($filterParams = array()){ - $response = $this->httpBroker->getRequest($this->statsEndpointUrl, $filterParams); + $response = $this->restClient->getRequest($this->statsEndpointUrl, $filterParams); return $response; } } \ No newline at end of file diff --git a/src/Mailgun/Unsubscribes/Unsubscribes.php b/src/Mailgun/Unsubscribes/Unsubscribes.php index b9d6f88..01a47f3 100644 --- a/src/Mailgun/Unsubscribes/Unsubscribes.php +++ b/src/Mailgun/Unsubscribes/Unsubscribes.php @@ -7,13 +7,13 @@ namespace Mailgun\Unsubscribes; class Unsubscribes{ - private $httpBroker; + private $restClient; private $workingDomain; private $endpointUrl; - public function __construct($httpBroker){ - $this->httpBroker = $httpBroker; - $this->endpointUrl = $this->httpBroker->returnWorkingDomain() . "/unsubscribes"; + public function __construct($restClient){ + $this->restClient = $restClient; + $this->endpointUrl = $this->restClient->returnWorkingDomain() . "/unsubscribes"; } public function addAddress($unsubAddress, $unsubTag = NULL){ @@ -23,23 +23,23 @@ class Unsubscribes{ else{ $postData = array("address" => $unsubAddress, "tag" => "*"); } - $response = $this->httpBroker->postRequest($this->endpointUrl, $postData); + $response = $this->restClient->postRequest($this->endpointUrl, $postData); return $response; } public function deleteAddress($unsubAddress){ $requestUrl = $this->endpointUrl . "/" . urlencode($unsubAddress); - $response = $this->httpBroker->deleteRequest($requestUrl); + $response = $this->restClient->deleteRequest($requestUrl); return $response; } public function getUnsubscribe($unsubAddress){ $requestUrl = $this->endpointUrl . "/" . urlencode($unsubAddress); - $response = $this->httpBroker->getRequest($requestUrl); + $response = $this->restClient->getRequest($requestUrl); return $response; } public function getUnsubscribes($limit, $skip){ - $response = $this->httpBroker->getRequest($this->endpointUrl, array($limit, $skip)); + $response = $this->restClient->getRequest($this->endpointUrl, array($limit, $skip)); return $response; } diff --git a/tests/Mailgun/Tests/Connection/TestBroker.php b/tests/Mailgun/Tests/Connection/TestBroker.php index 6d5914e..887fc5a 100644 --- a/tests/Mailgun/Tests/Connection/TestBroker.php +++ b/tests/Mailgun/Tests/Connection/TestBroker.php @@ -1,9 +1,9 @@ httpBroker = new TestBroker($apiKey, $domain, $debug); + $this->restClient = new TestBroker($apiKey, $domain, $debug); return true; } }