diff --git a/src/Api/Domain.php b/src/Api/Domain.php index 0c24c3b..1c2a19e 100644 --- a/src/Api/Domain.php +++ b/src/Api/Domain.php @@ -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); diff --git a/tests/Api/DomainTest.php b/tests/Api/DomainTest.php index 4beaa18..c4da5e5 100644 --- a/tests/Api/DomainTest.php +++ b/tests/Api/DomainTest.php @@ -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');