Skip to content

Commit fc8819b

Browse files
Merge pull request #917 from mailgun/DE-1256-api-unsubscribe-endpoint
Add import method to the Unsubscribe
2 parents 41d83ac + 1f1e28a commit fc8819b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/Api/Suppression/Unsubscribe.php

+23
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,27 @@ public function deleteAll(string $domain, array $requestHeaders = [])
125125

126126
return $this->hydrateResponse($response, DeleteResponse::class);
127127
}
128+
129+
/**
130+
* @param string $domain
131+
* @param string $filePath
132+
* @return mixed
133+
* @throws ClientExceptionInterface
134+
*/
135+
public function import(string $domain, string $filePath)
136+
{
137+
Assert::stringNotEmpty($domain);
138+
Assert::stringNotEmpty($filePath);
139+
Assert::fileExists($filePath);
140+
141+
$response = $this->httpPost(
142+
sprintf('/v3/%s/unsubscribes/import', $domain),
143+
['file' => fopen($filePath, 'r')],
144+
[
145+
'filename' => basename($filePath),
146+
]
147+
);
148+
149+
return $this->hydrateResponse($response, ShowResponse::class);
150+
}
128151
}

0 commit comments

Comments
 (0)