From 6853b0324769ef6724decc5e62fa5961d3e6c658 Mon Sep 17 00:00:00 2001 From: Pawel Wasiluk <45973917+Pavlico@users.noreply.github.com> Date: Tue, 5 Oct 2021 09:44:50 +0200 Subject: [PATCH] Pool id tests (#793) * Add the `pool_id` parameter to Domain::create() * Formatting * Added tests * Added missing comma Co-authored-by: Roy Hill-Percival --- src/Api/Domain.php | 9 ++++++++- tests/Api/DomainTest.php | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Api/Domain.php b/src/Api/Domain.php index ba73fe5..0c24c3b 100644 --- a/src/Api/Domain.php +++ b/src/Api/Domain.php @@ -84,10 +84,11 @@ 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 * * @return CreateResponse|array|ResponseInterface */ - public function create(string $domain, string $smtpPass = null, string $spamAction = null, bool $wildcard = null, bool $forceDkimAuthority = null, ?array $ips = 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) { Assert::stringNotEmpty($domain); @@ -125,6 +126,12 @@ class Domain extends HttpApi $params['ips'] = join(',', $ips); } + if (null !== $pool_id) { + Assert::stringNotEmpty($pool_id); + + $params['pool_id'] = $pool_id; + } + $response = $this->httpPost('/v3/domains', $params); return $this->hydrateResponse($response, CreateResponse::class); diff --git a/tests/Api/DomainTest.php b/tests/Api/DomainTest.php index b81c168..4beaa18 100644 --- a/tests/Api/DomainTest.php +++ b/tests/Api/DomainTest.php @@ -103,6 +103,21 @@ JSON $api->create('example.com', 'foo'); } + public function testCreateWithPoolId() + { + $this->setRequestMethod('POST'); + $this->setRequestUri('/v3/domains'); + $this->setRequestBody([ + 'name' => 'example.com', + 'smtp_password' => 'foo', + 'pool_id' => '123', + ]); + $this->setHydrateClass(CreateResponse::class); + + $api = $this->getApiInstance(); + $api->create('example.com', 'foo', null, null, null, null, '123'); + } + public function testCreateWithPasswordSpamAction() { $this->setRequestMethod('POST');