diff --git a/src/Model/EmailValidation/ValidateResponse.php b/src/Model/EmailValidation/ValidateResponse.php index bc2f285..c8b8bd1 100644 --- a/src/Model/EmailValidation/ValidateResponse.php +++ b/src/Model/EmailValidation/ValidateResponse.php @@ -23,11 +23,6 @@ final class ValidateResponse implements ApiResponse */ private $address; - /** - * @var string|null - */ - private $didYouMean; - /** * @var bool */ @@ -39,24 +34,19 @@ final class ValidateResponse implements ApiResponse private $isRoleAddress; /** - * @var bool + * @var string[] */ - private $isValid; - - /** - * @var bool - */ - private $mailboxVerification; - - /** - * @var Parts - */ - private $parts; + private $reason; /** * @var string|null */ - private $reason; + private $result; + + /** + * @var string|null + */ + private $risk; private function __construct() { @@ -66,13 +56,11 @@ final class ValidateResponse implements ApiResponse { $model = new self(); $model->address = $data['address'] ?? null; - $model->didYouMean = $data['did_you_mean'] ?? null; $model->isDisposableAddress = $data['is_disposable_address'] ?? false; $model->isRoleAddress = $data['is_role_address'] ?? false; - $model->isValid = $data['is_valid'] ?? false; - $model->mailboxVerification = isset($data['mailbox_verification']) ? 'true' === $data['mailbox_verification'] : false; - $model->parts = Parts::create($data['parts'] ?? []); - $model->reason = $data['reason'] ?? null; + $model->reason = $data['reason'] ?? []; + $model->result = $data['result'] ?? null; + $model->risk = $data['risk'] ?? null; return $model; } @@ -82,11 +70,6 @@ final class ValidateResponse implements ApiResponse return $this->address; } - public function getDidYouMean(): ?string - { - return $this->didYouMean; - } - public function isDisposableAddress(): bool { return $this->isDisposableAddress; @@ -97,23 +80,24 @@ final class ValidateResponse implements ApiResponse return $this->isRoleAddress; } - public function isValid(): bool - { - return $this->isValid; - } - - public function isMailboxVerification(): bool - { - return $this->mailboxVerification; - } - - public function getParts(): Parts - { - return $this->parts; - } - - public function getReason(): ?string + public function getReason(): array { return $this->reason; } + + /** + * @return string|null + */ + public function getResult(): ?string + { + return $this->result; + } + + /** + * @return string|null + */ + public function getRisk(): ?string + { + return $this->risk; + } } diff --git a/tests/Model/EmailValidation/ValidateResponseTest.php b/tests/Model/EmailValidation/ValidateResponseTest.php index d5aa6bf..ede86cf 100644 --- a/tests/Model/EmailValidation/ValidateResponseTest.php +++ b/tests/Model/EmailValidation/ValidateResponseTest.php @@ -23,67 +23,35 @@ class ValidateResponseTest extends BaseModelTest <<<'JSON' { "address": "foo@mailgun.net", - "did_you_mean": null, "is_disposable_address": false, "is_role_address": true, - "is_valid": true, - "mailbox_verification": "true", - "parts": { - "display_name": null, - "domain": "mailgun.net", - "local_part": "foo" - } + "reason": [], + "result": "deliverable", + "risk": "low" } JSON; $model = ValidateResponse::create(json_decode($json, true)); $this->assertTrue($model->isMailboxVerification()); } - public function testCreateWithoutMailboxVerification() - { - $json = - <<<'JSON' -{ - "address": "foo@mailgun.net", - "did_you_mean": null, - "is_disposable_address": false, - "is_role_address": false, - "is_valid": true, - "mailbox_verification": null, - "parts": { - "display_name": null, - "domain": "mailgun.net", - "local_part": "foo" - }, - "reason": null -} -JSON; - $model = ValidateResponse::create(json_decode($json, true)); - $this->assertFalse($model->isMailboxVerification()); - } - public function testEmailValidation() { $data = [ 'address' => 'foo@mailgun.net', - 'did_you_mean' => null, 'is_disposable_address' => false, 'is_role_address' => false, - 'is_valid' => true, - 'mailbox_verification' => null, - 'parts' => ['display_name' => null, 'domain' => 'mailgun.net', 'local_part' => 'foo'], - 'reason' => null, + 'reason' => [], + 'result' => 'deliverable', + 'risk' => 'low' ]; $parts = ValidateResponse::create($data); $this->assertEquals($data['address'], $parts->getAddress()); - $this->assertEquals($data['did_you_mean'], $parts->getDidYouMean()); $this->assertEquals($data['is_disposable_address'], $parts->isDisposableAddress()); $this->assertEquals($data['is_role_address'], $parts->isRoleAddress()); - $this->assertEquals($data['is_valid'], $parts->isValid()); - $this->assertEquals($data['mailbox_verification'], $parts->isMailboxVerification()); - $this->assertInstanceOf(Parts::class, $parts->getParts()); $this->assertEquals($data['reason'], $parts->getReason()); + $this->assertEquals($data['result'], $parts->getResult()); + $this->assertEquals($data['risk'], $parts->getRisk()); } }