mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-23 21:16:02 +03:00
Apply fixes from StyleCI and make sure we add MIT license properly (#163)
* Applied fixes from StyleCI * Create LICENSE
This commit is contained in:
parent
5d04bc63a7
commit
8fe342f5b9
17
LICENSE
Normal file
17
LICENSE
Normal file
@ -0,0 +1,17 @@
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Connection\Exceptions;
|
||||
|
||||
class GenericHTTPError extends \Exception
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Connection\Exceptions;
|
||||
|
||||
class InvalidCredentials extends \Exception
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Connection\Exceptions;
|
||||
|
||||
class MissingEndpoint extends \Exception
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Connection\Exceptions;
|
||||
|
||||
class MissingRequiredParameters extends \Exception
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Connection\Exceptions;
|
||||
|
||||
class NoDomainsConfigured extends \Exception
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?PHP
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Connection;
|
||||
|
||||
use Http\Client\HttpClient;
|
||||
@ -254,7 +261,7 @@ class RestClient
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @param string|array $filePath
|
||||
* @param integer $fileIndex
|
||||
* @param int $fileIndex
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Constants;
|
||||
|
||||
class Api
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Constants;
|
||||
|
||||
class ExceptionMessages
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?PHP
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Lists;
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?PHP
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun;
|
||||
|
||||
use Http\Client\HttpClient;
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?PHP
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Messages;
|
||||
|
||||
use Mailgun\Constants\Api;
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Messages\Exceptions;
|
||||
|
||||
class InvalidParameter extends \Exception
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Messages\Exceptions;
|
||||
|
||||
class InvalidParameterType extends \Exception
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Messages\Exceptions;
|
||||
|
||||
class MissingRequiredMIMEParameters extends \Exception
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Messages\Exceptions;
|
||||
|
||||
class TooManyParameters extends \Exception
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?PHP
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Messages;
|
||||
|
||||
use Mailgun\Constants\Api;
|
||||
@ -309,7 +316,6 @@ class MessageBuilder
|
||||
];
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,9 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Functional;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||
*/
|
||||
class InlineFileTest extends \PHPUnit_Framework_TestCase
|
||||
@ -13,7 +19,7 @@ class InlineFileTest extends \PHPUnit_Framework_TestCase
|
||||
$fileValidator = function ($files) {
|
||||
$fileNames = [
|
||||
['name' => 'inline[0]', 'filename' => 'foo.png'],
|
||||
['name'=>'inline[1]', 'filename'=>'bar.png']
|
||||
['name' => 'inline[1]', 'filename' => 'bar.png'],
|
||||
];
|
||||
|
||||
// Make sure that both files exists
|
||||
@ -33,14 +39,14 @@ class InlineFileTest extends \PHPUnit_Framework_TestCase
|
||||
$mailgun = MockedMailgun::create($this, 'POST', 'domain/messages', [], $fileValidator);
|
||||
|
||||
$builder = $mailgun->MessageBuilder();
|
||||
$builder->setFromAddress("bob@example.com");
|
||||
$builder->addToRecipient("alice@example.com");
|
||||
$builder->setSubject("Foo");
|
||||
$builder->setTextBody("Bar");
|
||||
$builder->setFromAddress('bob@example.com');
|
||||
$builder->addToRecipient('alice@example.com');
|
||||
$builder->setSubject('Foo');
|
||||
$builder->setTextBody('Bar');
|
||||
|
||||
$builder->addInlineImage("@./tests/TestAssets/mailgun_icon1.png", 'foo.png');
|
||||
$builder->addInlineImage("@./tests/TestAssets/mailgun_icon2.png", 'bar.png');
|
||||
$builder->addInlineImage('@./tests/TestAssets/mailgun_icon1.png', 'foo.png');
|
||||
$builder->addInlineImage('@./tests/TestAssets/mailgun_icon2.png', 'bar.png');
|
||||
|
||||
$mailgun->post("domain/messages", $builder->getMessage(), $builder->getFiles());
|
||||
$mailgun->post('domain/messages', $builder->getMessage(), $builder->getFiles());
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Functional;
|
||||
|
||||
use Mailgun\Mailgun;
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Functional;
|
||||
|
||||
use Mailgun\Connection\RestClient;
|
||||
|
@ -1,15 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Functional;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||
*/
|
||||
class NoSamePostNameTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* No post names should ever be the same
|
||||
* No post names should ever be the same.
|
||||
*/
|
||||
public function testNames()
|
||||
{
|
||||
@ -25,25 +31,25 @@ class NoSamePostNameTest extends \PHPUnit_Framework_TestCase
|
||||
$mailgun = MockedMailgun::create($this, 'POST', 'domain/messages', [], $fileValidator);
|
||||
|
||||
$builder = $mailgun->MessageBuilder();
|
||||
$builder->setFromAddress("bob@example.com");
|
||||
$builder->addToRecipient("to1@example.com");
|
||||
$builder->addToRecipient("to2@example.com");
|
||||
$builder->addCcRecipient("cc1@example.com");
|
||||
$builder->addCcRecipient("cc2@example.com");
|
||||
$builder->addBccRecipient("bcc1@example.com");
|
||||
$builder->addBccRecipient("bcc2@example.com");
|
||||
$builder->setFromAddress('bob@example.com');
|
||||
$builder->addToRecipient('to1@example.com');
|
||||
$builder->addToRecipient('to2@example.com');
|
||||
$builder->addCcRecipient('cc1@example.com');
|
||||
$builder->addCcRecipient('cc2@example.com');
|
||||
$builder->addBccRecipient('bcc1@example.com');
|
||||
$builder->addBccRecipient('bcc2@example.com');
|
||||
$builder->addCustomParameter('foo', 'bar');
|
||||
$builder->addCustomParameter('foo', 'baz');
|
||||
$builder->addCampaignId('campaign0');
|
||||
$builder->addCampaignId('campaign1');
|
||||
$builder->setSubject("Foo");
|
||||
$builder->setTextBody("Bar");
|
||||
$builder->setSubject('Foo');
|
||||
$builder->setTextBody('Bar');
|
||||
|
||||
$builder->addAttachment("@./tests/TestAssets/mailgun_icon1.png", 'foo.png');
|
||||
$builder->addAttachment("@./tests/TestAssets/mailgun_icon1.png", 'foo.png');
|
||||
$builder->addInlineImage("@./tests/TestAssets/mailgun_icon2.png", 'bar.png');
|
||||
$builder->addInlineImage("@./tests/TestAssets/mailgun_icon2.png", 'bar.png');
|
||||
$builder->addAttachment('@./tests/TestAssets/mailgun_icon1.png', 'foo.png');
|
||||
$builder->addAttachment('@./tests/TestAssets/mailgun_icon1.png', 'foo.png');
|
||||
$builder->addInlineImage('@./tests/TestAssets/mailgun_icon2.png', 'bar.png');
|
||||
$builder->addInlineImage('@./tests/TestAssets/mailgun_icon2.png', 'bar.png');
|
||||
|
||||
$mailgun->post("domain/messages", $builder->getMessage(), $builder->getFiles());
|
||||
$mailgun->post('domain/messages', $builder->getMessage(), $builder->getFiles());
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Functional;
|
||||
|
||||
/**
|
||||
* Simple test to show how to use the MockedMailgun client
|
||||
* Simple test to show how to use the MockedMailgun client.
|
||||
*
|
||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||
*/
|
||||
@ -22,10 +29,10 @@ class SendMessageTest extends \PHPUnit_Framework_TestCase
|
||||
// Create the mocked mailgun client. We use $this->assertEquals on $method, $uri and $body parameters.
|
||||
$mailgun = MockedMailgun::create($this, 'POST', 'domain/messages', [], $fileValidator);
|
||||
|
||||
$mailgun->sendMessage('domain', array(
|
||||
$mailgun->sendMessage('domain', [
|
||||
'from' => 'bob@example.com',
|
||||
'to' => 'alice@example.com',
|
||||
'subject' => 'Foo',
|
||||
'text' => 'Bar'));
|
||||
'text' => 'Bar', ]);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?PHP
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Lists;
|
||||
|
||||
use Mailgun\Tests\Mock\Mailgun;
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?PHP
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests;
|
||||
|
||||
use Mailgun\Mailgun;
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?PHP
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests;
|
||||
|
||||
abstract class MailgunTestCase extends \PHPUnit_Framework_TestCase
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?PHP
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Messages;
|
||||
|
||||
use Mailgun\Tests\Mock\Mailgun;
|
||||
|
@ -1,15 +1,22 @@
|
||||
<?PHP
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Messages;
|
||||
|
||||
use Mailgun\Tests\Mock\Mailgun;
|
||||
use Mailgun\Connection\RestClient;
|
||||
use Mailgun\Tests\Mock\Mailgun;
|
||||
|
||||
|
||||
class mockRestClient extends RestClient{
|
||||
class mockRestClient extends RestClient
|
||||
{
|
||||
public function send($method, $uri, $body = null, $files = [], array $headers = [])
|
||||
{
|
||||
$result = new \stdClass;
|
||||
$result = new \stdClass();
|
||||
|
||||
$result->method = $method;
|
||||
$result->uri = $uri;
|
||||
@ -21,7 +28,8 @@ class mockRestClient extends RestClient{
|
||||
}
|
||||
}
|
||||
|
||||
class mockMailgun extends Mailgun{
|
||||
class mockMailgun extends Mailgun
|
||||
{
|
||||
public function __construct(
|
||||
$apiKey = null,
|
||||
HttpClient $httpClient = null,
|
||||
@ -44,25 +52,24 @@ class ComplexMessageTest extends \Mailgun\Tests\MailgunTestCase
|
||||
|
||||
public function testSendComplexMessage()
|
||||
{
|
||||
|
||||
$message = [
|
||||
'to' => 'test@test.mailgun.org',
|
||||
'from' => 'sender@test.mailgun.org',
|
||||
'subject' => 'This is my test subject',
|
||||
'text' => 'Testing!'
|
||||
'text' => 'Testing!',
|
||||
];
|
||||
|
||||
$files = [
|
||||
'inline' => [
|
||||
[
|
||||
'remoteName' => 'mailgun_icon1.png',
|
||||
'filePath' => 'tests/TestAssets/mailgun_icon1.png'
|
||||
'filePath' => 'tests/TestAssets/mailgun_icon1.png',
|
||||
],
|
||||
[
|
||||
'remoteName' => 'mailgun_icon2.png',
|
||||
'filePath' => 'tests/TestAssets/mailgun_icon2.png'
|
||||
]
|
||||
]
|
||||
'filePath' => 'tests/TestAssets/mailgun_icon2.png',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$result = $this->client->sendMessage('test.mailgun.org', $message, $files);
|
||||
@ -106,6 +113,5 @@ class ComplexMessageTest extends \Mailgun\Tests\MailgunTestCase
|
||||
|
||||
$this->assertEquals([], $result->body);
|
||||
$this->assertEquals([], $result->headers);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?PHP
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Messages;
|
||||
|
||||
use Mailgun\Tests\Mock\Mailgun;
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?PHP
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Messages;
|
||||
|
||||
use Mailgun\Tests\Mock\Mailgun;
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Mock\Connection;
|
||||
|
||||
use Mailgun\Connection\Exceptions\GenericHTTPError;
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?PHP
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Mock;
|
||||
|
||||
use Mailgun\Mailgun as Base;
|
||||
|
Loading…
Reference in New Issue
Block a user