diff --git a/src/Mailgun/Api/Suppression/Complaint.php b/src/Mailgun/Api/Suppression/Complaint.php index ec5575a..cd7a3d9 100644 --- a/src/Mailgun/Api/Suppression/Complaint.php +++ b/src/Mailgun/Api/Suppression/Complaint.php @@ -72,10 +72,10 @@ class Complaint extends HttpApi { Assert::stringNotEmpty($domain); Assert::stringNotEmpty($address); - Assert::stringNotEmpty($createdAt); $params['address'] = $address; if (null !== $createdAt) { + Assert::stringNotEmpty($createdAt); $params['created_at'] = $createdAt; } diff --git a/tests/Api/Suppression/BounceTest.php b/tests/Api/Suppression/BounceTest.php index 07b7e05..ef31dbe 100644 --- a/tests/Api/Suppression/BounceTest.php +++ b/tests/Api/Suppression/BounceTest.php @@ -67,7 +67,7 @@ class BounceTest extends TestCase $this->setHydrateClass(DeleteResponse::class); $api = $this->getApiInstance(); - $api->show('example.com', 'foo@bar.com'); + $api->delete('example.com', 'foo@bar.com'); } public function testDeleteAll() @@ -77,7 +77,7 @@ class BounceTest extends TestCase $this->setHydrateClass(DeleteResponse::class); $api = $this->getApiInstance(); - $api->show('example.com'); + $api->deleteAll('example.com'); } /** diff --git a/tests/Api/Suppression/ComplaintTest.php b/tests/Api/Suppression/ComplaintTest.php new file mode 100644 index 0000000..7eaf62d --- /dev/null +++ b/tests/Api/Suppression/ComplaintTest.php @@ -0,0 +1,89 @@ + + */ +class ComplaintTest extends TestCase +{ + public function testIndex() + { + $this->setRequestMethod('GET'); + $this->setRequestUri('/v3/example.com/complaints?limit=100'); + $this->setHydrateClass(IndexResponse::class); + + $api = $this->getApiInstance(); + $api->index('example.com'); + } + + public function testShow() + { + $this->setRequestMethod('GET'); + $this->setRequestUri('/v3/example.com/complaints/foo@bar.com'); + $this->setHydrateClass(ShowResponse::class); + + $api = $this->getApiInstance(); + $api->show('example.com', 'foo@bar.com'); + } + + public function testCreate() + { + $this->setRequestMethod('POST'); + $this->setRequestUri('/v3/example.com/complaints'); + $this->setHydrateClass(CreateResponse::class); + $this->setRequestBody([ + 'address' => 'foo@bar.com', + ]); + + $api = $this->getApiInstance(); + $api->create('example.com', 'foo@bar.com'); + } + + + public function testDelete() + { + $this->setRequestMethod('DELETE'); + $this->setRequestUri('/v3/example.com/complaints/foo@bar.com'); + $this->setHydrateClass(DeleteResponse::class); + + $api = $this->getApiInstance(); + $api->delete('example.com', 'foo@bar.com'); + } + + public function testDeleteAll() + { + $this->setRequestMethod('DELETE'); + $this->setRequestUri('/v3/example.com/complaints'); + $this->setHydrateClass(DeleteResponse::class); + + $api = $this->getApiInstance(); + $api->deleteAll('example.com'); + } + + /** + * {@inheritdoc} + */ + protected function getApiClass() + { + return Complaint::class; + } +}