mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2025-02-06 08:19:25 +03:00
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:
parent
ae9a549e7f
commit
c9bbf8e45f
@ -88,16 +88,26 @@ class Domain extends HttpApi
|
|||||||
|
|
||||||
$params['name'] = $domain;
|
$params['name'] = $domain;
|
||||||
|
|
||||||
// If at least smtpPass available, check for the fields spamAction wildcard
|
|
||||||
if (!empty($smtpPass)) {
|
if (!empty($smtpPass)) {
|
||||||
// TODO(sean.johnson): Extended spam filter input validation.
|
Assert::stringNotEmpty($smtpPass);
|
||||||
Assert::stringNotEmpty($spamAction);
|
Assert::lengthBetween($smtpPass, 5, 32, 'SMTP password must be between 5 and 32 characters.');
|
||||||
Assert::boolean($wildcard);
|
|
||||||
|
|
||||||
$params['smtp_password'] = $smtpPass;
|
$params['smtp_password'] = $smtpPass;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $spamAction) {
|
||||||
|
// TODO(sean.johnson): Extended spam filter input validation.
|
||||||
|
Assert::stringNotEmpty($spamAction);
|
||||||
|
|
||||||
$params['spam_action'] = $spamAction;
|
$params['spam_action'] = $spamAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null !== $wildcard) {
|
||||||
|
Assert::boolean($wildcard);
|
||||||
|
|
||||||
|
$params['wildcard'] = $wildcard ? 'true' : 'false';
|
||||||
|
}
|
||||||
|
|
||||||
$response = $this->httpPost('/v3/domains', $params);
|
$response = $this->httpPost('/v3/domains', $params);
|
||||||
|
|
||||||
return $this->hydrateResponse($response, CreateResponse::class);
|
return $this->hydrateResponse($response, CreateResponse::class);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user