| @@ 27-115 (lines=89) @@ | ||
| 24 | * |
|
| 25 | * @author Sean Johnson <[email protected]> |
|
| 26 | */ |
|
| 27 | class Bounce extends HttpApi |
|
| 28 | { |
|
| 29 | use Pagination; |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @param string $domain Domain to list bounces for |
|
| 33 | * @param int $limit optional |
|
| 34 | * |
|
| 35 | * @return IndexResponse |
|
| 36 | */ |
|
| 37 | public function index(string $domain, int $limit = 100) |
|
| 38 | { |
|
| 39 | Assert::stringNotEmpty($domain); |
|
| 40 | Assert::range($limit, 1, 10000, '"Limit" parameter must be between 1 and 10000'); |
|
| 41 | ||
| 42 | $params = [ |
|
| 43 | 'limit' => $limit, |
|
| 44 | ]; |
|
| 45 | ||
| 46 | $response = $this->httpGet(sprintf('/v3/%s/bounces', $domain), $params); |
|
| 47 | ||
| 48 | return $this->hydrateResponse($response, IndexResponse::class); |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * @param string $domain Domain to show bounce from |
|
| 53 | * @param string $address Bounce address to show |
|
| 54 | * |
|
| 55 | * @return ShowResponse |
|
| 56 | */ |
|
| 57 | public function show(string $domain, string $address) |
|
| 58 | { |
|
| 59 | Assert::stringNotEmpty($domain); |
|
| 60 | Assert::stringNotEmpty($address); |
|
| 61 | ||
| 62 | $response = $this->httpGet(sprintf('/v3/%s/bounces/%s', $domain, $address)); |
|
| 63 | ||
| 64 | return $this->hydrateResponse($response, ShowResponse::class); |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * @param string $domain Domain to create a bounce for |
|
| 69 | * @param string $address Address to create a bounce for |
|
| 70 | * @param array $params optional |
|
| 71 | * |
|
| 72 | * @return CreateResponse |
|
| 73 | */ |
|
| 74 | public function create(string $domain, string $address, array $params = []) |
|
| 75 | { |
|
| 76 | Assert::stringNotEmpty($domain); |
|
| 77 | Assert::stringNotEmpty($address); |
|
| 78 | ||
| 79 | $params['address'] = $address; |
|
| 80 | ||
| 81 | $response = $this->httpPost(sprintf('/v3/%s/bounces', $domain), $params); |
|
| 82 | ||
| 83 | return $this->hydrateResponse($response, CreateResponse::class); |
|
| 84 | } |
|
| 85 | ||
| 86 | /** |
|
| 87 | * @param string $domain Domain to delete a bounce for |
|
| 88 | * @param string $address Bounce address to delete |
|
| 89 | * |
|
| 90 | * @return DeleteResponse |
|
| 91 | */ |
|
| 92 | public function delete(string $domain, string $address) |
|
| 93 | { |
|
| 94 | Assert::stringNotEmpty($domain); |
|
| 95 | Assert::stringNotEmpty($address); |
|
| 96 | ||
| 97 | $response = $this->httpDelete(sprintf('/v3/%s/bounces/%s', $domain, $address)); |
|
| 98 | ||
| 99 | return $this->hydrateResponse($response, DeleteResponse::class); |
|
| 100 | } |
|
| 101 | ||
| 102 | /** |
|
| 103 | * @param string $domain Domain to delete all bounces for |
|
| 104 | * |
|
| 105 | * @return DeleteResponse |
|
| 106 | */ |
|
| 107 | public function deleteAll(string $domain) |
|
| 108 | { |
|
| 109 | Assert::stringNotEmpty($domain); |
|
| 110 | ||
| 111 | $response = $this->httpDelete(sprintf('/v3/%s/bounces', $domain)); |
|
| 112 | ||
| 113 | return $this->hydrateResponse($response, DeleteResponse::class); |
|
| 114 | } |
|
| 115 | } |
|
| 116 | ||
| @@ 27-115 (lines=89) @@ | ||
| 24 | * |
|
| 25 | * @author Sean Johnson <[email protected]> |
|
| 26 | */ |
|
| 27 | class Unsubscribe extends HttpApi |
|
| 28 | { |
|
| 29 | use Pagination; |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @param string $domain Domain to get unsubscribes for |
|
| 33 | * @param int $limit optional |
|
| 34 | * |
|
| 35 | * @return IndexResponse |
|
| 36 | */ |
|
| 37 | public function index(string $domain, int $limit = 100) |
|
| 38 | { |
|
| 39 | Assert::stringNotEmpty($domain); |
|
| 40 | Assert::range($limit, 1, 10000, 'Limit parameter must be between 1 and 10000'); |
|
| 41 | ||
| 42 | $params = [ |
|
| 43 | 'limit' => $limit, |
|
| 44 | ]; |
|
| 45 | ||
| 46 | $response = $this->httpGet(sprintf('/v3/%s/unsubscribes', $domain), $params); |
|
| 47 | ||
| 48 | return $this->hydrateResponse($response, IndexResponse::class); |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * @param string $domain Domain to show unsubscribe for |
|
| 53 | * @param string $address Unsubscribe address |
|
| 54 | * |
|
| 55 | * @return ShowResponse |
|
| 56 | */ |
|
| 57 | public function show(string $domain, string $address) |
|
| 58 | { |
|
| 59 | Assert::stringNotEmpty($domain); |
|
| 60 | Assert::stringNotEmpty($address); |
|
| 61 | ||
| 62 | $response = $this->httpGet(sprintf('/v3/%s/unsubscribes/%s', $domain, $address)); |
|
| 63 | ||
| 64 | return $this->hydrateResponse($response, ShowResponse::class); |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * @param string $domain Domain to create unsubscribe for |
|
| 69 | * @param string $address Unsubscribe address |
|
| 70 | * @param array $params optional |
|
| 71 | * |
|
| 72 | * @return CreateResponse |
|
| 73 | */ |
|
| 74 | public function create(string $domain, string $address, array $params = []) |
|
| 75 | { |
|
| 76 | Assert::stringNotEmpty($domain); |
|
| 77 | Assert::stringNotEmpty($address); |
|
| 78 | ||
| 79 | $params['address'] = $address; |
|
| 80 | ||
| 81 | $response = $this->httpPost(sprintf('/v3/%s/unsubscribes', $domain), $params); |
|
| 82 | ||
| 83 | return $this->hydrateResponse($response, CreateResponse::class); |
|
| 84 | } |
|
| 85 | ||
| 86 | /** |
|
| 87 | * @param string $domain Domain to delete unsubscribe for |
|
| 88 | * @param string $address Unsubscribe address |
|
| 89 | * |
|
| 90 | * @return DeleteResponse |
|
| 91 | */ |
|
| 92 | public function delete(string $domain, string $address) |
|
| 93 | { |
|
| 94 | Assert::stringNotEmpty($domain); |
|
| 95 | Assert::stringNotEmpty($address); |
|
| 96 | ||
| 97 | $response = $this->httpDelete(sprintf('/v3/%s/unsubscribes/%s', $domain, $address)); |
|
| 98 | ||
| 99 | return $this->hydrateResponse($response, DeleteResponse::class); |
|
| 100 | } |
|
| 101 | ||
| 102 | /** |
|
| 103 | * @param string $domain Domain to delete all unsubscribes for |
|
| 104 | * |
|
| 105 | * @return DeleteResponse |
|
| 106 | */ |
|
| 107 | public function deleteAll(string $domain) |
|
| 108 | { |
|
| 109 | Assert::stringNotEmpty($domain); |
|
| 110 | ||
| 111 | $response = $this->httpDelete(sprintf('/v3/%s/unsubscribes', $domain)); |
|
| 112 | ||
| 113 | return $this->hydrateResponse($response, DeleteResponse::class); |
|
| 114 | } |
|
| 115 | } |
|
| 116 | ||