mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2025-02-06 08:19:25 +03:00
feat(unsubscribe): Handle tags in Unsubscribe v3 api.
This commit is contained in:
parent
83800d7486
commit
ce2bd4b0f1
@ -29,6 +29,11 @@ class Unsubscribe
|
|||||||
*/
|
*/
|
||||||
private $createdAt;
|
private $createdAt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $tags = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $address
|
* @param string $address
|
||||||
*/
|
*/
|
||||||
@ -50,6 +55,9 @@ class Unsubscribe
|
|||||||
if (isset($data['tag'])) {
|
if (isset($data['tag'])) {
|
||||||
$unsubscribe->setTag($data['tag']);
|
$unsubscribe->setTag($data['tag']);
|
||||||
}
|
}
|
||||||
|
if (isset($data['tags'])) {
|
||||||
|
$unsubscribe->setTags($data['tags']);
|
||||||
|
}
|
||||||
if (isset($data['created_at'])) {
|
if (isset($data['created_at'])) {
|
||||||
$unsubscribe->setCreatedAt(new \DateTime($data['created_at']));
|
$unsubscribe->setCreatedAt(new \DateTime($data['created_at']));
|
||||||
}
|
}
|
||||||
@ -96,4 +104,20 @@ class Unsubscribe
|
|||||||
{
|
{
|
||||||
$this->createdAt = $createdAt;
|
$this->createdAt = $createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $tags
|
||||||
|
*/
|
||||||
|
private function setTags($tags)
|
||||||
|
{
|
||||||
|
$this->tags = $tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getTags()
|
||||||
|
{
|
||||||
|
return $this->tags;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
28
tests/Model/Suppression/Unsubscribe/UnsubscribeTest.php
Normal file
28
tests/Model/Suppression/Unsubscribe/UnsubscribeTest.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Mailgun\Tests\Model\Suppression\Unsubscribe;
|
||||||
|
|
||||||
|
use Mailgun\Model\Suppression\Unsubscribe\Unsubscribe;
|
||||||
|
use PHPUnit_Framework_TestCase;
|
||||||
|
|
||||||
|
class UnsubscribeTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_gets_empty_list_of_tags_by_default()
|
||||||
|
{
|
||||||
|
$unsubscribe = Unsubscribe::create(['address' => 'dummy@mailgun.net']);
|
||||||
|
$this->assertEquals([], $unsubscribe->getTags());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_gets_tags()
|
||||||
|
{
|
||||||
|
$tags = ['tag1', 'tag2'];
|
||||||
|
$unsubscribe = Unsubscribe::create(['address' => 'dummy@mailgun.net', 'tags' => $tags]);
|
||||||
|
$this->assertEquals($tags, $unsubscribe->getTags());
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user