* 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:
Pawel Wasiluk 2021-10-19 09:46:16 +02:00 committed by GitHub
parent 6853b03247
commit d926ba72fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 1 deletions

View File

@ -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);

View File

@ -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');