mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-22 12:36:02 +03:00
add unsubscribe delete parameter.
This commit is contained in:
parent
16d0a04014
commit
8390bdd803
@ -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 $address Unsubscribe address
|
||||||
*
|
* @param string|null $tag Unsubscribe tag
|
||||||
* @return DeleteResponse
|
* @return DeleteResponse
|
||||||
*/
|
*/
|
||||||
public function delete(string $domain, string $address)
|
public function delete(string $domain, string $address, string $tag = null)
|
||||||
{
|
{
|
||||||
Assert::stringNotEmpty($domain);
|
Assert::stringNotEmpty($domain);
|
||||||
Assert::stringNotEmpty($address);
|
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);
|
return $this->hydrateResponse($response, DeleteResponse::class);
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,17 @@ class UnsubscribeTest extends TestCase
|
|||||||
$api->delete('example.com', 'foo@bar.com');
|
$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()
|
public function testDeleteAll()
|
||||||
{
|
{
|
||||||
$this->setRequestMethod('DELETE');
|
$this->setRequestMethod('DELETE');
|
||||||
|
Loading…
Reference in New Issue
Block a user