mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-29 08:26:06 +03:00
Patch 1 (#792)
* Support setting web_schema * Added tests, change parameters * phpcs fixes * Test fixes Co-authored-by: Thomas Portelange <thomas@lekoala.be>
This commit is contained in:
parent
6853b03247
commit
d926ba72fd
@ -85,10 +85,11 @@ class Domain extends HttpApi
|
||||
* @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 $webScheme `http` or `https` - set your open, click and unsubscribe URLs to use http or https. The default is http
|
||||
*
|
||||
* @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)
|
||||
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')
|
||||
{
|
||||
Assert::stringNotEmpty($domain);
|
||||
|
||||
@ -126,6 +127,12 @@ class Domain extends HttpApi
|
||||
$params['ips'] = join(',', $ips);
|
||||
}
|
||||
|
||||
if (!empty($webScheme)) {
|
||||
Assert::stringNotEmpty($webScheme);
|
||||
Assert::oneOf($webScheme, ['https', 'http']);
|
||||
$params['web_scheme'] = $webScheme;
|
||||
}
|
||||
|
||||
if (null !== $pool_id) {
|
||||
Assert::stringNotEmpty($pool_id);
|
||||
|
||||
|
@ -82,6 +82,7 @@ JSON
|
||||
$this->setRequestUri('/v3/domains');
|
||||
$this->setRequestBody([
|
||||
'name' => 'example.com',
|
||||
'web_scheme' => 'http',
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
@ -96,6 +97,7 @@ JSON
|
||||
$this->setRequestBody([
|
||||
'name' => 'example.com',
|
||||
'smtp_password' => 'foo',
|
||||
'web_scheme' => 'http',
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
@ -111,6 +113,7 @@ JSON
|
||||
'name' => 'example.com',
|
||||
'smtp_password' => 'foo',
|
||||
'pool_id' => '123',
|
||||
'web_scheme' => 'http',
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
@ -126,6 +129,7 @@ JSON
|
||||
'name' => 'example.com',
|
||||
'smtp_password' => 'foo',
|
||||
'spam_action' => 'bar',
|
||||
'web_scheme' => 'http',
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
@ -142,6 +146,7 @@ JSON
|
||||
'smtp_password' => 'foo',
|
||||
'spam_action' => 'bar',
|
||||
'wildcard' => 'true',
|
||||
'web_scheme' => 'http',
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
@ -157,6 +162,7 @@ JSON
|
||||
'name' => 'example.com',
|
||||
'smtp_password' => 'foo',
|
||||
'force_dkim_authority' => 'true',
|
||||
'web_scheme' => 'http',
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
@ -174,6 +180,7 @@ JSON
|
||||
'spam_action' => 'bar',
|
||||
'wildcard' => 'true',
|
||||
'force_dkim_authority' => 'true',
|
||||
'web_scheme' => 'http',
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
@ -270,6 +277,7 @@ JSON
|
||||
'name' => 'example.com',
|
||||
'smtp_password' => 'foo',
|
||||
'ips' => '127.0.0.1,127.0.0.2',
|
||||
'web_scheme' => 'http',
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
@ -277,6 +285,21 @@ JSON
|
||||
$api->create('example.com', 'foo', null, null, null, ['127.0.0.1', '127.0.0.2']);
|
||||
}
|
||||
|
||||
public function testCreateWithWebSchema()
|
||||
{
|
||||
$this->setRequestMethod('POST');
|
||||
$this->setRequestUri('/v3/domains');
|
||||
$this->setRequestBody([
|
||||
'name' => 'example.com',
|
||||
'smtp_password' => 'foo',
|
||||
'web_scheme' => 'https',
|
||||
]);
|
||||
$this->setHydrateClass(CreateResponse::class);
|
||||
|
||||
$api = $this->getApiInstance();
|
||||
$api->create('example.com', 'foo', null, null, null, null, null, 'https');
|
||||
}
|
||||
|
||||
public function testTracking()
|
||||
{
|
||||
$this->setRequestMethod('GET');
|
||||
|
Loading…
Reference in New Issue
Block a user