mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-12-01 17:36:05 +03:00
Added dkim size
This commit is contained in:
parent
f25a22344b
commit
c3c3a9f01a
@ -36,6 +36,7 @@ use Psr\Http\Message\ResponseInterface;
|
||||
*/
|
||||
class Domain extends HttpApi
|
||||
{
|
||||
private const DKIM_SIZES = ['1024', '2048'];
|
||||
/**
|
||||
* Returns a list of domains on the account.
|
||||
*
|
||||
@ -84,12 +85,13 @@ class Domain extends HttpApi
|
||||
* @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
|
||||
* @param ?string $pool_id pool id to assign to the domain
|
||||
* @param ?string $poolId pool id to assign to the domain
|
||||
* @param string $webScheme `http` or `https` - set your open, click and unsubscribe URLs to use http or https. The default is http
|
||||
* @param string $dkimKeySize Set length of your domain’s generated DKIM key
|
||||
*
|
||||
* @return CreateResponse|array|ResponseInterface
|
||||
*/
|
||||
public function create(string $domain, string $smtpPass = null, string $spamAction = null, bool $wildcard = null, bool $forceDkimAuthority = null, ?array $ips = null, ?string $pool_id = null, string $webScheme = 'http')
|
||||
public function create(string $domain, string $smtpPass = null, string $spamAction = null, bool $wildcard = null, bool $forceDkimAuthority = null, ?array $ips = null, ?string $poolId = null, string $webScheme = 'http', string $dkimKeySize = '1024')
|
||||
{
|
||||
Assert::stringNotEmpty($domain);
|
||||
|
||||
@ -133,10 +135,18 @@ class Domain extends HttpApi
|
||||
$params['web_scheme'] = $webScheme;
|
||||
}
|
||||
|
||||
if (null !== $pool_id) {
|
||||
Assert::stringNotEmpty($pool_id);
|
||||
if (null !== $poolId) {
|
||||
Assert::stringNotEmpty($poolId);
|
||||
|
||||
$params['pool_id'] = $pool_id;
|
||||
$params['pool_id'] = $poolId;
|
||||
}
|
||||
if (null !== $dkimKeySize) {
|
||||
Assert::oneOf(
|
||||
$dkimKeySize,
|
||||
self::DKIM_SIZES,
|
||||
'Length of your domain’s generated DKIM key must be 1024 or 2048'
|
||||
);
|
||||
$params['dkim_key_size'] = $dkimKeySize;
|
||||
}
|
||||
|
||||
$response = $this->httpPost('/v3/domains', $params);
|
||||
|
@ -83,6 +83,7 @@ JSON
|
||||
$this->setRequestBody([
|
||||
'name' => 'example.com',
|
||||
'web_scheme' => 'http',
|
||||
'dkim_key_size' => '1024'
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
@ -98,6 +99,7 @@ JSON
|
||||
'name' => 'example.com',
|
||||
'smtp_password' => 'foo',
|
||||
'web_scheme' => 'http',
|
||||
'dkim_key_size' => '1024'
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
@ -114,6 +116,7 @@ JSON
|
||||
'smtp_password' => 'foo',
|
||||
'pool_id' => '123',
|
||||
'web_scheme' => 'http',
|
||||
'dkim_key_size' => '1024'
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
@ -130,6 +133,7 @@ JSON
|
||||
'smtp_password' => 'foo',
|
||||
'spam_action' => 'bar',
|
||||
'web_scheme' => 'http',
|
||||
'dkim_key_size' => '1024'
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
@ -147,6 +151,7 @@ JSON
|
||||
'spam_action' => 'bar',
|
||||
'wildcard' => 'true',
|
||||
'web_scheme' => 'http',
|
||||
'dkim_key_size' => '1024'
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
@ -163,6 +168,7 @@ JSON
|
||||
'smtp_password' => 'foo',
|
||||
'force_dkim_authority' => 'true',
|
||||
'web_scheme' => 'http',
|
||||
'dkim_key_size' => '1024'
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
@ -181,6 +187,7 @@ JSON
|
||||
'wildcard' => 'true',
|
||||
'force_dkim_authority' => 'true',
|
||||
'web_scheme' => 'http',
|
||||
'dkim_key_size' => '1024'
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
@ -278,6 +285,7 @@ JSON
|
||||
'smtp_password' => 'foo',
|
||||
'ips' => '127.0.0.1,127.0.0.2',
|
||||
'web_scheme' => 'http',
|
||||
'dkim_key_size' => '1024'
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
@ -285,6 +293,22 @@ JSON
|
||||
$api->create('example.com', 'foo', null, null, null, ['127.0.0.1', '127.0.0.2']);
|
||||
}
|
||||
|
||||
public function testCreateWithDkim()
|
||||
{
|
||||
$this->setRequestMethod('POST');
|
||||
$this->setRequestUri('/v3/domains');
|
||||
$this->setRequestBody([
|
||||
'name' => 'example.com',
|
||||
'smtp_password' => 'foo',
|
||||
'web_scheme' => 'http',
|
||||
'dkim_key_size' => '2048'
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
$api = $this->getApiInstance();
|
||||
$api->create('example.com', 'foo', null, null, null, null, null, 'http', '2048');
|
||||
}
|
||||
|
||||
public function testCreateWithWebSchema()
|
||||
{
|
||||
$this->setRequestMethod('POST');
|
||||
@ -293,6 +317,7 @@ JSON
|
||||
'name' => 'example.com',
|
||||
'smtp_password' => 'foo',
|
||||
'web_scheme' => 'https',
|
||||
'dkim_key_size' => '1024'
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user