Allow assigning a domain to a list of ips during creation

This commit is contained in:
Joseph Shanak 2020-10-05 09:50:47 -05:00 committed by David Garcia
parent ff8c9c31b7
commit 086afb49b7
2 changed files with 28 additions and 6 deletions

View File

@ -74,15 +74,16 @@ class Domain extends HttpApi
*
* @see https://documentation.mailgun.com/en/latest/api-domains.html#domains
*
* @param string $domain name of the domain
* @param string $smtpPass password for SMTP authentication
* @param string $spamAction `disable` or `tag` - inbound spam filtering
* @param bool $wildcard domain will accept email for subdomains
* @param bool $forceDkimAuthority force DKIM authority
* @param string $domain name of the domain
* @param string $smtpPass password for SMTP authentication
* @param string $spamAction `disable` or `tag` - inbound spam filtering
* @param bool $wildcard domain will accept email for subdomains
* @param bool $forceDkimAuthority force DKIM authority
* @param string[] $ips an array of ips to be assigned to the domain
*
* @return CreateResponse|array|ResponseInterface
*/
public function create(string $domain, string $smtpPass = null, string $spamAction = null, bool $wildcard = null, bool $forceDkimAuthority = null)
public function create(string $domain, string $smtpPass = null, string $spamAction = null, bool $wildcard = null, bool $forceDkimAuthority = null, ?array $ips = null)
{
Assert::stringNotEmpty($domain);
@ -113,6 +114,12 @@ class Domain extends HttpApi
$params['force_dkim_authority'] = $forceDkimAuthority ? 'true' : 'false';
}
if (null !== $ips) {
Assert::isList($ips);
$params['ips'] = join(',', $ips);
}
$response = $this->httpPost('/v3/domains', $params);
return $this->hydrateResponse($response, CreateResponse::class);

View File

@ -241,4 +241,19 @@ JSON
$api = $this->getApiInstance();
$api->verify('example.com');
}
public function testCreateWithIps()
{
$this->setRequestMethod('POST');
$this->setRequestUri('/v3/domains');
$this->setRequestBody([
'name' => 'example.com',
'smtp_password' => 'foo',
'ips' => "127.0.0.1,127.0.0.2",
]);
$this->setHydrateClass(CreateResponse::class);
$api = $this->getApiInstance();
$api->create('example.com', 'foo', null, null, null, ["127.0.0.1", "127.0.0.2"]);
}
}