diff --git a/src/Mailgun/Model/Suppression/Bounce/Bounce.php b/src/Mailgun/Model/Suppression/Bounce/Bounce.php new file mode 100644 index 0000000..687effc --- /dev/null +++ b/src/Mailgun/Model/Suppression/Bounce/Bounce.php @@ -0,0 +1,123 @@ + + */ +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; + } +} diff --git a/src/Mailgun/Model/Suppression/Bounce/ShowResponse.php b/src/Mailgun/Model/Suppression/Bounce/ShowResponse.php index e062490..894babd 100644 --- a/src/Mailgun/Model/Suppression/Bounce/ShowResponse.php +++ b/src/Mailgun/Model/Suppression/Bounce/ShowResponse.php @@ -14,112 +14,6 @@ use Mailgun\Model\ApiResponse; /** * @author Sean Johnson */ -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; - } } diff --git a/src/Mailgun/Model/Suppression/Complaint/Complaint.php b/src/Mailgun/Model/Suppression/Complaint/Complaint.php new file mode 100644 index 0000000..c9506d2 --- /dev/null +++ b/src/Mailgun/Model/Suppression/Complaint/Complaint.php @@ -0,0 +1,75 @@ + + */ +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; + } +} diff --git a/src/Mailgun/Model/Suppression/Complaint/ShowResponse.php b/src/Mailgun/Model/Suppression/Complaint/ShowResponse.php index 79da797..4ad2102 100644 --- a/src/Mailgun/Model/Suppression/Complaint/ShowResponse.php +++ b/src/Mailgun/Model/Suppression/Complaint/ShowResponse.php @@ -14,64 +14,6 @@ use Mailgun\Model\ApiResponse; /** * @author Sean Johnson */ -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; - } } diff --git a/src/Mailgun/Model/Suppression/Unsubscribe/IndexResponse.php b/src/Mailgun/Model/Suppression/Unsubscribe/IndexResponse.php index 2774a5b..fb3ebda 100644 --- a/src/Mailgun/Model/Suppression/Unsubscribe/IndexResponse.php +++ b/src/Mailgun/Model/Suppression/Unsubscribe/IndexResponse.php @@ -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); } } diff --git a/src/Mailgun/Model/Suppression/Unsubscribe/ShowResponse.php b/src/Mailgun/Model/Suppression/Unsubscribe/ShowResponse.php index 5df9426..558c92d 100644 --- a/src/Mailgun/Model/Suppression/Unsubscribe/ShowResponse.php +++ b/src/Mailgun/Model/Suppression/Unsubscribe/ShowResponse.php @@ -14,88 +14,6 @@ use Mailgun\Model\ApiResponse; /** * @author Sean Johnson */ -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; - } } diff --git a/src/Mailgun/Model/Suppression/Unsubscribe/Unsubscribe.php b/src/Mailgun/Model/Suppression/Unsubscribe/Unsubscribe.php new file mode 100644 index 0000000..eed521d --- /dev/null +++ b/src/Mailgun/Model/Suppression/Unsubscribe/Unsubscribe.php @@ -0,0 +1,99 @@ + + */ +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; + } +} diff --git a/test.php b/test.php new file mode 100644 index 0000000..0f6a186 --- /dev/null +++ b/test.php @@ -0,0 +1,7 @@ +suppressions()->bounces()->index('sandbox40c4b0745b8a4461959950ccf9c0a1ea.mailgun.org'); +$x = 2;