mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2025-02-06 08:19:25 +03:00
cleanup_duplication: moved duplications to abstract class.
This commit is contained in:
parent
c228b2bd2c
commit
2412efd1a2
119
src/Mailgun/Model/Domain/AbstractDomainResponse.php
Normal file
119
src/Mailgun/Model/Domain/AbstractDomainResponse.php
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Mailgun
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Mailgun\Model\Domain;
|
||||||
|
|
||||||
|
use Mailgun\Model\ApiResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||||
|
*/
|
||||||
|
abstract class AbstractDomainResponse implements ApiResponse
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Domain
|
||||||
|
*/
|
||||||
|
private $domain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var DnsRecord[]
|
||||||
|
*/
|
||||||
|
private $inboundDnsRecords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var DnsRecord[]
|
||||||
|
*/
|
||||||
|
private $outboundDnsRecords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public static function create(array $data)
|
||||||
|
{
|
||||||
|
$rx = [];
|
||||||
|
$tx = [];
|
||||||
|
$domain = null;
|
||||||
|
$message = null;
|
||||||
|
|
||||||
|
if (isset($data['domain'])) {
|
||||||
|
$domain = Domain::create($data['domain']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($data['message'])) {
|
||||||
|
$message = $data['message'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($data['receiving_dns_records'])) {
|
||||||
|
foreach ($data['receiving_dns_records'] as $item) {
|
||||||
|
$rx[] = DnsRecord::create($item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($data['sending_dns_records'])) {
|
||||||
|
foreach ($data['sending_dns_records'] as $item) {
|
||||||
|
$tx[] = DnsRecord::create($item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new self($domain, $rx, $tx, $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Domain $domainInfo
|
||||||
|
* @param DnsRecord[] $rxRecords
|
||||||
|
* @param DnsRecord[] $txRecords
|
||||||
|
* @param string $message
|
||||||
|
*/
|
||||||
|
private function __construct(Domain $domainInfo, array $rxRecords, array $txRecords, $message)
|
||||||
|
{
|
||||||
|
$this->domain = $domainInfo;
|
||||||
|
$this->inboundDnsRecords = $rxRecords;
|
||||||
|
$this->outboundDnsRecords = $txRecords;
|
||||||
|
$this->message = $message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Domain
|
||||||
|
*/
|
||||||
|
public function getDomain()
|
||||||
|
{
|
||||||
|
return $this->domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return DnsRecord[]
|
||||||
|
*/
|
||||||
|
public function getInboundDNSRecords()
|
||||||
|
{
|
||||||
|
return $this->inboundDnsRecords;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return DnsRecord[]
|
||||||
|
*/
|
||||||
|
public function getOutboundDNSRecords()
|
||||||
|
{
|
||||||
|
return $this->outboundDnsRecords;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getMessage()
|
||||||
|
{
|
||||||
|
return $this->message;
|
||||||
|
}
|
||||||
|
}
|
@ -9,111 +9,9 @@
|
|||||||
|
|
||||||
namespace Mailgun\Model\Domain;
|
namespace Mailgun\Model\Domain;
|
||||||
|
|
||||||
use Mailgun\Model\ApiResponse;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||||
*/
|
*/
|
||||||
final class CreateResponse implements ApiResponse
|
final class CreateResponse extends AbstractDomainResponse
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $message;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Domain
|
|
||||||
*/
|
|
||||||
private $domain;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var DnsRecord[]
|
|
||||||
*/
|
|
||||||
private $inboundDnsRecords;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var DnsRecord[]
|
|
||||||
*/
|
|
||||||
private $outboundDnsRecords;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $data
|
|
||||||
*
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public static function create(array $data)
|
|
||||||
{
|
|
||||||
$rx = [];
|
|
||||||
$tx = [];
|
|
||||||
$domain = null;
|
|
||||||
$message = null;
|
|
||||||
|
|
||||||
if (isset($data['domain'])) {
|
|
||||||
$domain = Domain::create($data['domain']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($data['message'])) {
|
|
||||||
$message = $data['message'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($data['receiving_dns_records'])) {
|
|
||||||
foreach ($data['receiving_dns_records'] as $item) {
|
|
||||||
$rx[] = DnsRecord::create($item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($data['sending_dns_records'])) {
|
|
||||||
foreach ($data['sending_dns_records'] as $item) {
|
|
||||||
$tx[] = DnsRecord::create($item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new self($domain, $rx, $tx, $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Domain $domainInfo
|
|
||||||
* @param DnsRecord[] $rxRecords
|
|
||||||
* @param DnsRecord[] $txRecords
|
|
||||||
* @param string $message
|
|
||||||
*/
|
|
||||||
private function __construct(Domain $domainInfo, array $rxRecords, array $txRecords, $message)
|
|
||||||
{
|
|
||||||
$this->domain = $domainInfo;
|
|
||||||
$this->inboundDnsRecords = $rxRecords;
|
|
||||||
$this->outboundDnsRecords = $txRecords;
|
|
||||||
$this->message = $message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Domain
|
|
||||||
*/
|
|
||||||
public function getDomain()
|
|
||||||
{
|
|
||||||
return $this->domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return DnsRecord[]
|
|
||||||
*/
|
|
||||||
public function getInboundDNSRecords()
|
|
||||||
{
|
|
||||||
return $this->inboundDnsRecords;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return DnsRecord[]
|
|
||||||
*/
|
|
||||||
public function getOutboundDNSRecords()
|
|
||||||
{
|
|
||||||
return $this->outboundDnsRecords;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getMessage()
|
|
||||||
{
|
|
||||||
return $this->message;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -9,111 +9,9 @@
|
|||||||
|
|
||||||
namespace Mailgun\Model\Domain;
|
namespace Mailgun\Model\Domain;
|
||||||
|
|
||||||
use Mailgun\Model\ApiResponse;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Maxim Zasorin <maximzasorin@gmail.com>
|
* @author Maxim Zasorin <maximzasorin@gmail.com>
|
||||||
*/
|
*/
|
||||||
final class VerifyResponse implements ApiResponse
|
final class VerifyResponse extends AbstractDomainResponse
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var Domain
|
|
||||||
*/
|
|
||||||
private $domain;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $message;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var DnsRecord[]
|
|
||||||
*/
|
|
||||||
private $inboundDnsRecords;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var DnsRecord[]
|
|
||||||
*/
|
|
||||||
private $outboundDnsRecords;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $data
|
|
||||||
*
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public static function create(array $data)
|
|
||||||
{
|
|
||||||
$rx = [];
|
|
||||||
$tx = [];
|
|
||||||
$domain = null;
|
|
||||||
$message = null;
|
|
||||||
|
|
||||||
if (isset($data['domain'])) {
|
|
||||||
$domain = Domain::create($data['domain']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($data['message'])) {
|
|
||||||
$message = $data['message'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($data['receiving_dns_records'])) {
|
|
||||||
foreach ($data['receiving_dns_records'] as $item) {
|
|
||||||
$rx[] = DnsRecord::create($item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($data['sending_dns_records'])) {
|
|
||||||
foreach ($data['sending_dns_records'] as $item) {
|
|
||||||
$tx[] = DnsRecord::create($item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new self($domain, $rx, $tx, $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Domain $domainInfo
|
|
||||||
* @param DnsRecord[] $rxRecords
|
|
||||||
* @param DnsRecord[] $txRecords
|
|
||||||
* @param string $message
|
|
||||||
*/
|
|
||||||
private function __construct(Domain $domainInfo, array $rxRecords, array $txRecords, $message)
|
|
||||||
{
|
|
||||||
$this->domain = $domainInfo;
|
|
||||||
$this->inboundDnsRecords = $rxRecords;
|
|
||||||
$this->outboundDnsRecords = $txRecords;
|
|
||||||
$this->message = $message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Domain
|
|
||||||
*/
|
|
||||||
public function getDomain()
|
|
||||||
{
|
|
||||||
return $this->domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return DnsRecord[]
|
|
||||||
*/
|
|
||||||
public function getInboundDNSRecords()
|
|
||||||
{
|
|
||||||
return $this->inboundDnsRecords;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return DnsRecord[]
|
|
||||||
*/
|
|
||||||
public function getOutboundDNSRecords()
|
|
||||||
{
|
|
||||||
return $this->outboundDnsRecords;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getMessage()
|
|
||||||
{
|
|
||||||
return $this->message;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user