Update method's description and fix parameters

This commit is contained in:
David Garcia 2019-08-09 23:56:36 +01:00
parent 3586bd0398
commit 281cb04130
No known key found for this signature in database
GPG Key ID: 5B833C2A14BD9A97
2 changed files with 13 additions and 13 deletions

View File

@ -27,13 +27,19 @@ use Psr\Http\Message\ResponseInterface;
class EmailValidation extends HttpApi class EmailValidation extends HttpApi
{ {
/** /**
* Addresses are validated based off defined checks. * Mailgun API will validate the given address based on:
* - Mailbox detection
* - Syntax checks (RFC defined grammar)
* - DNS validation
* - Spell checks
* - Email Service Provider (ESP) specific local-part grammar (if available).
* *
* This operation is only accessible with the private API key and not subject to the daily usage limits. * Pricing details for Mailguns email validation service can be found on Mailgun's pricing page.
*
* @see https://documentation.mailgun.com/en/latest/api-email-validation.html
* @see https://www.mailgun.com/pricing
* *
* @param string $address An email address to validate. Maximum: 512 characters. * @param string $address An email address to validate. Maximum: 512 characters.
* @param bool $mailboxVerification If set to true, a mailbox verification check will be performed
* against the address. The default is False.
* *
* @throws InvalidArgumentException Thrown when local validation returns an error * @throws InvalidArgumentException Thrown when local validation returns an error
* @throws HttpClientException Thrown when there's an error on Client side * @throws HttpClientException Thrown when there's an error on Client side
@ -42,14 +48,11 @@ class EmailValidation extends HttpApi
* *
* @return ValidateResponse|ResponseInterface * @return ValidateResponse|ResponseInterface
*/ */
public function validate(string $address, bool $mailboxVerification = false) public function validate(string $address)
{ {
Assert::stringNotEmpty($address); Assert::stringNotEmpty($address);
$params = [ $params = ['address' => $address];
'address' => $address,
'mailbox_verification' => $mailboxVerification,
];
$response = $this->httpGet('/v4/address/validate', $params); $response = $this->httpGet('/v4/address/validate', $params);

View File

@ -26,10 +26,7 @@ class EmailValidationTest extends TestCase
public function testValidEmail() public function testValidEmail()
{ {
$params = [ $params = ['address' => 'foo@mailgun.net'];
'address' => 'me@davidgarcia.cat',
'mailbox_verification' => true,
];
$api = $this->getApiMock(); $api = $this->getApiMock();