From 1f1e28aaa83ff56c438fe159d586ad397797affd Mon Sep 17 00:00:00 2001 From: Oleksandr Mykhailenko Date: Sat, 3 Aug 2024 14:01:05 +0300 Subject: [PATCH] Add import method to the Unsubscribe --- src/Api/Suppression/Unsubscribe.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Api/Suppression/Unsubscribe.php b/src/Api/Suppression/Unsubscribe.php index 3f1ba28e..646470fb 100644 --- a/src/Api/Suppression/Unsubscribe.php +++ b/src/Api/Suppression/Unsubscribe.php @@ -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); + } }