mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-29 00:25:37 +03:00
Refactor complete
This commit is contained in:
parent
1b3720a339
commit
104bb72008
34
README.md
34
README.md
@ -27,44 +27,30 @@ php -d detect_unicode=Off -r "eval('?>'.file_get_contents('https://getcomposer.o
|
|||||||
Next, require Composer's autoloader, in your application, to automatically load the Mailgun SDK in your project:
|
Next, require Composer's autoloader, in your application, to automatically load the Mailgun SDK in your project:
|
||||||
```PHP
|
```PHP
|
||||||
require 'vendor/autoload.php';
|
require 'vendor/autoload.php';
|
||||||
use Mailgun\MailgunClient;
|
use Mailgun\Mailgun;
|
||||||
```
|
```
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
Using the SDK should feel simple, if you're already familiar with our API endpoints. If not, no problem... When you're reviewing our documentation, the endpoints are expressed as a class in the SDK to make things easier.
|
Using the SDK should feel simple, if you're already familiar with our API endpoints. If not, no problem... When you're reviewing our documentation, use the provided resource URL when creating the HTTP request.
|
||||||
|
|
||||||
For example, here's how to use the "Messages" API endpoint:
|
For example, here's how to use the "Messages" API endpoint:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
# First, instantiate the client with your API credentials and domain.
|
# First, instantiate the SDK with your API credentials and define your domain.
|
||||||
$mgClient = new MailgunClient("key-3ax6xnjp29jd6fds4gc373sgvjxteol0", "samples.mailgun.org");
|
$mg = new Mailgun("key-example");
|
||||||
|
$domain = "example.com";
|
||||||
|
|
||||||
# Next, instantiate a Message object on the messages API endpoint.
|
# Now, compose and send your message.
|
||||||
$message = $mgClient->Messages();
|
$mg->post('{$domain}/messages', array('from' => 'bob@example.com',
|
||||||
|
'to' => 'sally@example.com',
|
||||||
# Now, compose your message.
|
|
||||||
$message->setMessage(array('from' => 'me@samples.mailgun.org',
|
|
||||||
'to' => 'php-sdk@mailgun.net',
|
|
||||||
'subject' => 'The PHP SDK is awesome!',
|
'subject' => 'The PHP SDK is awesome!',
|
||||||
'text' => 'It is so simple to send a message.'));
|
'text' => 'It is so simple to send a message.'));
|
||||||
|
|
||||||
# Finally, send the message.
|
|
||||||
$message->sendMessage();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
For usage examples on each API endpoint, go to the "src/Mailgun" folder and browse through each API endpoint folder. A README exists in each folder with examples.
|
For usage examples on each API endpoint, head over to our official documentation pages.
|
||||||
|
|
||||||
[Address](src/Mailgun/Address/)
|
This SDK includes a [Message Builder](src/Mailgun/Messages/README.md) and [Batch Message](src/Mailgun/Messages/README.md) component.
|
||||||
[Bounces](src/Mailgun/Bounces/)
|
|
||||||
[Campaigns](src/Mailgun/Campaigns/)
|
|
||||||
[Complaints](src/Mailgun/Complaints/)
|
|
||||||
[Lists](src/Mailgun/Lists/)
|
|
||||||
[Logs](src/Mailgun/Logs/)
|
|
||||||
[Messages](src/Mailgun/Messages/)
|
|
||||||
[Routes](src/Mailgun/Routes/)
|
|
||||||
[Stats](src/Mailgun/Stats/)
|
|
||||||
[Unsubscribes](src/Mailgun/Unsubscribes/)
|
|
||||||
|
|
||||||
Support and Feedback
|
Support and Feedback
|
||||||
--------------------
|
--------------------
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Address.php - Validate Addresses.
|
|
||||||
*/
|
|
||||||
namespace Mailgun\Address;
|
|
||||||
|
|
||||||
class Address{
|
|
||||||
|
|
||||||
private $restClient;
|
|
||||||
private $workingDomain;
|
|
||||||
private $endpointUrl;
|
|
||||||
|
|
||||||
public function __construct($restClient){
|
|
||||||
$this->restClient = $restClient;
|
|
||||||
$this->endpointUrl = "address";
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getValidate($address){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/validate";
|
|
||||||
$getData = array('address' => $address);
|
|
||||||
$response = $this->restClient->getRequest($updatedUrl, $getData);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@ -1,30 +0,0 @@
|
|||||||
Mailgun - Address
|
|
||||||
===================
|
|
||||||
|
|
||||||
This is the Mailgun PHP *Email Validation* endpoint. Given an arbitrary address, we will validate the address based on: Syntax checks (RFC defined grammar), DNS validation, Spell checks, Email Service Provider (ESP) specific local-part grammar (if available).
|
|
||||||
|
|
||||||
The below assumes you've already installed the Mailgun PHP SDK in to your project. If not, go back to the master README for instructions.
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-------------
|
|
||||||
Here's how to use the "Address" API endpoint:
|
|
||||||
|
|
||||||
```php
|
|
||||||
# First, instantiate the client with your PUBLIC API credentials and domain.
|
|
||||||
$mgClient = new MailgunClient("pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7", "samples.mailgun.org");
|
|
||||||
|
|
||||||
# Next, instantiate an Address object on the Address API endpoint.
|
|
||||||
$address = $mgClient->Address();
|
|
||||||
|
|
||||||
# Now, validate the address and store the result in $result.
|
|
||||||
$result = $address->getValidate("me@samples.mailgun.org");
|
|
||||||
```
|
|
||||||
|
|
||||||
Available Functions
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
`getValidate(string $address);`
|
|
||||||
|
|
||||||
More Documentation
|
|
||||||
------------------
|
|
||||||
See the official [Mailgun Docs](http://documentation.mailgun.com/api-email-validation.html) for more information.
|
|
@ -1,46 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Bounces.php - Processing Bounces.
|
|
||||||
*/
|
|
||||||
namespace Mailgun\Bounces;
|
|
||||||
|
|
||||||
class Bounces{
|
|
||||||
|
|
||||||
private $restClient;
|
|
||||||
private $workingDomain;
|
|
||||||
private $endpointUrl;
|
|
||||||
|
|
||||||
public function __construct($restClient){
|
|
||||||
$this->restClient = $restClient;
|
|
||||||
$this->endpointUrl = $this->restClient->returnWorkingDomain() . "/bounces";
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addAddress($bounceAddress, $bounceCode, $bounceError = null){
|
|
||||||
if(isset($bounceError)){
|
|
||||||
$postData = array("address" => $bounceAddress, "code" => $bounceCode, "error" => $bounceError);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$postData = array("address" => $bounceAddress, "code" => $bounceCode);
|
|
||||||
}
|
|
||||||
$response = $this->restClient->postRequest($this->endpointUrl, $postData);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteAddress($bounceAddress){
|
|
||||||
$requestUrl = $this->endpointUrl . "/" . urlencode($bounceAddress);
|
|
||||||
$response = $this->restClient->deleteRequest($requestUrl);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBounce($bounceAddress){
|
|
||||||
$requestUrl = $this->endpointUrl . "/" . urlencode($bounceAddress);
|
|
||||||
$response = $this->restClient->getRequest($requestUrl);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
public function getBounces($limit, $skip){
|
|
||||||
$response = $this->restClient->getRequest($this->endpointUrl, array($limit, $skip));
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
Mailgun - Bounces
|
|
||||||
===================
|
|
||||||
|
|
||||||
This is the Mailgun PHP *Bounces* endpoint.
|
|
||||||
|
|
||||||
The below assumes you've already installed the Mailgun PHP SDK in to your project. If not, go back to the master README for instructions.
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-------------
|
|
||||||
Here's how to use the "Bounces" API endpoint:
|
|
||||||
|
|
||||||
```php
|
|
||||||
# First, instantiate the client with your PUBLIC API credentials and domain.
|
|
||||||
$mgClient = new MailgunClient("key-3ax6xnjp29jd6fds4gc373sgvjxteol0", "samples.mailgun.org");
|
|
||||||
|
|
||||||
# Next, instantiate a Bounces object on the Bounces API endpoint.
|
|
||||||
$bounces = $mgClient->Bounces();
|
|
||||||
|
|
||||||
# Finally, add an address to the Bounces Table.
|
|
||||||
$result = $bounces->addAddress("bounce@samples.mailgun.org", 550, "Server not accepting messages for mailbox.");
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Available Functions
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
`addAddress(string $bounceAddress, int $bounceCode, string $bounceError);`
|
|
||||||
|
|
||||||
`deleteAddress(string $bounceAddress);`
|
|
||||||
|
|
||||||
`getBounce(string $bounceAddress);`
|
|
||||||
|
|
||||||
`getBounces(int $limit, int $skip);`
|
|
||||||
|
|
||||||
|
|
||||||
More Documentation
|
|
||||||
------------------
|
|
||||||
See the official [Mailgun Docs](http://documentation.mailgun.com/api-bounces.html) for more information.
|
|
@ -1,93 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Campaigns.php - Processing Campaigns.
|
|
||||||
*/
|
|
||||||
namespace Mailgun\Campaigns;
|
|
||||||
|
|
||||||
class Campaigns{
|
|
||||||
|
|
||||||
private $restClient;
|
|
||||||
private $workingDomain;
|
|
||||||
private $endpointUrl;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct($restClient){
|
|
||||||
$this->restClient = $restClient;
|
|
||||||
$this->endpointUrl = $this->restClient->returnWorkingDomain() . "/campaigns";
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCampaigns($limit, $skip){
|
|
||||||
$response = $this->restClient->getRequest($this->endpointUrl, array($limit, $skip));
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCampaign($campaignId){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $campaignId;
|
|
||||||
$response = $this->restClient->getRequest($updatedUrl);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addCampaign($name, $id){
|
|
||||||
if(isset($id) && strlen($id) > 64){
|
|
||||||
throw new InvalidParameter("The message ID is too long. Limit is 64 characters.");
|
|
||||||
}
|
|
||||||
$postData = array('name' => $name, 'id' => $id);
|
|
||||||
$response = $this->restClient->postRequest($this->endpointUrl, $postData);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateCampaign($campaignId, $name, $id){
|
|
||||||
if(isset($id) && strlen($id) > 64){
|
|
||||||
throw new InvalidParameter("The message ID is too long. Limit is 64 characters.");
|
|
||||||
}
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $campaignId;
|
|
||||||
$postData = array('name' => $name, 'id' => $id);
|
|
||||||
$response = $this->restClient->putRequest($updatedUrl, $postData);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteCampaign($campaignId){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $campaignId;
|
|
||||||
$response = $this->restClient->deleteRequest($updatedUrl);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCampaignEvents($campaignId, $filterParams = array()){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $campaignId . "/events";
|
|
||||||
$response = $this->restClient->getRequest($updatedUrl, $filterParams);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCampaignStats($campaignId, $filterParams = array()){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $campaignId . "/stats";
|
|
||||||
$response = $this->restClient->getRequest($updatedUrl, $filterParams);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCampaignClicks($campaignId, $filterParams = array()){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $campaignId . "/clicks";
|
|
||||||
$response = $this->restClient->getRequest($updatedUrl, $filterParams);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCampaignOpens($campaignId, $filterParams = array()){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $campaignId . "/opens";
|
|
||||||
$response = $this->restClient->getRequest($updatedUrl, $filterParams);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCampaignUnsubscribes($campaignId, $filterParams = array()){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $campaignId . "/unsubscribes";
|
|
||||||
$response = $this->restClient->getRequest($updatedUrl, $filterParams);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCampaignComplaints($campaignId, $filterParams = array()){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $campaignId . "/clicks";
|
|
||||||
$response = $this->restClient->getRequest($updatedUrl, $filterParams);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Mailgun\Campaigns\Exceptions;
|
|
||||||
|
|
||||||
class InvalidParameter extends \Exception{}
|
|
||||||
|
|
||||||
?>
|
|
@ -1,53 +0,0 @@
|
|||||||
Mailgun - Campaigns
|
|
||||||
===================
|
|
||||||
|
|
||||||
This is the Mailgun PHP *Campaigns* endpoint.
|
|
||||||
|
|
||||||
The below assumes you've already installed the Mailgun PHP SDK in to your project. If not, go back to the master README for instructions.
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-------------
|
|
||||||
Here's how to use the "Campaign" API endpoint:
|
|
||||||
|
|
||||||
```php
|
|
||||||
# First, instantiate the client with your PUBLIC API credentials and domain.
|
|
||||||
$mgClient = new MailgunClient("key-3ax6xnjp29jd6fds4gc373sgvjxteol0", "samples.mailgun.org");
|
|
||||||
|
|
||||||
# Next, instantiate a Campaign object on the Campaign API endpoint.
|
|
||||||
$campaigns = $mgClient->Campaigns();
|
|
||||||
|
|
||||||
$ Finally, get a list of campaigns, limit 5, skip 0.
|
|
||||||
$campaigns->getCampaigns(5, 0);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Available Functions
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
`getCampaigns(int $limit, int $skip)`
|
|
||||||
|
|
||||||
`getCampaign(string $campaignId)`
|
|
||||||
|
|
||||||
`addCampaign(string $name, string $id)`
|
|
||||||
|
|
||||||
`updateCampaign(string $campaignId, string $name, string $id)`
|
|
||||||
|
|
||||||
`deleteCampaign(string $campaignId)`
|
|
||||||
|
|
||||||
`getCampaignEvents(string $campaignId, array $filterParams)`
|
|
||||||
|
|
||||||
`getCampaignStats(string $campaignId, array $filterParams)`
|
|
||||||
|
|
||||||
`getCampaignClicks(string $campaignId, array $filterParams)`
|
|
||||||
|
|
||||||
`getCampaignOpens(string $campaignId, array $filterParams)`
|
|
||||||
|
|
||||||
`getCampaignUnsubscribes(string $campaignId, array $filterParams)`
|
|
||||||
|
|
||||||
`getCampaignComplaints(string $campaignId, array $filterParams)`
|
|
||||||
|
|
||||||
$filterParams are unique to the endpoint being called. See the documentation below for specifics.
|
|
||||||
|
|
||||||
More Documentation
|
|
||||||
------------------
|
|
||||||
See the official [Mailgun Docs](http://documentation.mailgun.com/api-campaigns.html) for more information.
|
|
@ -1,41 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SpamComplaints.php - Processing Spam Complaints.
|
|
||||||
*/
|
|
||||||
namespace Mailgun\Complaints;
|
|
||||||
|
|
||||||
class Complaints{
|
|
||||||
|
|
||||||
private $restClient;
|
|
||||||
private $workingDomain;
|
|
||||||
private $endpointUrl;
|
|
||||||
|
|
||||||
public function __construct($restClient){
|
|
||||||
$this->restClient = $restClient;
|
|
||||||
$this->endpointUrl = $this->restClient->returnWorkingDomain() . "/complaints";
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addAddress($spamAddress){
|
|
||||||
$postData = array("address" => $spamAddress);
|
|
||||||
$response = $this->restClient->postRequest($this->endpointUrl, $postData);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteAddress($spamAddress){
|
|
||||||
$requestUrl = $this->endpointUrl . "/" . urlencode($spamAddress);
|
|
||||||
$response = $this->restClient->deleteRequest($requestUrl);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getComplaint($spamAddress){
|
|
||||||
$requestUrl = $this->endpointUrl . "/" . urlencode($spamAddress);
|
|
||||||
$response = $this->restClient->getRequest($requestUrl);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
public function getComplaints($limit, $skip){
|
|
||||||
$response = $this->restClient->getRequest($this->endpointUrl, array($limit, $skip));
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
Mailgun - Complaints
|
|
||||||
====================
|
|
||||||
|
|
||||||
This is the Mailgun PHP *Complaints* endpoint.
|
|
||||||
|
|
||||||
The below assumes you've already installed the Mailgun PHP SDK in to your project. If not, go back to the master README for instructions.
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-------------
|
|
||||||
Here's how to use the "Complaints" API endpoint:
|
|
||||||
|
|
||||||
```php
|
|
||||||
# First, instantiate the client with your PUBLIC API credentials and domain.
|
|
||||||
$mgClient = new MailgunClient("key-3ax6xnjp29jd6fds4gc373sgvjxteol0", "samples.mailgun.org");
|
|
||||||
|
|
||||||
# Next, instantiate a Complaints object on the Complaints API endpoint.
|
|
||||||
$complaints = $mgClient->Complaints();
|
|
||||||
|
|
||||||
# Finally, add a complaint to the Spam Complaints table.
|
|
||||||
$result = $complaints->addAddress("junk@samples.mailgun.org");
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Available Functions
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
`addAddress(string $spamAddress)`
|
|
||||||
|
|
||||||
`deleteAddress(string $spamAddress)`
|
|
||||||
|
|
||||||
`getComplaint(string $spamAddress)`
|
|
||||||
|
|
||||||
`getComplaints(int $limit, int $skip)`
|
|
||||||
|
|
||||||
More Documentation
|
|
||||||
------------------
|
|
||||||
See the official [Mailgun Docs](http://documentation.mailgun.com/api-complaints.html) for more information.
|
|
@ -1,80 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Lists.php - Processing LIsts.
|
|
||||||
*/
|
|
||||||
namespace Mailgun\Lists;
|
|
||||||
|
|
||||||
class Lists{
|
|
||||||
|
|
||||||
private $restClient;
|
|
||||||
private $workingDomain;
|
|
||||||
private $endpointUrl;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct($restClient){
|
|
||||||
$this->restClient = $restClient;
|
|
||||||
$this->endpointUrl = "lists";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLists($limit, $skip){
|
|
||||||
$response = $this->restClient->getRequest($this->endpointUrl, array($limit, $skip));
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
public function getList($listAddress){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $listAddress;
|
|
||||||
$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->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->restClient->putRequest($updatedUrl, $postData);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
public function deleteList($listAddress){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $listAddress;
|
|
||||||
$response = $this->restClient->deleteRequest($updatedUrl);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
public function getListMembers($listAddress, $filterParams = array()){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $listAddress . "/members";
|
|
||||||
$response = $this->restClient->getRequest($updatedUrl, $filterParams);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
public function getListMember($listAddress, $memberAddress){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $listAddress . "/members/" . $memberAddress;
|
|
||||||
$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->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->restClient->putRequest($updatedUrl, $postData);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
public function deleteListMember($listAddress, $memberAddress){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $listAddress . "/members/" . $memberAddress;
|
|
||||||
$response = $this->restClient->deleteRequest($updatedUrl);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
public function getListStats($listAddress){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $listAddress . "/stats";
|
|
||||||
$response = $this->restClient->getRequest($updatedUrl);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@ -1,53 +0,0 @@
|
|||||||
Mailgun - Lists
|
|
||||||
====================
|
|
||||||
|
|
||||||
This is the Mailgun PHP *Lists* endpoint.
|
|
||||||
|
|
||||||
The below assumes you've already installed the Mailgun PHP SDK in to your project. If not, go back to the master README for instructions.
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-------------
|
|
||||||
Here's how to use the "Lists" API endpoint:
|
|
||||||
|
|
||||||
```php
|
|
||||||
# First, instantiate the client with your PUBLIC API credentials and domain.
|
|
||||||
$mgClient = new MailgunClient("key-3ax6xnjp29jd6fds4gc373sgvjxteol0", "samples.mailgun.org");
|
|
||||||
|
|
||||||
# Next, instantiate a Lists object on the Lists API endpoint.
|
|
||||||
$lists = $mgClient->Lists();
|
|
||||||
|
|
||||||
# Finally, get 50 results and store in $result.
|
|
||||||
$result = $lists->getLists(50, 0);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Available Functions
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
`getLists(int $limit, int $skip)`
|
|
||||||
|
|
||||||
`getList(string $listAddress)`
|
|
||||||
|
|
||||||
`addList(string $listAddress, string $name, string $description, string $access_level)`
|
|
||||||
|
|
||||||
`updateList(string $listAddress, string $name, string $description, string $access_level)`
|
|
||||||
|
|
||||||
`deleteList(string $listAddress)`
|
|
||||||
|
|
||||||
`getListMembers(string $listAddress, array $filterParams)`
|
|
||||||
|
|
||||||
`getListMember(string $listAddress, string $memberAddress)`
|
|
||||||
|
|
||||||
`addListMember(string $listAddress, string $memberAddress, string $name, array $vars, bool $subscribed, bool $upsert)`
|
|
||||||
|
|
||||||
`updateListMember(string $listAddress, string $memberAddress, string $name, array $vars, bool $subscribed)`
|
|
||||||
|
|
||||||
`deleteListMember(string $listAddress, string $memberAddress)`
|
|
||||||
|
|
||||||
`getListStats(string $listAddress)`
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
More Documentation
|
|
||||||
------------------
|
|
||||||
See the official [Mailgun Docs](http://documentation.mailgun.com/api-mailinglists.html) for more information.
|
|
@ -1,26 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Logs.php - Processing Logs.
|
|
||||||
*/
|
|
||||||
namespace Mailgun\Logs;
|
|
||||||
|
|
||||||
class Logs{
|
|
||||||
|
|
||||||
private $restClient;
|
|
||||||
private $workingDomain;
|
|
||||||
private $endpointUrl;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct($restClient){
|
|
||||||
$this->restClient = $restClient;
|
|
||||||
$this->endpointUrl = $this->restClient->returnWorkingDomain() . "/log";
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLogs($limit, $skip){
|
|
||||||
$response = $this->restClient->getRequest($this->endpointUrl, array($limit, $skip));
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@ -1,31 +0,0 @@
|
|||||||
Mailgun - Logs
|
|
||||||
====================
|
|
||||||
|
|
||||||
This is the Mailgun PHP *Logs* endpoint.
|
|
||||||
|
|
||||||
The below assumes you've already installed the Mailgun PHP SDK in to your project. If not, go back to the master README for instructions.
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-------------
|
|
||||||
Here's how to use the "Logs" API endpoint:
|
|
||||||
|
|
||||||
```php
|
|
||||||
# First, instantiate the client with your PUBLIC API credentials and domain.
|
|
||||||
$mgClient = new MailgunClient("key-3ax6xnjp29jd6fds4gc373sgvjxteol0", "samples.mailgun.org");
|
|
||||||
|
|
||||||
# Next, instantiate a Logs object on the Logs API endpoint.
|
|
||||||
$logs = $mgClient->Logs();
|
|
||||||
|
|
||||||
# Finally, get the 50 most recent log items.
|
|
||||||
$result = $logs->getLogs(50, 0);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Available Functions
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
`getLogs(int $limit, int $skip)`
|
|
||||||
|
|
||||||
More Documentation
|
|
||||||
------------------
|
|
||||||
See the official [Mailgun Docs](http://documentation.mailgun.com/api-logs.html) for more information.
|
|
@ -38,8 +38,8 @@ class Mailgun{
|
|||||||
return new MessageBuilder();
|
return new MessageBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function BatchMessage($autoSend = true){
|
public function BatchMessage($workingDomain, $autoSend = true){
|
||||||
return new BatchMessage($this->restClient, $autoSend);
|
return new BatchMessage($this->restClient, $workingDomain, $autoSend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,20 +2,24 @@
|
|||||||
|
|
||||||
namespace Mailgun\Messages;
|
namespace Mailgun\Messages;
|
||||||
|
|
||||||
|
use Mailgun\Messages\MessageBuilder;
|
||||||
use Mailgun\Messages\Exceptions\TooManyParameters;
|
use Mailgun\Messages\Exceptions\TooManyParameters;
|
||||||
use Mailgun\Messages\Exceptions\MissingRequiredMIMEParameters;
|
use Mailgun\Messages\Exceptions\MissingRequiredMIMEParameters;
|
||||||
|
|
||||||
|
|
||||||
class BatchMessage{
|
class BatchMessage extends MessageBuilder{
|
||||||
|
|
||||||
protected $batchRecipientAttributes;
|
protected $batchRecipientAttributes;
|
||||||
protected $autoSend;
|
protected $autoSend;
|
||||||
protected $restClient;
|
protected $restClient;
|
||||||
|
protected $workingDomain;
|
||||||
|
|
||||||
public function __construct($restClient, $autoSend){
|
public function __construct($restClient, $workingDomain, $autoSend){
|
||||||
$this->batchRecipientAttributes = array();
|
$this->batchRecipientAttributes = array();
|
||||||
$this->autoSend = $autoSend;
|
$this->autoSend = $autoSend;
|
||||||
$this->restClient = $restClient;
|
$this->restClient = $restClient;
|
||||||
|
$this->workingDomain = $workingDomain;
|
||||||
|
$this->endpointUrl = $workingDomain . "/messages";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addToRecipient($address, $attributes){
|
public function addToRecipient($address, $attributes){
|
||||||
@ -76,5 +80,8 @@ class BatchMessage{
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public function finalize(){
|
||||||
|
return $this->sendMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -328,6 +328,15 @@ class MessageBuilder{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setMessage($message = array(), $files = array()){
|
||||||
|
$this->message = $message;
|
||||||
|
$this->files = $files;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMessage(){
|
||||||
|
return $this->message;
|
||||||
|
}
|
||||||
|
|
||||||
public function getFiles(){
|
public function getFiles(){
|
||||||
return $this->files;
|
return $this->files;
|
||||||
}
|
}
|
||||||
|
@ -1,57 +1,33 @@
|
|||||||
Mailgun - Messages
|
Mailgun - Messages
|
||||||
====================
|
====================
|
||||||
|
|
||||||
This is the Mailgun PHP *Messages* endpoint.
|
This is the Mailgun PHP *Message* utilities.
|
||||||
|
|
||||||
The below assumes you've already installed the Mailgun PHP SDK in to your project. If not, go back to the master README for instructions.
|
The below assumes you've already installed the Mailgun PHP SDK in to your project. If not, go back to the master README for instructions.
|
||||||
|
|
||||||
Usage - Messages
|
There are two utilities included, Message Builder and Batch Message.
|
||||||
----------------
|
|
||||||
Here's how to use the "Messages" API endpoint:
|
|
||||||
|
|
||||||
```php
|
Message Builder: Allows you to build a message object by calling methods for each MIME attribute.
|
||||||
# First, instantiate the client with your PUBLIC API credentials and domain.
|
Batch Message: Inherits Message Builder and allows you to iterate through recipients from a list. Messages will fire after the 1,000th recipient has been added.
|
||||||
$mgClient = new MailgunClient("key-3ax6xnjp29jd6fds4gc373sgvjxteol0", "samples.mailgun.org");
|
|
||||||
|
|
||||||
# Next, instantiate a Message object on the Messages API endpoint.
|
|
||||||
$message = $mgClient->Messages();
|
|
||||||
|
|
||||||
# Next, set the message content.
|
|
||||||
$message->setMessage(array('from' => 'me@samples.mailgun.org',
|
|
||||||
'to' => 'php-sdk@mailgun.net',
|
|
||||||
'subject' => 'The PHP SDK is awesome!',
|
|
||||||
'text' => 'It is so simple to send a message.'));
|
|
||||||
|
|
||||||
# Finally, send the message.
|
|
||||||
$message->sendMessage();
|
|
||||||
```
|
|
||||||
|
|
||||||
Available Functions
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
`sendMessage(array $message, array $files)`
|
|
||||||
|
|
||||||
`setMessage(array $message, array $files)`
|
|
||||||
|
|
||||||
`sendMessage()`
|
|
||||||
|
|
||||||
Usage - Message Builder
|
Usage - Message Builder
|
||||||
---------------------
|
-----------------------
|
||||||
Here's how to use the "Messages" API endpoint with Message Builder:
|
Here's how to use Message Builder to build your Message.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
# First, instantiate the client with your PUBLIC API credentials and domain.
|
# First, instantiate the SDK with your API credentials and define your domain.
|
||||||
$mgClient = new MailgunClient("key-3ax6xnjp29jd6fds4gc373sgvjxteol0", "samples.mailgun.org");
|
$mg = new Mailgun("key-example");
|
||||||
|
$domain = "example.com";
|
||||||
|
|
||||||
# Next, instantiate a Message Builder object on the Messages API endpoint.
|
# Next, instantiate a Message Builder object from the SDK.
|
||||||
$messageBldr = $mgClient->Messages()->MessageBuilder();
|
$messageBldr = $mg->MessageBuilder();
|
||||||
|
|
||||||
# Define the from address.
|
# Define the from address.
|
||||||
$messageBldr->setFromAddress("me@samples.mailgun.org", array("first"=>"PHP", "last" => "SDK"));
|
$messageBldr->setFromAddress("me@example.com", array("first"=>"PHP", "last" => "SDK"));
|
||||||
# Define a to recipient.
|
# Define a to recipient.
|
||||||
$messageBldr->addToRecipient("john.doe@samples.mailgun.org", array("first" => "John", "last" => "Doe"));
|
$messageBldr->addToRecipient("john.doe@example.com", array("first" => "John", "last" => "Doe"));
|
||||||
# Define a cc recipient.
|
# Define a cc recipient.
|
||||||
$messageBldr->addCcRecipient("sally.doe@samples.mailgun.org", array("first" => "Sally", "last" => "Doe"));
|
$messageBldr->addCcRecipient("sally.doe@example.com", array("first" => "Sally", "last" => "Doe"));
|
||||||
# Define the subject.
|
# Define the subject.
|
||||||
$messageBldr->setSubject("A message from the PHP SDK using Message Builder!");
|
$messageBldr->setSubject("A message from the PHP SDK using Message Builder!");
|
||||||
# Define the body of the message.
|
# Define the body of the message.
|
||||||
@ -65,10 +41,10 @@ $messageBldr->setDeliveryTime("tomorrow 8:00AM", "PST");
|
|||||||
$messageBldr->setClickTracking(true);
|
$messageBldr->setClickTracking(true);
|
||||||
|
|
||||||
# Finally, send the message.
|
# Finally, send the message.
|
||||||
$messageBldr->sendMessage();
|
$mg->post('{$domain}/messages', $messageBldr->getMessage());
|
||||||
```
|
```
|
||||||
|
|
||||||
Available Functions (Inherits all Messages Functions)
|
Available Functions
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
|
|
||||||
`addToRecipient(string $address, array $attributes)`
|
`addToRecipient(string $address, array $attributes)`
|
||||||
@ -103,42 +79,50 @@ Available Functions (Inherits all Messages Functions)
|
|||||||
|
|
||||||
`addCustomOption(string $optionName, string $data)`
|
`addCustomOption(string $optionName, string $data)`
|
||||||
|
|
||||||
|
`addCustomParameter(string $parameterName, string $data)`
|
||||||
|
|
||||||
|
`setMessage(array $message, array $files)`
|
||||||
|
|
||||||
`getMessage()`
|
`getMessage()`
|
||||||
|
|
||||||
`getFiles()`
|
`getFiles()`
|
||||||
|
|
||||||
|
|
||||||
Usage - Batch Sending
|
Usage - Batch Message
|
||||||
---------------------
|
---------------------
|
||||||
Here's how to use the "Messages" API endpoint with Batch Sending:
|
Here's how to use Batch Message to easily handle batch sending jobs.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
# First, instantiate the client with your API credentials and domain.
|
# First, instantiate the SDK with your API credentials and define your domain.
|
||||||
$mgClient = new MailgunClient("key-3ax6xnjp29jd6fds4gc373sgvjxteol0", "samples.mailgun.org");
|
$mg = new Mailgun("key-example");
|
||||||
|
$domain = "example.com";
|
||||||
|
|
||||||
# Next, instantiate a Batch Message object on the Messages API endpoint.
|
# Next, instantiate a Message Builder object from the SDK, pass in your sending domain.
|
||||||
$batchMessage = $mgClient->Messages()->BatchMessage();
|
$batchMsg = $mg->BatchMessage($domain);
|
||||||
|
|
||||||
# Define the from address.
|
# Define the from address.
|
||||||
$batchMessage->setFromAddress("me@samples.mailgun.org", array("first"=>"PHP", "last" => "SDK"));
|
$batchMsg->setFromAddress("me@samples.mailgun.org", array("first"=>"PHP", "last" => "SDK"));
|
||||||
# Define the subject.
|
# Define the subject.
|
||||||
$batchMessage->setSubject("A Batch Message from the PHP SDK!");
|
$batchMsg->setSubject("A Batch Message from the PHP SDK!");
|
||||||
# Define the body of the message.
|
# Define the body of the message.
|
||||||
$batchMessage->setTextBody("This is the text body of the message!");
|
$batchMsg->setTextBody("This is the text body of the message!");
|
||||||
|
|
||||||
# Next, let's add a few recipients to the batch job.
|
# Next, let's add a few recipients to the batch job.
|
||||||
$batchMessage->addBatchRecipient("john.doe@samples.mailgun.org", array("first" => "John", "last" => "Doe"));
|
$batchMsg->addToRecipient("john.doe@samples.mailgun.org", array("first" => "John", "last" => "Doe"));
|
||||||
$batchMessage->addBatchRecipient("sally.doe@samples.mailgun.org", array("first" => "Sally", "last" => "Doe"));
|
$batchMsg->addToRecipient("sally.doe@samples.mailgun.org", array("first" => "Sally", "last" => "Doe"));
|
||||||
$batchMessage->addBatchRecipient("mike.jones@samples.mailgun.org", array("first" => "Mike", "last" => "Jones"));
|
$batchMsg->addToRecipient("mike.jones@samples.mailgun.org", array("first" => "Mike", "last" => "Jones"));
|
||||||
|
...
|
||||||
|
// After 1,000 recipeints, Batch Message will automatically post your message to the messages endpoint.
|
||||||
|
|
||||||
|
// Call finalize() to send any remaining recipients still in the buffer.
|
||||||
|
$batchMsg->finalize();
|
||||||
|
|
||||||
# Finally, submit the batch job.
|
|
||||||
$batchMessage->sendMessage();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Available Functions (Inherits all Batch Message and Messages Functions)
|
Available Functions (Inherits all Batch Message and Messages Functions)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
`addBatchRecipient(string $address, string $attributes)`
|
`addToRecipient(string $address, string $attributes)`
|
||||||
|
|
||||||
More Documentation
|
More Documentation
|
||||||
------------------
|
------------------
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Mailgun\Routes\Exceptions;
|
|
||||||
|
|
||||||
class InvalidParameter extends \Exception{}
|
|
||||||
|
|
||||||
?>
|
|
@ -1,38 +0,0 @@
|
|||||||
Mailgun - Routes
|
|
||||||
====================
|
|
||||||
|
|
||||||
This is the Mailgun PHP *Routes* endpoint.
|
|
||||||
|
|
||||||
The below assumes you've already installed the Mailgun PHP SDK in to your project. If not, go back to the master README for instructions.
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-------------
|
|
||||||
Here's how to use the "Routes" API endpoint:
|
|
||||||
|
|
||||||
```php
|
|
||||||
# First, instantiate the client with your PUBLIC API credentials and domain.
|
|
||||||
$mgClient = new MailgunClient("key-3ax6xnjp29jd6fds4gc373sgvjxteol0", "samples.mailgun.org");
|
|
||||||
|
|
||||||
# Next, instantiate a Routes object on the Routes API endpoint.
|
|
||||||
$routes = $mgClient->Routes();
|
|
||||||
|
|
||||||
# Next, add the new route.
|
|
||||||
$routes->addRoute(0, "Match defined recipient", "match_recipient(\"^chris\+(.*)@example.com$\")", "forward(\"mbx@externaldomain.com\")");
|
|
||||||
```
|
|
||||||
|
|
||||||
Available Functions
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
`getRoutes(int $limit, int $skip)`
|
|
||||||
|
|
||||||
`getRoute(string $routeId)`
|
|
||||||
|
|
||||||
`addRoute(int $priority, string $description, string $expression, string $action)`
|
|
||||||
|
|
||||||
`updateRoute(string $routeId, int $priority, string $description, string $expression, string $action)`
|
|
||||||
|
|
||||||
`deleteRoute(string $routeId)`
|
|
||||||
|
|
||||||
More Documentation
|
|
||||||
------------------
|
|
||||||
See the official [Mailgun Docs](http://documentation.mailgun.com/api-routes.html) for more information.
|
|
@ -1,86 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Routes.php - Processing Routes.
|
|
||||||
*/
|
|
||||||
namespace Mailgun\Routes;
|
|
||||||
|
|
||||||
use Mailgun\Routes\Exceptions\InvalidParameter;
|
|
||||||
|
|
||||||
class Routes{
|
|
||||||
|
|
||||||
private $restClient;
|
|
||||||
private $workingDomain;
|
|
||||||
private $endpointUrl;
|
|
||||||
|
|
||||||
public function __construct($restClient){
|
|
||||||
$this->restClient = $restClient;
|
|
||||||
$this->endpointUrl = "routes";
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRoutes($limit, $skip){
|
|
||||||
$response = $this->restClient->getRequest($this->endpointUrl, array($limit, $skip));
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRoute($routeId){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $routeId;
|
|
||||||
$response = $this->restClient->getRequest($updatedUrl);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addRoute($priority, $description, $expression, $action){
|
|
||||||
|
|
||||||
if(!is_int($priority) || $priority < 0){
|
|
||||||
throw new InvalidParameter("The priority is not a positive integer.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!isset($description)){
|
|
||||||
throw new InvalidParameter("The description seems to be missing.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!isset($expression)){
|
|
||||||
throw new InvalidParameter("The expression seems to be missing.");
|
|
||||||
}
|
|
||||||
if(!isset($action)){
|
|
||||||
throw new InvalidParameter("The action seems to be missing.");
|
|
||||||
}
|
|
||||||
|
|
||||||
$postData = array('priority' => $priority, 'description' => $description, 'expression' => $expression, 'action' => $action);
|
|
||||||
|
|
||||||
$response = $this->restClient->postRequest($this->endpointUrl, $postData);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateRoute($routeId, $priority, $description, $expression, $action){
|
|
||||||
if(!is_int($priority) || $priority < 0){
|
|
||||||
throw new InvalidParameter("The priority is not a positive integer.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!isset($description)){
|
|
||||||
throw new InvalidParameter("The description seems to be missing.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!isset($expression)){
|
|
||||||
throw new InvalidParameter("The expression seems to be missing.");
|
|
||||||
}
|
|
||||||
if(!isset($action)){
|
|
||||||
throw new InvalidParameter("The action seems to be missing.");
|
|
||||||
}
|
|
||||||
|
|
||||||
$postData = array('priority' => $priority, 'description' => $description, 'expression' => $expression, 'action' => $action);
|
|
||||||
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $routeId;
|
|
||||||
|
|
||||||
$response = $this->restClient->putRequest($updatedUrl, $postData);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteRoute($routeId){
|
|
||||||
$updatedUrl = $this->endpointUrl . "/" . $routeId;
|
|
||||||
$response = $this->restClient->deleteRequest($updatedUrl);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@ -1,32 +0,0 @@
|
|||||||
Mailgun - Stats
|
|
||||||
====================
|
|
||||||
|
|
||||||
This is the Mailgun PHP *Stats* endpoint.
|
|
||||||
|
|
||||||
The below assumes you've already installed the Mailgun PHP SDK in to your project. If not, go back to the master README for instructions.
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-------------
|
|
||||||
Here's how to use the "Stats" API endpoint:
|
|
||||||
|
|
||||||
```php
|
|
||||||
# First, instantiate the client with your PUBLIC API credentials and domain.
|
|
||||||
$mgClient = new MailgunClient("key-3ax6xnjp29jd6fds4gc373sgvjxteol0", "samples.mailgun.org");
|
|
||||||
|
|
||||||
# Next, instantiate a Stats object on the Stats API endpoint.
|
|
||||||
$stats = $mgClient->Stats();
|
|
||||||
|
|
||||||
# Next, get the last 50 stats.
|
|
||||||
$stats->getStats(array('limit' => 50, 'skip' => 0, 'event' => 'sent'));
|
|
||||||
```
|
|
||||||
|
|
||||||
Available Functions
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
`deleteTag(string $tag)`
|
|
||||||
|
|
||||||
`getStats(array $filterParams)`
|
|
||||||
|
|
||||||
More Documentation
|
|
||||||
------------------
|
|
||||||
See the official [Mailgun Docs](http://documentation.mailgun.com/api-stats.html) for more information.
|
|
@ -1,32 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Stats.php - Processing Stats.
|
|
||||||
*/
|
|
||||||
namespace Mailgun\Stats;
|
|
||||||
|
|
||||||
class Stats{
|
|
||||||
|
|
||||||
private $restClient;
|
|
||||||
private $workingDomain;
|
|
||||||
private $endpointUrl;
|
|
||||||
private $statsEndpointUrl;
|
|
||||||
private $tagEndpointUrl;
|
|
||||||
|
|
||||||
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->restClient->deleteRequest($requestUrl);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getStats($filterParams = array()){
|
|
||||||
$response = $this->restClient->getRequest($this->statsEndpointUrl, $filterParams);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
Mailgun - Unsubscribes
|
|
||||||
======================
|
|
||||||
|
|
||||||
This is the Mailgun PHP *Unsubscribes* endpoint.
|
|
||||||
|
|
||||||
The below assumes you've already installed the Mailgun PHP SDK in to your project. If not, go back to the master README for instructions.
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-------------
|
|
||||||
Here's how to use the "Unsubscribes" API endpoint:
|
|
||||||
|
|
||||||
```php
|
|
||||||
# First, instantiate the client with your PUBLIC API credentials and domain.
|
|
||||||
$mgClient = new MailgunClient("key-3ax6xnjp29jd6fds4gc373sgvjxteol0", "samples.mailgun.org");
|
|
||||||
|
|
||||||
# Next, instantiate a Unsubscribes object on the Unsubscribes API endpoint.
|
|
||||||
$unsubscribe = $mgClient->Unsubscribes();
|
|
||||||
|
|
||||||
# Next, unsubscribe the address from the weekly-emails tag.
|
|
||||||
$unsubscribe->addAddress("removeme@samples.mailgun.org", "weekly-emails");
|
|
||||||
```
|
|
||||||
|
|
||||||
Available Functions
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
`addAddress(string $unsubAddress, string $unsubTag)`
|
|
||||||
|
|
||||||
`deleteAddress(string $unsubAddress)`
|
|
||||||
|
|
||||||
`getUnsubscribe(string $unsubAddress)`
|
|
||||||
|
|
||||||
`getUnsubscribes(int $limit, int $skip)`
|
|
||||||
|
|
||||||
|
|
||||||
More Documentation
|
|
||||||
------------------
|
|
||||||
See the official [Mailgun Docs](http://documentation.mailgun.com/api-unsubscribes.html) for more information.
|
|
@ -1,46 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Unsubscribe.php - Processing unsubscribes.
|
|
||||||
*/
|
|
||||||
namespace Mailgun\Unsubscribes;
|
|
||||||
|
|
||||||
class Unsubscribes{
|
|
||||||
|
|
||||||
private $restClient;
|
|
||||||
private $workingDomain;
|
|
||||||
private $endpointUrl;
|
|
||||||
|
|
||||||
public function __construct($restClient){
|
|
||||||
$this->restClient = $restClient;
|
|
||||||
$this->endpointUrl = $this->restClient->returnWorkingDomain() . "/unsubscribes";
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addAddress($unsubAddress, $unsubTag = NULL){
|
|
||||||
if(isset($unsubTag)){
|
|
||||||
$postData = array("address" => $unsubAddress, "tag" => $unsubTag);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$postData = array("address" => $unsubAddress, "tag" => "*");
|
|
||||||
}
|
|
||||||
$response = $this->restClient->postRequest($this->endpointUrl, $postData);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteAddress($unsubAddress){
|
|
||||||
$requestUrl = $this->endpointUrl . "/" . urlencode($unsubAddress);
|
|
||||||
$response = $this->restClient->deleteRequest($requestUrl);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUnsubscribe($unsubAddress){
|
|
||||||
$requestUrl = $this->endpointUrl . "/" . urlencode($unsubAddress);
|
|
||||||
$response = $this->restClient->getRequest($requestUrl);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
public function getUnsubscribes($limit, $skip){
|
|
||||||
$response = $this->restClient->getRequest($this->endpointUrl, array($limit, $skip));
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
16
test.php
Normal file
16
test.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?PHP
|
||||||
|
|
||||||
|
class Test{
|
||||||
|
|
||||||
|
public function __call($name, $arguments){
|
||||||
|
return array($name => $arguments);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$test = new Test();
|
||||||
|
|
||||||
|
var_dump($test->olakwnfelkajweklfjlwkjelkmg("Asdfasdf"));
|
||||||
|
|
||||||
|
?>
|
@ -1,22 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
namespace Mailgun\Tests\Address;
|
|
||||||
|
|
||||||
use Mailgun\Tests\MailgunClientTest;
|
|
||||||
|
|
||||||
class AddressTest extends \Mailgun\Tests\MailgunTestCase{
|
|
||||||
|
|
||||||
private $client;
|
|
||||||
|
|
||||||
public function setUp(){
|
|
||||||
$this->client = new MailgunClientTest("My-Super-Awesome-API-Key", "samples.mailgun.org", false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testValidateAddress(){
|
|
||||||
$client = $this->client->Address();
|
|
||||||
$response = $client->validateAddress("addressvalidation@mailgun.com");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
namespace Mailgun\Tests\Bounces;
|
|
||||||
|
|
||||||
use Mailgun\Tests\MailgunClientTest;
|
|
||||||
|
|
||||||
class BouncesTest extends \Mailgun\Tests\MailgunTestCase{
|
|
||||||
|
|
||||||
private $client;
|
|
||||||
|
|
||||||
public function setUp(){
|
|
||||||
$this->client = new MailgunClientTest("My-Super-Awesome-API-Key", "samples.mailgun.org", false);
|
|
||||||
|
|
||||||
}
|
|
||||||
public function testAddAddress(){
|
|
||||||
$client = $this->client->Bounces();
|
|
||||||
$response = $client->addAddress("test@samples.mailgun.org", 550, "This bounced!");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
public function testDeleteAddress(){
|
|
||||||
$client = $this->client->Bounces();
|
|
||||||
$response = $client->deleteAddress("test@samples.mailgun.org");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
public function testGetAddress(){
|
|
||||||
$client = $this->client->Bounces();
|
|
||||||
$response = $client->getBounce("test@samples.mailgun.org");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
public function testGetAddresses(){
|
|
||||||
$client = $this->client->Bounces();
|
|
||||||
$response = $client->getBounces("1", "30");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
namespace Mailgun\Tests\Campaigns;
|
|
||||||
|
|
||||||
use Mailgun\Tests\MailgunClientTest;
|
|
||||||
|
|
||||||
class CampaignsTest extends \Mailgun\Tests\MailgunTestCase{
|
|
||||||
|
|
||||||
private $client;
|
|
||||||
|
|
||||||
public function setUp(){
|
|
||||||
$this->client = new MailgunClientTest("My-Super-Awesome-API-Key", "samples.mailgun.org", false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetCampaigns(){
|
|
||||||
$client = $this->client->Campaigns();
|
|
||||||
$response = $client->getCampaigns("1", "30");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetCampaign(){
|
|
||||||
$client = $this->client->Campaigns();
|
|
||||||
$response = $client->getCampaign(12345);
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAddCampaign(){
|
|
||||||
$client = $this->client->Campaigns();
|
|
||||||
$response = $client->addCampaign("MyCampaign", "TheID");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUpdateCampaign(){
|
|
||||||
$client = $this->client->Campaigns();
|
|
||||||
$response = $client->updateCampaign(12345, "MyCampaign", "TheID");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDeleteCampaign(){
|
|
||||||
$client = $this->client->Campaigns();
|
|
||||||
$response = $client->deleteCampaign(12345);
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetCampaignEvents(){
|
|
||||||
$client = $this->client->Campaigns();
|
|
||||||
$response = $client->getCampaignEvents(12345, array());
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetCampaignStats(){
|
|
||||||
$client = $this->client->Campaigns();
|
|
||||||
$response = $client->getCampaignStats(12345, array());
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetCampaignClicks(){
|
|
||||||
$client = $this->client->Campaigns();
|
|
||||||
$response = $client->getCampaignClicks(12345, array());
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetCampaignOpens(){
|
|
||||||
$client = $this->client->Campaigns();
|
|
||||||
$response = $client->getCampaignOpens(12345, array());
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
namespace Mailgun\Tests\Complaints;
|
|
||||||
|
|
||||||
use Mailgun\Tests\MailgunClientTest;
|
|
||||||
|
|
||||||
class ComplaintsTest extends \Mailgun\Tests\MailgunTestCase{
|
|
||||||
|
|
||||||
private $client;
|
|
||||||
|
|
||||||
public function setUp(){
|
|
||||||
$this->client = new MailgunClientTest("My-Super-Awesome-API-Key", "samples.mailgun.org", false);
|
|
||||||
|
|
||||||
}
|
|
||||||
public function testAddAddress(){
|
|
||||||
$client = $this->client->Complaints();
|
|
||||||
$response = $client->addAddress("test@samples.mailgun.org");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
public function testDeleteAddress(){
|
|
||||||
$client = $this->client->Complaints();
|
|
||||||
$response = $client->deleteAddress("test@samples.mailgun.org");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
public function testGetAddress(){
|
|
||||||
$client = $this->client->Complaints();
|
|
||||||
$response = $client->getComplaint("test@samples.mailgun.org");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
public function testGetAddresses(){
|
|
||||||
$client = $this->client->Complaints();
|
|
||||||
$response = $client->getComplaints("1", "30");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
namespace Mailgun\Tests\Connection;
|
namespace Mailgun\Tests\Connection;
|
||||||
|
|
||||||
use Mailgun\Tests\MailgunClientTest;
|
use Mailgun\Tests\MailgunTest;
|
||||||
|
|
||||||
class ConnectionTest extends \Mailgun\Tests\MailgunTestCase{
|
class ConnectionTest extends \Mailgun\Tests\MailgunTestCase{
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ class ConnectionTest extends \Mailgun\Tests\MailgunTestCase{
|
|||||||
public function setUp(){
|
public function setUp(){
|
||||||
}
|
}
|
||||||
public function testNewClientInstantiation(){
|
public function testNewClientInstantiation(){
|
||||||
$this->client = new MailgunClientTest("My-Super-Awesome-API-Key", "samples.mailgun.org", false);
|
$this->client = new MailgunTest("My-Super-Awesome-API-Key", "samples.mailgun.org", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,19 +5,16 @@ use Mailgun\Connection\RestClient;
|
|||||||
|
|
||||||
class TestBroker extends RestClient{
|
class TestBroker extends RestClient{
|
||||||
private $apiKey;
|
private $apiKey;
|
||||||
protected $domain;
|
|
||||||
protected $debug;
|
|
||||||
|
|
||||||
protected $apiEndpoint = API_ENDPOINT;
|
protected $apiEndpoint;
|
||||||
protected $apiVersion = API_VERSION;
|
protected $apiVersion = API_VERSION;
|
||||||
protected $apiUser = API_USER;
|
protected $apiUser = API_USER;
|
||||||
protected $sdkVersion = SDK_VERSION;
|
protected $sdkVersion = SDK_VERSION;
|
||||||
protected $sdkUserAgent = SDK_USER_AGENT;
|
protected $sdkUserAgent = SDK_USER_AGENT;
|
||||||
|
|
||||||
public function __construct($apiKey, $domain, $debug = false){
|
public function __construct($apiKey = null, $apiEndpoint = "api.mailgun.net"){
|
||||||
$this->apiKey = $apiKey;
|
$this->apiKey = $apiKey;
|
||||||
$this->domain = $domain;
|
$this->apiEndpoint = $apiEndpoint;
|
||||||
$this->debug = $debug;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function postRequest($endpointUrl, $postData = array(), $files = array()){
|
public function postRequest($endpointUrl, $postData = array(), $files = array()){
|
||||||
|
@ -1,92 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
namespace Mailgun\Tests\Lists;
|
|
||||||
|
|
||||||
use Mailgun\Tests\MailgunClientTest;
|
|
||||||
|
|
||||||
class ListsTest extends \Mailgun\Tests\MailgunTestCase{
|
|
||||||
|
|
||||||
private $client;
|
|
||||||
|
|
||||||
public function setUp(){
|
|
||||||
$this->client = new MailgunClientTest("My-Super-Awesome-API-Key", "samples.mailgun.org", false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetLists(){
|
|
||||||
$client = $this->client->Lists();
|
|
||||||
$response = $client->getLists("1", "30");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetList(){
|
|
||||||
$client = $this->client->Lists();
|
|
||||||
$response = $client->getList("mylist@mailgun.org");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAddList(){
|
|
||||||
$client = $this->client->Lists();
|
|
||||||
$response = $client->addList("mylist@mailgun.org", "My Sample List", "More Description Stuff", "readonly");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUpdateList(){
|
|
||||||
$client = $this->client->Lists();
|
|
||||||
$response = $client->updateList("mylist@mailgun.org", "My Sample List", "More Description Stuff", "readonly");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDeleteList(){
|
|
||||||
$client = $this->client->Lists();
|
|
||||||
$response = $client->deleteList(12345);
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetListMembers(){
|
|
||||||
$client = $this->client->Lists();
|
|
||||||
$response = $client->getListMembers("mylist@mailgun.org", array('subscribed'=>true, 'limit' => 50, 'skip' => 50));
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetListMember(){
|
|
||||||
$client = $this->client->Lists();
|
|
||||||
$response = $client->getListMember("mylist@mailgun.org", "subscribee@mailgun.org");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAddListMember(){
|
|
||||||
$client = $this->client->Lists();
|
|
||||||
$response = $client->getListMember("mylist@mailgun.org", "subscribee@mailgun.org", "Sample User", array('userid' => 'ABC123'), true, true);
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUpdateListMember(){
|
|
||||||
$client = $this->client->Lists();
|
|
||||||
$response = $client->updateListMember("mylist@mailgun.org", "subscribee@mailgun.org", "Sample User", array('userid' => 'ABC123'), true);
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDeleteListMember(){
|
|
||||||
$client = $this->client->Lists();
|
|
||||||
$response = $client->deleteListMember("mylist@mailgun.org", "subscribee@mailgun.org");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetListStats(){
|
|
||||||
$client = $this->client->Lists();
|
|
||||||
$response = $client->getListStats("mylist@mailgun.org");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
namespace Mailgun\Tests\Logs;
|
|
||||||
|
|
||||||
use Mailgun\Tests\MailgunClientTest;
|
|
||||||
|
|
||||||
class LogsTest extends \Mailgun\Tests\MailgunTestCase{
|
|
||||||
|
|
||||||
private $client;
|
|
||||||
|
|
||||||
public function setUp(){
|
|
||||||
$this->client = new MailgunClientTest("My-Super-Awesome-API-Key", "samples.mailgun.org", false);
|
|
||||||
|
|
||||||
}
|
|
||||||
public function testGetLogs(){
|
|
||||||
$client = $this->client->Logs();
|
|
||||||
$response = $client->getLogs("1", "30");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
namespace Mailgun\Tests;
|
|
||||||
|
|
||||||
use Mailgun\MailgunClient;
|
|
||||||
use Mailgun\Tests\Connection\TestBroker;
|
|
||||||
|
|
||||||
class MailgunClientTest extends MailgunClient
|
|
||||||
{
|
|
||||||
protected $debug;
|
|
||||||
protected $restClient;
|
|
||||||
|
|
||||||
public function __construct($apiKey, $domain, $debug = false){
|
|
||||||
$this->restClient = new TestBroker($apiKey, $domain, $debug);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
20
tests/Mailgun/Tests/MailgunTest.php
Normal file
20
tests/Mailgun/Tests/MailgunTest.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?PHP
|
||||||
|
|
||||||
|
namespace Mailgun\Tests;
|
||||||
|
|
||||||
|
use Mailgun\Mailgun;
|
||||||
|
use Mailgun\Tests\Connection\TestBroker;
|
||||||
|
|
||||||
|
class MailgunTest extends Mailgun
|
||||||
|
{
|
||||||
|
protected $debug;
|
||||||
|
protected $restClient;
|
||||||
|
|
||||||
|
public function __construct($apiKey = null, $apiEndpoint = "api.mailgun.net"){
|
||||||
|
$this->restClient = new TestBroker($apiKey, $apiEndpoint);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -1,47 +1,48 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
namespace Mailgun\Tests\BatchMessage;
|
namespace Mailgun\Tests\BatchMessage;
|
||||||
|
|
||||||
use Mailgun\Tests\MailgunClientTest;
|
use Mailgun\Tests\MailgunTest;
|
||||||
|
|
||||||
class BatchMessageTest extends \Mailgun\Tests\MailgunTestCase{
|
class BatchMessageTest extends \Mailgun\Tests\MailgunTestCase{
|
||||||
|
|
||||||
private $client;
|
private $client;
|
||||||
|
private $sampleDomain = "samples.mailgun.org";
|
||||||
|
|
||||||
public function setUp(){
|
public function setUp(){
|
||||||
$this->client = new MailgunClientTest("My-Super-Awesome-API-Key", "samples.mailgun.org", false);
|
$this->client = new MailgunTest("My-Super-Awesome-API-Key");
|
||||||
}
|
}
|
||||||
public function testBlankInstantiation(){
|
public function testBlankInstantiation(){
|
||||||
$message = $this->client->Messages()->BatchMessage();
|
$message = $this->client->BatchMessage($this->sampleDomain);
|
||||||
$this->assertTrue(is_array($message->getMessage()));
|
$this->assertTrue(is_array($message->getMessage()));
|
||||||
}
|
}
|
||||||
public function testAddBatchRecipient(){
|
public function testaddToRecipient(){
|
||||||
$message = $this->client->Messages()->BatchMessage();
|
$message = $this->client->BatchMessage($this->sampleDomain);
|
||||||
$message->addBatchRecipient("test@samples.mailgun.org", array("first" => "Test", "last" => "User"));
|
$message->addToRecipient("test@samples.mailgun.org", array("first" => "Test", "last" => "User"));
|
||||||
$messageObj= $message->getMessage();
|
$messageObj= $message->getMessage();
|
||||||
$this->assertEquals(array("to" => array("Test User <test@samples.mailgun.org>")), $messageObj);
|
$this->assertEquals(array("to" => array("Test User <test@samples.mailgun.org>")), $messageObj);
|
||||||
}
|
}
|
||||||
public function testAddMultipleBatchRecipients(){
|
public function testAddMultipleBatchRecipients(){
|
||||||
$message = $this->client->Messages()->BatchMessage();
|
$message = $this->client->BatchMessage($this->sampleDomain);
|
||||||
for($i=0; $i<100; $i++){
|
for($i=0; $i<100; $i++){
|
||||||
$message->addBatchRecipient("$i@samples.mailgun.org", array("first" => "Test", "last" => "User $i"));
|
$message->addToRecipient("$i@samples.mailgun.org", array("first" => "Test", "last" => "User $i"));
|
||||||
}
|
}
|
||||||
$messageObj= $message->getMessage();
|
$messageObj= $message->getMessage();
|
||||||
$this->assertEquals(100, count($messageObj["to"]));
|
$this->assertEquals(100, count($messageObj["to"]));
|
||||||
}
|
}
|
||||||
public function testMaximumBatchSize(){
|
public function testMaximumBatchSize(){
|
||||||
$message = $this->client->Messages()->BatchMessage();
|
$message = $this->client->BatchMessage($this->sampleDomain);
|
||||||
$message->setFromAddress("samples@mailgun.org", array("first" => "Test", "last" => "User"));
|
$message->setFromAddress("samples@mailgun.org", array("first" => "Test", "last" => "User"));
|
||||||
$message->setSubject("This is the subject of the message!");
|
$message->setSubject("This is the subject of the message!");
|
||||||
$message->setTextBody("This is the text body of the message!");
|
$message->setTextBody("This is the text body of the message!");
|
||||||
for($i=0; $i<1001; $i++){
|
for($i=0; $i<1001; $i++){
|
||||||
$message->addBatchRecipient("$i@samples.mailgun.org", array("first" => "Test", "last" => "User $i"));
|
$message->addToRecipient("$i@samples.mailgun.org", array("first" => "Test", "last" => "User $i"));
|
||||||
}
|
}
|
||||||
$messageObj= $message->getMessage();
|
$messageObj= $message->getMessage();
|
||||||
$this->assertEquals(1, count($messageObj["to"]));
|
$this->assertEquals(1, count($messageObj["to"]));
|
||||||
}
|
}
|
||||||
public function testResetOnEndBatchMessage(){
|
public function testResetOnEndBatchMessage(){
|
||||||
$message = $this->client->Messages()->BatchMessage();
|
$message = $this->client->BatchMessage($this->sampleDomain);
|
||||||
$message->addBatchRecipient("test-user@samples.mailgun.org", array("first" => "Test", "last" => "User"));
|
$message->addToRecipient("test-user@samples.mailgun.org", array("first" => "Test", "last" => "User"));
|
||||||
$message->setFromAddress("samples@mailgun.org", array("first" => "Test", "last" => "User"));
|
$message->setFromAddress("samples@mailgun.org", array("first" => "Test", "last" => "User"));
|
||||||
$message->setSubject("This is the subject of the message!");
|
$message->setSubject("This is the subject of the message!");
|
||||||
$message->setTextBody("This is the text body of the message!");
|
$message->setTextBody("This is the text body of the message!");
|
||||||
|
@ -1,83 +1,83 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
namespace Mailgun\Tests\Message;
|
namespace Mailgun\Tests\Message;
|
||||||
|
|
||||||
use Mailgun\Tests\MailgunClientTest;
|
use Mailgun\Tests\MailgunTest;
|
||||||
|
|
||||||
class MessageBuilderTest extends \Mailgun\Tests\MailgunTestCase{
|
class MessageBuilderTest extends \Mailgun\Tests\MailgunTestCase{
|
||||||
private $client;
|
private $client;
|
||||||
|
|
||||||
public function setUp(){
|
public function setUp(){
|
||||||
$this->client = new MailgunClientTest("My-Super-Awesome-API-Key", "samples.mailgun.org", false);
|
$this->client = new MailgunTest("My-Super-Awesome-API-Key", "samples.mailgun.org", false);
|
||||||
}
|
}
|
||||||
public function testBlankInstantiation(){
|
public function testBlankInstantiation(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$this->assertTrue(is_array($message->getMessage()));
|
$this->assertTrue(is_array($message->getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddToRecipient(){
|
public function testAddToRecipient(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->addToRecipient("test@samples.mailgun.org", array("first" => "Test", "last" => "User"));
|
$message->addToRecipient("test@samples.mailgun.org", array("first" => "Test", "last" => "User"));
|
||||||
$messageObj = $message->getMessage();
|
$messageObj = $message->getMessage();
|
||||||
$this->assertEquals(array("to" => array("Test User <test@samples.mailgun.org>")), $messageObj);
|
$this->assertEquals(array("to" => array("Test User <test@samples.mailgun.org>")), $messageObj);
|
||||||
}
|
}
|
||||||
public function testAddCcRecipient(){
|
public function testAddCcRecipient(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->addCcRecipient("test@samples.mailgun.org", array("first" => "Test", "last" => "User"));
|
$message->addCcRecipient("test@samples.mailgun.org", array("first" => "Test", "last" => "User"));
|
||||||
$messageObj = $message->getMessage();
|
$messageObj = $message->getMessage();
|
||||||
$this->assertEquals(array("cc" => array("Test User <test@samples.mailgun.org>")), $messageObj);
|
$this->assertEquals(array("cc" => array("Test User <test@samples.mailgun.org>")), $messageObj);
|
||||||
}
|
}
|
||||||
public function testAddBccRecipient(){
|
public function testAddBccRecipient(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->addBccRecipient("test@samples.mailgun.org", array("first" => "Test", "last" => "User"));
|
$message->addBccRecipient("test@samples.mailgun.org", array("first" => "Test", "last" => "User"));
|
||||||
$messageObj = $message->getMessage();
|
$messageObj = $message->getMessage();
|
||||||
$this->assertEquals(array("bcc" => array("Test User <test@samples.mailgun.org>")), $messageObj);
|
$this->assertEquals(array("bcc" => array("Test User <test@samples.mailgun.org>")), $messageObj);
|
||||||
}
|
}
|
||||||
public function testSetFromAddress(){
|
public function testSetFromAddress(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->setFromAddress("test@samples.mailgun.org", array("first" => "Test", "last" => "User"));
|
$message->setFromAddress("test@samples.mailgun.org", array("first" => "Test", "last" => "User"));
|
||||||
$messageObj = $message->getMessage();
|
$messageObj = $message->getMessage();
|
||||||
$this->assertEquals(array("from" => "Test User <test@samples.mailgun.org>"), $messageObj);
|
$this->assertEquals(array("from" => "Test User <test@samples.mailgun.org>"), $messageObj);
|
||||||
}
|
}
|
||||||
public function testSetSubject(){
|
public function testSetSubject(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->setSubject("Test Subject");
|
$message->setSubject("Test Subject");
|
||||||
$messageObj = $message->getMessage();
|
$messageObj = $message->getMessage();
|
||||||
$this->assertEquals(array("subject" => "Test Subject"), $messageObj);
|
$this->assertEquals(array("subject" => "Test Subject"), $messageObj);
|
||||||
}
|
}
|
||||||
public function testAddCustomHeader(){
|
public function testAddCustomHeader(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->addCustomHeader("My-Header", "123");
|
$message->addCustomHeader("My-Header", "123");
|
||||||
$messageObj = $message->getMessage();
|
$messageObj = $message->getMessage();
|
||||||
$this->assertEquals(array("h:My-Header" => array("123")), $messageObj);
|
$this->assertEquals(array("h:My-Header" => array("123")), $messageObj);
|
||||||
}
|
}
|
||||||
public function testSetTextBody(){
|
public function testSetTextBody(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->setTextBody("This is the text body!");
|
$message->setTextBody("This is the text body!");
|
||||||
$messageObj = $message->getMessage();
|
$messageObj = $message->getMessage();
|
||||||
$this->assertEquals(array("text" => "This is the text body!"), $messageObj);
|
$this->assertEquals(array("text" => "This is the text body!"), $messageObj);
|
||||||
}
|
}
|
||||||
public function testSetHtmlBody(){
|
public function testSetHtmlBody(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->setHtmlBody("<html><body>This is an awesome email</body></html>");
|
$message->setHtmlBody("<html><body>This is an awesome email</body></html>");
|
||||||
$messageObj = $message->getMessage();
|
$messageObj = $message->getMessage();
|
||||||
$this->assertEquals(array("html" => "<html><body>This is an awesome email</body></html>"), $messageObj);
|
$this->assertEquals(array("html" => "<html><body>This is an awesome email</body></html>"), $messageObj);
|
||||||
}
|
}
|
||||||
public function testAddAttachments(){
|
public function testAddAttachments(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->addAttachment("@../TestAssets/mailgun_icon.png");
|
$message->addAttachment("@../TestAssets/mailgun_icon.png");
|
||||||
$message->addAttachment("@../TestAssets/rackspace_logo.png");
|
$message->addAttachment("@../TestAssets/rackspace_logo.png");
|
||||||
$messageObj = $message->getFiles();
|
$messageObj = $message->getFiles();
|
||||||
$this->assertEquals(array("attachment" => array("@../TestAssets/mailgun_icon.png", "@../TestAssets/rackspace_logo.png")), $messageObj);
|
$this->assertEquals(array("attachment" => array("@../TestAssets/mailgun_icon.png", "@../TestAssets/rackspace_logo.png")), $messageObj);
|
||||||
}
|
}
|
||||||
public function testAddInlineImages(){
|
public function testAddInlineImages(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->addInlineImage("@../TestAssets/mailgun_icon.png");
|
$message->addInlineImage("@../TestAssets/mailgun_icon.png");
|
||||||
$message->addInlineImage("@../TestAssets/rackspace_logo.png");
|
$message->addInlineImage("@../TestAssets/rackspace_logo.png");
|
||||||
$messageObj = $message->getFiles();
|
$messageObj = $message->getFiles();
|
||||||
$this->assertEquals(array("inline" => array("@../TestAssets/mailgun_icon.png", "@../TestAssets/rackspace_logo.png")), $messageObj);
|
$this->assertEquals(array("inline" => array("@../TestAssets/mailgun_icon.png", "@../TestAssets/rackspace_logo.png")), $messageObj);
|
||||||
}
|
}
|
||||||
public function testsetTestMode(){
|
public function testsetTestMode(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->setTestMode(true);
|
$message->setTestMode(true);
|
||||||
$messageObj = $message->getMessage();
|
$messageObj = $message->getMessage();
|
||||||
$this->assertEquals(array("o:testmode" => "yes"), $messageObj);
|
$this->assertEquals(array("o:testmode" => "yes"), $messageObj);
|
||||||
@ -92,7 +92,7 @@ class MessageBuilderTest extends \Mailgun\Tests\MailgunTestCase{
|
|||||||
$this->assertEquals(array("o:testmode" => "no"), $messageObj);
|
$this->assertEquals(array("o:testmode" => "no"), $messageObj);
|
||||||
}
|
}
|
||||||
public function addCampaignId(){
|
public function addCampaignId(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->addCampaignId("ABC123");
|
$message->addCampaignId("ABC123");
|
||||||
$message->addCampaignId("XYZ987");
|
$message->addCampaignId("XYZ987");
|
||||||
$message->addCampaignId("TUV456");
|
$message->addCampaignId("TUV456");
|
||||||
@ -101,7 +101,7 @@ class MessageBuilderTest extends \Mailgun\Tests\MailgunTestCase{
|
|||||||
$this->assertEquals(array("o:campaign" => array("ABC123", "XYZ987", "TUV456")), $messageObj);
|
$this->assertEquals(array("o:campaign" => array("ABC123", "XYZ987", "TUV456")), $messageObj);
|
||||||
}
|
}
|
||||||
public function testSetDkim(){
|
public function testSetDkim(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->setDkim(true);
|
$message->setDkim(true);
|
||||||
$messageObj = $message->getMessage();
|
$messageObj = $message->getMessage();
|
||||||
$this->assertEquals(array("o:dkim" => "yes"), $messageObj);
|
$this->assertEquals(array("o:dkim" => "yes"), $messageObj);
|
||||||
@ -116,7 +116,7 @@ class MessageBuilderTest extends \Mailgun\Tests\MailgunTestCase{
|
|||||||
$this->assertEquals(array("o:dkim" => "no"), $messageObj);
|
$this->assertEquals(array("o:dkim" => "no"), $messageObj);
|
||||||
}
|
}
|
||||||
public function testSetClickTracking(){
|
public function testSetClickTracking(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->setClickTracking(true);
|
$message->setClickTracking(true);
|
||||||
$messageObj = $message->getMessage();
|
$messageObj = $message->getMessage();
|
||||||
$this->assertEquals(array("o:tracking-clicks" => "yes"), $messageObj);
|
$this->assertEquals(array("o:tracking-clicks" => "yes"), $messageObj);
|
||||||
@ -131,7 +131,7 @@ class MessageBuilderTest extends \Mailgun\Tests\MailgunTestCase{
|
|||||||
$this->assertEquals(array("o:tracking-clicks" => "no"), $messageObj);
|
$this->assertEquals(array("o:tracking-clicks" => "no"), $messageObj);
|
||||||
}
|
}
|
||||||
public function testSetOpenTracking(){
|
public function testSetOpenTracking(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->setOpenTracking(true);
|
$message->setOpenTracking(true);
|
||||||
$messageObj = $message->getMessage();
|
$messageObj = $message->getMessage();
|
||||||
$this->assertEquals(array("o:tracking-opens" => "yes"), $messageObj);
|
$this->assertEquals(array("o:tracking-opens" => "yes"), $messageObj);
|
||||||
@ -146,7 +146,7 @@ class MessageBuilderTest extends \Mailgun\Tests\MailgunTestCase{
|
|||||||
$this->assertEquals(array("o:tracking-opens" => "no"), $messageObj);
|
$this->assertEquals(array("o:tracking-opens" => "no"), $messageObj);
|
||||||
}
|
}
|
||||||
public function testSetDeliveryTime(){
|
public function testSetDeliveryTime(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->setDeliveryTime("January 15, 2014 8:00AM", "CST");
|
$message->setDeliveryTime("January 15, 2014 8:00AM", "CST");
|
||||||
$messageObj = $message->getMessage();
|
$messageObj = $message->getMessage();
|
||||||
$this->assertEquals(array("o:deliverytime" => "Wed, 15 Jan 2014 08:00:00 -0600"), $messageObj);
|
$this->assertEquals(array("o:deliverytime" => "Wed, 15 Jan 2014 08:00:00 -0600"), $messageObj);
|
||||||
@ -161,13 +161,13 @@ class MessageBuilderTest extends \Mailgun\Tests\MailgunTestCase{
|
|||||||
$this->assertEquals(array("o:deliverytime" => "Sat, 06 Jul 2013 08:00:00 -0500"), $messageObj);
|
$this->assertEquals(array("o:deliverytime" => "Sat, 06 Jul 2013 08:00:00 -0500"), $messageObj);
|
||||||
}
|
}
|
||||||
public function testAddCustomData(){
|
public function testAddCustomData(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->addCustomData("My-Super-Awesome-Data", array("What" => "Mailgun Rocks!"));
|
$message->addCustomData("My-Super-Awesome-Data", array("What" => "Mailgun Rocks!"));
|
||||||
$messageObj = $message->getMessage();
|
$messageObj = $message->getMessage();
|
||||||
$this->assertEquals(array("v:My-Super-Awesome-Data" => "{\"What\":\"Mailgun Rocks!\"}"), $messageObj);
|
$this->assertEquals(array("v:My-Super-Awesome-Data" => "{\"What\":\"Mailgun Rocks!\"}"), $messageObj);
|
||||||
}
|
}
|
||||||
public function testAddCustomOption(){
|
public function testAddCustomOption(){
|
||||||
$message = $this->client->Messages()->MessageBuilder();
|
$message = $this->client->MessageBuilder();
|
||||||
$message->addCustomOption("my-option", "yes");
|
$message->addCustomOption("my-option", "yes");
|
||||||
$message->addCustomOption("o:my-other-option", "no");
|
$message->addCustomOption("o:my-other-option", "no");
|
||||||
$messageObj = $message->getMessage();
|
$messageObj = $message->getMessage();
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
namespace Mailgun\Tests\Routes;
|
|
||||||
|
|
||||||
use Mailgun\Tests\MailgunClientTest;
|
|
||||||
|
|
||||||
class RoutesTest extends \Mailgun\Tests\MailgunTestCase{
|
|
||||||
|
|
||||||
private $client;
|
|
||||||
|
|
||||||
public function setUp(){
|
|
||||||
$this->client = new MailgunClientTest("My-Super-Awesome-API-Key", "samples.mailgun.org", false);
|
|
||||||
|
|
||||||
}
|
|
||||||
public function testAddRoute(){
|
|
||||||
$client = $this->client->Routes();
|
|
||||||
$response = $client->addRoute(10, "This is the description", "match_recipient('.*@gmail.com')", "forward('alex@mailgun.net')");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
public function testDeleteRoute(){
|
|
||||||
$client = $this->client->Routes();
|
|
||||||
$response = $client->deleteRoute(12345);
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
public function testGetRoute(){
|
|
||||||
$client = $this->client->Routes();
|
|
||||||
$response = $client->getRoute(12345);
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
public function testGetRoutes(){
|
|
||||||
$client = $this->client->Routes();
|
|
||||||
$response = $client->getRoutes("5", "10");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
public function testUpdateRoute(){
|
|
||||||
$client = $this->client->Routes();
|
|
||||||
$response = $client->updateRoute(12345, 10, "This is the description", "match_recipient('.*@gmail.com')", "forward('alex@mailgun.net')");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
namespace Mailgun\Tests\Stats;
|
|
||||||
|
|
||||||
use Mailgun\Tests\MailgunClientTest;
|
|
||||||
|
|
||||||
class StatsTest extends \Mailgun\Tests\MailgunTestCase{
|
|
||||||
|
|
||||||
private $client;
|
|
||||||
|
|
||||||
public function setUp(){
|
|
||||||
$this->client = new MailgunClientTest("My-Super-Awesome-API-Key", "samples.mailgun.org", false);
|
|
||||||
|
|
||||||
}
|
|
||||||
public function testDeleteTag(){
|
|
||||||
$client = $this->client->Stats();
|
|
||||||
$response = $client->deleteTag("My-Tag");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
public function testGetStats(){
|
|
||||||
$client = $this->client->Stats();
|
|
||||||
$response = $client->getStats("1", "30", "Sent", "10/10/10");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
<?PHP
|
|
||||||
|
|
||||||
namespace Mailgun\Tests\Unsubscribes;
|
|
||||||
|
|
||||||
use Mailgun\Tests\MailgunClientTest;
|
|
||||||
|
|
||||||
class UnsubscribeTest extends \Mailgun\Tests\MailgunTestCase{
|
|
||||||
|
|
||||||
private $client;
|
|
||||||
|
|
||||||
public function setUp(){
|
|
||||||
$this->client = new MailgunClientTest("My-Super-Awesome-API-Key", "samples.mailgun.org", false);
|
|
||||||
|
|
||||||
}
|
|
||||||
public function testAddAddress(){
|
|
||||||
$client = $this->client->Unsubscribes();
|
|
||||||
$response = $client->addAddress("test@samples.mailgun.org");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
public function testDeleteAddress(){
|
|
||||||
$client = $this->client->Unsubscribes();
|
|
||||||
$response = $client->deleteAddress("test@samples.mailgun.org");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
public function testGetAddress(){
|
|
||||||
$client = $this->client->Unsubscribes();
|
|
||||||
$response = $client->getUnsubscribe("test@samples.mailgun.org");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
public function testGetAddresses(){
|
|
||||||
$client = $this->client->Unsubscribes();
|
|
||||||
$response = $client->getUnsubscribes("1", "30");
|
|
||||||
$httpCode = $response->http_response_code;
|
|
||||||
$this->assertEquals(200, $httpCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user