mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-25 14:26:04 +03:00
email validation v4 fixes
This commit is contained in:
parent
2a35fcb077
commit
b454618229
0
src/Api/EmailValidationV4.php
Normal file → Executable file
0
src/Api/EmailValidationV4.php
Normal file → Executable file
@ -95,6 +95,8 @@ abstract class HttpApi
|
||||
throw HttpClientException::forbidden($response);
|
||||
case 404:
|
||||
throw HttpClientException::notFound($response);
|
||||
case 409:
|
||||
throw HttpClientException::conflict($response);
|
||||
case 413:
|
||||
throw HttpClientException::payloadTooLarge($response);
|
||||
case 500 <= $statusCode:
|
||||
|
@ -78,6 +78,11 @@ final class HttpClientException extends \RuntimeException implements Exception
|
||||
return new self('The endpoint you have tried to access does not exist. Check if the domain matches the domain you have configure on Mailgun.', 404, $response);
|
||||
}
|
||||
|
||||
public static function conflict(ResponseInterface $response)
|
||||
{
|
||||
return new self('Request conflicts with current state of the target resource.', 409, $response);
|
||||
}
|
||||
|
||||
public static function payloadTooLarge(ResponseInterface $response)
|
||||
{
|
||||
return new self('Payload too large, your total attachment size is too big.', 413, $response);
|
||||
|
0
src/Model/EmailValidationV4/CreateBulkJobResponse.php
Normal file → Executable file
0
src/Model/EmailValidationV4/CreateBulkJobResponse.php
Normal file → Executable file
0
src/Model/EmailValidationV4/DeleteBulkJobResponse.php
Normal file → Executable file
0
src/Model/EmailValidationV4/DeleteBulkJobResponse.php
Normal file → Executable file
0
src/Model/EmailValidationV4/GetBulkJobResponse.php
Normal file → Executable file
0
src/Model/EmailValidationV4/GetBulkJobResponse.php
Normal file → Executable file
0
src/Model/EmailValidationV4/GetBulkJobsResponse.php
Normal file → Executable file
0
src/Model/EmailValidationV4/GetBulkJobsResponse.php
Normal file → Executable file
0
src/Model/EmailValidationV4/GetBulkPreviewResponse.php
Normal file → Executable file
0
src/Model/EmailValidationV4/GetBulkPreviewResponse.php
Normal file → Executable file
0
src/Model/EmailValidationV4/GetBulkPreviewsResponse.php
Normal file → Executable file
0
src/Model/EmailValidationV4/GetBulkPreviewsResponse.php
Normal file → Executable file
14
src/Model/EmailValidationV4/Job.php
Normal file → Executable file
14
src/Model/EmailValidationV4/Job.php
Normal file → Executable file
@ -22,7 +22,7 @@ class Job implements ApiResponse
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* @var JobDownloadUrl
|
||||
* @var JobDownloadUrl|null
|
||||
*/
|
||||
private $downloadUrl;
|
||||
|
||||
@ -47,7 +47,7 @@ class Job implements ApiResponse
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* @var Summary
|
||||
* @var Summary|null
|
||||
*/
|
||||
private $summary;
|
||||
|
||||
@ -59,13 +59,13 @@ class Job implements ApiResponse
|
||||
{
|
||||
$model = new static();
|
||||
|
||||
$model->createdAt = isset($data['created_at']) ? new DateTimeImmutable($data['created_at']) : null;
|
||||
$model->downloadUrl = JobDownloadUrl::create($data['download_url']);
|
||||
$model->createdAt = isset($data['created_at']) ? (DateTimeImmutable::createFromFormat('U', (string) ($data['created_at'])) ?: null) : null;
|
||||
$model->downloadUrl = $data['download_url'] ? JobDownloadUrl::create($data['download_url']) : null;
|
||||
$model->id = $data['id'] ?? null;
|
||||
$model->quantity = $data['quantity'] ?? null;
|
||||
$model->recordsProcessed = $data['records_processed'] ?? null;
|
||||
$model->status = $data['status'] ?? null;
|
||||
$model->summary = Summary::create($data['summary']);
|
||||
$model->summary = $data['summary'] ? Summary::create($data['summary']) : null;
|
||||
|
||||
return $model;
|
||||
}
|
||||
@ -75,7 +75,7 @@ class Job implements ApiResponse
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function getDownloadUrl(): JobDownloadUrl
|
||||
public function getDownloadUrl(): ?JobDownloadUrl
|
||||
{
|
||||
return $this->downloadUrl;
|
||||
}
|
||||
@ -100,7 +100,7 @@ class Job implements ApiResponse
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function getSummary(): Summary
|
||||
public function getSummary(): ?Summary
|
||||
{
|
||||
return $this->summary;
|
||||
}
|
||||
|
0
src/Model/EmailValidationV4/JobDownloadUrl.php
Normal file → Executable file
0
src/Model/EmailValidationV4/JobDownloadUrl.php
Normal file → Executable file
8
src/Model/EmailValidationV4/Preview.php
Normal file → Executable file
8
src/Model/EmailValidationV4/Preview.php
Normal file → Executable file
@ -42,7 +42,7 @@ class Preview implements ApiResponse
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* @var Summary
|
||||
* @var Summary|null
|
||||
*/
|
||||
private $summary;
|
||||
|
||||
@ -58,8 +58,8 @@ class Preview implements ApiResponse
|
||||
$model->valid = $data['valid'] ?? null;
|
||||
$model->status = $data['status'] ?? null;
|
||||
$model->quantity = $data['quantity'] ?? null;
|
||||
$model->createdAt = isset($data['created_at']) ? DateTimeImmutable::createFromFormat('U', (string) ($data['created_at'])) : null;
|
||||
$model->summary = Summary::create($data['summary']);
|
||||
$model->createdAt = isset($data['created_at']) ? (DateTimeImmutable::createFromFormat('U', (string) ($data['created_at'])) ?: null) : null;
|
||||
$model->summary = $data['summary'] ? Summary::create($data['summary']) : null;
|
||||
|
||||
return $model;
|
||||
}
|
||||
@ -89,7 +89,7 @@ class Preview implements ApiResponse
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function getSummary(): Summary
|
||||
public function getSummary(): ?Summary
|
||||
{
|
||||
return $this->summary;
|
||||
}
|
||||
|
0
src/Model/EmailValidationV4/PromoteBulkPreviewResponse.php
Normal file → Executable file
0
src/Model/EmailValidationV4/PromoteBulkPreviewResponse.php
Normal file → Executable file
0
src/Model/EmailValidationV4/Summary.php
Normal file → Executable file
0
src/Model/EmailValidationV4/Summary.php
Normal file → Executable file
0
src/Model/EmailValidationV4/SummaryResult.php
Normal file → Executable file
0
src/Model/EmailValidationV4/SummaryResult.php
Normal file → Executable file
0
src/Model/EmailValidationV4/SummaryRisk.php
Normal file → Executable file
0
src/Model/EmailValidationV4/SummaryRisk.php
Normal file → Executable file
0
src/Model/EmailValidationV4/ValidateResponse.php
Normal file → Executable file
0
src/Model/EmailValidationV4/ValidateResponse.php
Normal file → Executable file
8
tests/Api/EmailValidationV4Test.php
Normal file → Executable file
8
tests/Api/EmailValidationV4Test.php
Normal file → Executable file
@ -116,7 +116,7 @@ JSON
|
||||
{
|
||||
"jobs": [
|
||||
{
|
||||
"created_at": "Tue, 26 Feb 2019 21:30:03 GMT",
|
||||
"created_at": 1590080191,
|
||||
"download_url": {
|
||||
"csv": "<download_link>",
|
||||
"json": "<download_link>"
|
||||
@ -142,7 +142,7 @@ JSON
|
||||
}
|
||||
},
|
||||
{
|
||||
"created_at": "Tue, 23 Feb 2019 21:30:03 GMT",
|
||||
"created_at": 1590080191,
|
||||
"download_url": {
|
||||
"csv": "<download_link>",
|
||||
"json": "<download_link>"
|
||||
@ -200,7 +200,7 @@ JSON
|
||||
$this->setRequestUri('/v4/address/validate/bulk/listId123');
|
||||
$this->setHttpResponse(new Response(200, ['Content-Type' => 'application/json'], <<<'JSON'
|
||||
{
|
||||
"created_at": "Sat, 23 Feb 2019 21:30:03 GMT",
|
||||
"created_at": 1590080191,
|
||||
"download_url": {
|
||||
"csv": "<download_link>",
|
||||
"json": "<download_link>"
|
||||
@ -236,7 +236,7 @@ JSON
|
||||
|
||||
$this->assertInstanceOf(GetBulkJobResponse::class, $response);
|
||||
$this->assertInstanceOf(Job::class, $response);
|
||||
$this->assertEquals('2019-02-23 21:30:03', $response->getCreatedAt()->format('Y-m-d H:i:s'));
|
||||
$this->assertEquals('2020-05-21 16:56:31', $response->getCreatedAt()->format('Y-m-d H:i:s'));
|
||||
$this->assertInstanceOf(JobDownloadUrl::class, $response->getDownloadUrl());
|
||||
$this->assertEquals('bulk_validations_sandbox_mailgun_org', $response->getId());
|
||||
$this->assertEquals(207, $response->getQuantity());
|
||||
|
0
tests/Model/EmailValidationV4/JobDownloadUrlTest.php
Normal file → Executable file
0
tests/Model/EmailValidationV4/JobDownloadUrlTest.php
Normal file → Executable file
4
tests/Model/EmailValidationV4/JobTest.php
Normal file → Executable file
4
tests/Model/EmailValidationV4/JobTest.php
Normal file → Executable file
@ -23,7 +23,7 @@ class JobTest extends BaseModelTest
|
||||
$json =
|
||||
<<<'JSON'
|
||||
{
|
||||
"created_at": "Sat, 23 Feb 2019 21:30:03 GMT",
|
||||
"created_at": 1590080191,
|
||||
"download_url": {
|
||||
"csv": "<download_link>",
|
||||
"json": "<download_link>"
|
||||
@ -50,7 +50,7 @@ class JobTest extends BaseModelTest
|
||||
}
|
||||
JSON;
|
||||
$model = Job::create(json_decode($json, true));
|
||||
$this->assertEquals('2019-02-23 21:30:03', $model->getCreatedAt()->format('Y-m-d H:i:s'));
|
||||
$this->assertEquals('2020-05-21 16:56:31', $model->getCreatedAt()->format('Y-m-d H:i:s'));
|
||||
$this->assertInstanceOf(JobDownloadUrl::class, $model->getDownloadUrl());
|
||||
$this->assertEquals('bulk_validations_sandbox_mailgun_org', $model->getId());
|
||||
$this->assertEquals(207, $model->getQuantity());
|
||||
|
0
tests/Model/EmailValidationV4/PreviewTest.php
Normal file → Executable file
0
tests/Model/EmailValidationV4/PreviewTest.php
Normal file → Executable file
0
tests/Model/EmailValidationV4/SummaryResultTest.php
Normal file → Executable file
0
tests/Model/EmailValidationV4/SummaryResultTest.php
Normal file → Executable file
0
tests/Model/EmailValidationV4/SummaryRiskTest.php
Normal file → Executable file
0
tests/Model/EmailValidationV4/SummaryRiskTest.php
Normal file → Executable file
0
tests/Model/EmailValidationV4/SummaryTest.php
Normal file → Executable file
0
tests/Model/EmailValidationV4/SummaryTest.php
Normal file → Executable file
Loading…
Reference in New Issue
Block a user