Skip to content

Commit

Permalink
Revise domain creation to allow select arguments
Browse files Browse the repository at this point in the history
Previously, passing `$spamAction` only worked if an SMTP password (`$smtpPass`) was provided. This revision de-couples those two arguments.

In addition, it adds support for the `$wildcard` arguments (which appeared to not be used before).

Finally, this revision adds SMTP password validation (the same used in the `credentials` method).
  • Loading branch information
nathanntg authored and DavidGarciaCat committed Aug 29, 2019
1 parent ae9a549 commit c9bbf8e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Api/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,26 @@ public function create(string $domain, string $smtpPass = null, string $spamActi

$params['name'] = $domain;

// If at least smtpPass available, check for the fields spamAction wildcard
if (!empty($smtpPass)) {
Assert::stringNotEmpty($smtpPass);
Assert::lengthBetween($smtpPass, 5, 32, 'SMTP password must be between 5 and 32 characters.');

$params['smtp_password'] = $smtpPass;
}

if (null !== $spamAction) {
// TODO(sean.johnson): Extended spam filter input validation.
Assert::stringNotEmpty($spamAction);
Assert::boolean($wildcard);

$params['smtp_password'] = $smtpPass;
$params['spam_action'] = $spamAction;
}

if (null !== $wildcard) {
Assert::boolean($wildcard);

$params['wildcard'] = $wildcard ? 'true' : 'false';
}

$response = $this->httpPost('/v3/domains', $params);

return $this->hydrateResponse($response, CreateResponse::class);
Expand Down

0 comments on commit c9bbf8e

Please sign in to comment.