mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2025-02-06 08:19:25 +03:00
Fixing broken suppression API (#332)
* Fixing broken suppression API * cs
This commit is contained in:
parent
27d13d85fd
commit
ae9ee585a2
123
src/Mailgun/Model/Suppression/Bounce/Bounce.php
Normal file
123
src/Mailgun/Model/Suppression/Bounce/Bounce.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?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\Model\Suppression\Bounce;
|
||||
|
||||
/**
|
||||
* @author Sean Johnson <sean@mailgun.com>
|
||||
*/
|
||||
class Bounce
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $address;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $error;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* @param string $address
|
||||
*/
|
||||
private function __construct($address)
|
||||
{
|
||||
$this->address = $address;
|
||||
$this->createdAt = new \DateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Bounce
|
||||
*/
|
||||
public static function create(array $data)
|
||||
{
|
||||
$bounce = new self($data['address']);
|
||||
|
||||
if (isset($data['code'])) {
|
||||
$bounce->setCode($data['code']);
|
||||
}
|
||||
if (isset($data['error'])) {
|
||||
$bounce->setError($data['error']);
|
||||
}
|
||||
if (isset($data['created_at'])) {
|
||||
$bounce->setCreatedAt(new \DateTime($data['created_at']));
|
||||
}
|
||||
|
||||
return $bounce;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
*/
|
||||
private function setCode($code)
|
||||
{
|
||||
$this->code = $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $error
|
||||
*/
|
||||
private function setError($error)
|
||||
{
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $createdAt
|
||||
*/
|
||||
private function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
}
|
||||
}
|
@ -14,112 +14,6 @@ use Mailgun\Model\ApiResponse;
|
||||
/**
|
||||
* @author Sean Johnson <sean@mailgun.com>
|
||||
*/
|
||||
final class ShowResponse implements ApiResponse
|
||||
final class ShowResponse extends Bounce implements ApiResponse
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $address;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $error;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* @param string $address
|
||||
*/
|
||||
private function __construct($address)
|
||||
{
|
||||
$this->address = $address;
|
||||
$this->createdAt = new \DateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return ShowResponse
|
||||
*/
|
||||
public static function create(array $data)
|
||||
{
|
||||
$bounce = new self($data['address']);
|
||||
|
||||
if (isset($data['code'])) {
|
||||
$bounce->setCode($data['code']);
|
||||
}
|
||||
if (isset($data['error'])) {
|
||||
$bounce->setError($data['error']);
|
||||
}
|
||||
if (isset($data['created_at'])) {
|
||||
$bounce->setCreatedAt(new \DateTime($data['created_at']));
|
||||
}
|
||||
|
||||
return $bounce;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
*/
|
||||
private function setCode($code)
|
||||
{
|
||||
$this->code = $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $error
|
||||
*/
|
||||
private function setError($error)
|
||||
{
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $createdAt
|
||||
*/
|
||||
private function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
}
|
||||
}
|
||||
|
75
src/Mailgun/Model/Suppression/Complaint/Complaint.php
Normal file
75
src/Mailgun/Model/Suppression/Complaint/Complaint.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?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\Model\Suppression\Complaint;
|
||||
|
||||
/**
|
||||
* @author Sean Johnson <sean@mailgun.com>
|
||||
*/
|
||||
class Complaint
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $address;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* @param string $address
|
||||
*/
|
||||
private function __construct($address)
|
||||
{
|
||||
$this->address = $address;
|
||||
$this->createdAt = new \DateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Complaint
|
||||
*/
|
||||
public static function create(array $data)
|
||||
{
|
||||
$complaint = new self($data['address']);
|
||||
|
||||
if (isset($data['created_at'])) {
|
||||
$complaint->setCreatedAt(new \DateTime($data['created_at']));
|
||||
}
|
||||
|
||||
return $complaint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $createdAt
|
||||
*/
|
||||
private function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
}
|
||||
}
|
@ -14,64 +14,6 @@ use Mailgun\Model\ApiResponse;
|
||||
/**
|
||||
* @author Sean Johnson <sean@mailgun.com>
|
||||
*/
|
||||
final class ShowResponse implements ApiResponse
|
||||
final class ShowResponse extends Complaint implements ApiResponse
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $address;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* @param string $address
|
||||
*/
|
||||
private function __construct($address)
|
||||
{
|
||||
$this->address = $address;
|
||||
$this->createdAt = new \DateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return ShowResponse
|
||||
*/
|
||||
public static function create(array $data)
|
||||
{
|
||||
$bounce = new self($data['address']);
|
||||
|
||||
if (isset($data['created_at'])) {
|
||||
$bounce->setCreatedAt(new \DateTime($data['created_at']));
|
||||
}
|
||||
|
||||
return $bounce;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $createdAt
|
||||
*/
|
||||
private function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ final class IndexResponse implements ApiResponse, PagingProvider
|
||||
$unsubscribes = [];
|
||||
if (isset($data['items'])) {
|
||||
foreach ($data['items'] as $item) {
|
||||
$unsubscribes[] = Unsubscribes::create($item);
|
||||
$unsubscribes[] = Unsubscribe::create($item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,88 +14,6 @@ use Mailgun\Model\ApiResponse;
|
||||
/**
|
||||
* @author Sean Johnson <sean@mailgun.com>
|
||||
*/
|
||||
final class ShowResponse implements ApiResponse
|
||||
final class ShowResponse extends Unsubscribe implements ApiResponse
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $address;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $tag;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* @param string $address
|
||||
*/
|
||||
private function __construct($address)
|
||||
{
|
||||
$this->address = $address;
|
||||
$this->createdAt = new \DateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return ShowResponse
|
||||
*/
|
||||
public static function create(array $data)
|
||||
{
|
||||
$unsubscribe = new self($data['address']);
|
||||
|
||||
if (isset($data['tag'])) {
|
||||
$unsubscribe->setTag($data['tag']);
|
||||
}
|
||||
if (isset($data['created_at'])) {
|
||||
$unsubscribe->setCreatedAt(new \DateTime($data['created_at']));
|
||||
}
|
||||
|
||||
return $unsubscribe;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTag()
|
||||
{
|
||||
return $this->tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tag
|
||||
*/
|
||||
private function setTag($tag)
|
||||
{
|
||||
$this->tag = $tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $createdAt
|
||||
*/
|
||||
private function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
}
|
||||
}
|
||||
|
99
src/Mailgun/Model/Suppression/Unsubscribe/Unsubscribe.php
Normal file
99
src/Mailgun/Model/Suppression/Unsubscribe/Unsubscribe.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?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\Model\Suppression\Unsubscribe;
|
||||
|
||||
/**
|
||||
* @author Sean Johnson <sean@mailgun.com>
|
||||
*/
|
||||
class Unsubscribe
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $address;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $tag;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* @param string $address
|
||||
*/
|
||||
private function __construct($address)
|
||||
{
|
||||
$this->address = $address;
|
||||
$this->createdAt = new \DateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return Unsubscribe
|
||||
*/
|
||||
public static function create(array $data)
|
||||
{
|
||||
$unsubscribe = new self($data['address']);
|
||||
|
||||
if (isset($data['tag'])) {
|
||||
$unsubscribe->setTag($data['tag']);
|
||||
}
|
||||
if (isset($data['created_at'])) {
|
||||
$unsubscribe->setCreatedAt(new \DateTime($data['created_at']));
|
||||
}
|
||||
|
||||
return $unsubscribe;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTag()
|
||||
{
|
||||
return $this->tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tag
|
||||
*/
|
||||
private function setTag($tag)
|
||||
{
|
||||
$this->tag = $tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $createdAt
|
||||
*/
|
||||
private function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user