diff --git a/src/Api/Suppression/Unsubscribe.php b/src/Api/Suppression/Unsubscribe.php index db6dbf4..762caae 100644 --- a/src/Api/Suppression/Unsubscribe.php +++ b/src/Api/Suppression/Unsubscribe.php @@ -84,17 +84,23 @@ class Unsubscribe extends HttpApi } /** - * @param string $domain Domain to delete unsubscribe for + * @param string $domain Domain to delete unsubscribe for * @param string $address Unsubscribe address - * + * @param string|null $tag Unsubscribe tag * @return DeleteResponse */ - public function delete(string $domain, string $address) + public function delete(string $domain, string $address, string $tag = null) { Assert::stringNotEmpty($domain); Assert::stringNotEmpty($address); + Assert::nullOrStringNotEmpty($tag); - $response = $this->httpDelete(sprintf('/v3/%s/unsubscribes/%s', $domain, $address)); + $params = []; + if (!is_null($tag)) { + $params['tag'] = $tag; + } + + $response = $this->httpDelete(sprintf('/v3/%s/unsubscribes/%s', $domain, $address), $params); return $this->hydrateResponse($response, DeleteResponse::class); } diff --git a/tests/Api/Suppression/UnsubscribeTest.php b/tests/Api/Suppression/UnsubscribeTest.php index c4ec05f..eb4a31c 100644 --- a/tests/Api/Suppression/UnsubscribeTest.php +++ b/tests/Api/Suppression/UnsubscribeTest.php @@ -65,6 +65,17 @@ class UnsubscribeTest extends TestCase $api->delete('example.com', 'foo@bar.com'); } + public function testDeleteWithTag() + { + $this->setRequestMethod('DELETE'); + $this->setRequestUri('/v3/example.com/unsubscribes/foo@bar.com'); + $this->setRequestBody(['tag' => 'tag1']); + $this->setHydrateClass(DeleteResponse::class); + + $api = $this->getApiInstance(); + $api->delete('example.com', 'foo@bar.com', 'tag1'); + } + public function testDeleteAll() { $this->setRequestMethod('DELETE');