Skip to content

Commit

Permalink
Merge pull request #917 from mailgun/DE-1256-api-unsubscribe-endpoint
Browse files Browse the repository at this point in the history
Add import method to the Unsubscribe
  • Loading branch information
oleksandr-mykhailenko authored Aug 3, 2024
2 parents 41d83ac + 1f1e28a commit fc8819b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Api/Suppression/Unsubscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,27 @@ public function deleteAll(string $domain, array $requestHeaders = [])

return $this->hydrateResponse($response, DeleteResponse::class);
}

/**
* @param string $domain
* @param string $filePath
* @return mixed
* @throws ClientExceptionInterface
*/
public function import(string $domain, string $filePath)
{
Assert::stringNotEmpty($domain);
Assert::stringNotEmpty($filePath);
Assert::fileExists($filePath);

$response = $this->httpPost(
sprintf('/v3/%s/unsubscribes/import', $domain),
['file' => fopen($filePath, 'r')],
[
'filename' => basename($filePath),
]
);

return $this->hydrateResponse($response, ShowResponse::class);
}
}

0 comments on commit fc8819b

Please sign in to comment.