Revise domain creation to allow select arguments

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).
This commit is contained in:
Nathan Perkins 2019-08-26 10:19:07 -06:00 committed by David Garcia
parent ae9a549e7f
commit c9bbf8e45f

View File

@ -88,16 +88,26 @@ class Domain extends HttpApi
$params['name'] = $domain;
// If at least smtpPass available, check for the fields spamAction wildcard
if (!empty($smtpPass)) {
// TODO(sean.johnson): Extended spam filter input validation.
Assert::stringNotEmpty($spamAction);
Assert::boolean($wildcard);
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);
$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);