| @@ 25-128 (lines=104) @@ | ||
| 22 | * |
|
| 23 | * @author Tobias Nyholm <[email protected]> |
|
| 24 | */ |
|
| 25 | class Tag extends HttpApi |
|
| 26 | { |
|
| 27 | /** |
|
| 28 | * Returns a list of tags. |
|
| 29 | * |
|
| 30 | * @param string $domain |
|
| 31 | * @param int $limit |
|
| 32 | * |
|
| 33 | * @return IndexResponse|ResponseInterface |
|
| 34 | */ |
|
| 35 | public function index($domain, $limit = 100) |
|
| 36 | { |
|
| 37 | Assert::stringNotEmpty($domain); |
|
| 38 | Assert::integer($limit); |
|
| 39 | ||
| 40 | $params = [ |
|
| 41 | 'limit' => $limit, |
|
| 42 | ]; |
|
| 43 | ||
| 44 | $response = $this->httpGet(sprintf('/v3/%s/tags', $domain), $params); |
|
| 45 | ||
| 46 | return $this->safeDeserialize($response, IndexResponse::class); |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * Returns a single tag. |
|
| 51 | * |
|
| 52 | * @param string $domain Name of the domain |
|
| 53 | * @param string $tag |
|
| 54 | * |
|
| 55 | * @return ShowResponse|ResponseInterface |
|
| 56 | */ |
|
| 57 | public function show($domain, $tag) |
|
| 58 | { |
|
| 59 | Assert::stringNotEmpty($domain); |
|
| 60 | Assert::stringNotEmpty($tag); |
|
| 61 | ||
| 62 | $response = $this->httpGet(sprintf('/v3/%s/tags/%s', $domain, $tag)); |
|
| 63 | ||
| 64 | return $this->safeDeserialize($response, ShowResponse::class); |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Update a tag. |
|
| 69 | * |
|
| 70 | * @param string $domain |
|
| 71 | * @param string $tag |
|
| 72 | * @param string $description |
|
| 73 | * |
|
| 74 | * @return UpdateResponse|ResponseInterface |
|
| 75 | */ |
|
| 76 | public function update($domain, $tag, $description) |
|
| 77 | { |
|
| 78 | Assert::stringNotEmpty($domain); |
|
| 79 | Assert::stringNotEmpty($tag); |
|
| 80 | Assert::string($description); |
|
| 81 | ||
| 82 | $params = [ |
|
| 83 | 'description' => $description, |
|
| 84 | ]; |
|
| 85 | ||
| 86 | $response = $this->httpPut(sprintf('/v3/%s/tags/%s', $domain, $tag), $params); |
|
| 87 | ||
| 88 | return $this->safeDeserialize($response, UpdateResponse::class); |
|
| 89 | } |
|
| 90 | ||
| 91 | /** |
|
| 92 | * Returns statistics for a single tag. |
|
| 93 | * |
|
| 94 | * @param string $domain Name of the domain |
|
| 95 | * @param string $tag |
|
| 96 | * @param array $params |
|
| 97 | * |
|
| 98 | * @return StatisticsResponse|ResponseInterface |
|
| 99 | */ |
|
| 100 | public function stats($domain, $tag, array $params) |
|
| 101 | { |
|
| 102 | Assert::stringNotEmpty($domain); |
|
| 103 | Assert::stringNotEmpty($tag); |
|
| 104 | Assert::isArray($params); |
|
| 105 | ||
| 106 | $response = $this->httpGet(sprintf('/v3/%s/tags/%s/stats', $domain, $tag), $params); |
|
| 107 | ||
| 108 | return $this->safeDeserialize($response, StatisticsResponse::class); |
|
| 109 | } |
|
| 110 | ||
| 111 | /** |
|
| 112 | * Removes a tag from the account. |
|
| 113 | * |
|
| 114 | * @param string $domain Name of the domain |
|
| 115 | * @param string $tag |
|
| 116 | * |
|
| 117 | * @return DeleteResponse|ResponseInterface |
|
| 118 | */ |
|
| 119 | public function delete($domain, $tag) |
|
| 120 | { |
|
| 121 | Assert::stringNotEmpty($domain); |
|
| 122 | Assert::stringNotEmpty($tag); |
|
| 123 | ||
| 124 | $response = $this->httpDelete(sprintf('/v3/%s/tags/%s', $domain, $tag)); |
|
| 125 | ||
| 126 | return $this->safeDeserialize($response, DeleteResponse::class); |
|
| 127 | } |
|
| 128 | } |
|
| 129 | ||
| @@ 22-112 (lines=91) @@ | ||
| 19 | /** |
|
| 20 | * @author Tobias Nyholm <[email protected]> |
|
| 21 | */ |
|
| 22 | class Webhook extends HttpApi |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * @param string $domain |
|
| 26 | * |
|
| 27 | * @return IndexResponse |
|
| 28 | */ |
|
| 29 | public function index($domain) |
|
| 30 | { |
|
| 31 | Assert::notEmpty($domain); |
|
| 32 | $response = $this->httpGet(sprintf('/v3/domains/%s/webhooks', $domain)); |
|
| 33 | ||
| 34 | return $this->safeDeserialize($response, IndexResponse::class); |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * @param string $domain |
|
| 39 | * @param string $webhook |
|
| 40 | * |
|
| 41 | * @return ShowResponse |
|
| 42 | */ |
|
| 43 | public function show($domain, $webhook) |
|
| 44 | { |
|
| 45 | Assert::notEmpty($domain); |
|
| 46 | Assert::notEmpty($webhook); |
|
| 47 | $response = $this->httpGet(sprintf('/v3/domains/%s/webhooks/%s', $domain, $webhook)); |
|
| 48 | ||
| 49 | return $this->safeDeserialize($response, ShowResponse::class); |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * @param string $domain |
|
| 54 | * @param string $id |
|
| 55 | * @param string $url |
|
| 56 | * |
|
| 57 | * @return CreateResponse |
|
| 58 | */ |
|
| 59 | public function create($domain, $id, $url) |
|
| 60 | { |
|
| 61 | Assert::notEmpty($domain); |
|
| 62 | Assert::notEmpty($id); |
|
| 63 | Assert::notEmpty($url); |
|
| 64 | ||
| 65 | $params = [ |
|
| 66 | 'id' => $id, |
|
| 67 | 'url' => $url, |
|
| 68 | ]; |
|
| 69 | ||
| 70 | $response = $this->httpPost(sprintf('/v3/domains/%s/webhooks', $domain), $params); |
|
| 71 | ||
| 72 | return $this->safeDeserialize($response, CreateResponse::class); |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @param string $domain |
|
| 77 | * @param string $id |
|
| 78 | * @param string $url |
|
| 79 | * |
|
| 80 | * @return UpdateResponse |
|
| 81 | */ |
|
| 82 | public function update($domain, $id, $url) |
|
| 83 | { |
|
| 84 | Assert::notEmpty($domain); |
|
| 85 | Assert::notEmpty($id); |
|
| 86 | Assert::notEmpty($url); |
|
| 87 | ||
| 88 | $params = [ |
|
| 89 | 'url' => $url, |
|
| 90 | ]; |
|
| 91 | ||
| 92 | $response = $this->httpPut(sprintf('/v3/domains/%s/webhooks/%s', $domain, $id), $params); |
|
| 93 | ||
| 94 | return $this->safeDeserialize($response, UpdateResponse::class); |
|
| 95 | } |
|
| 96 | ||
| 97 | /** |
|
| 98 | * @param string $domain |
|
| 99 | * @param string $id |
|
| 100 | * |
|
| 101 | * @return DeleteResponse |
|
| 102 | */ |
|
| 103 | public function delete($domain, $id) |
|
| 104 | { |
|
| 105 | Assert::notEmpty($domain); |
|
| 106 | Assert::notEmpty($id); |
|
| 107 | ||
| 108 | $response = $this->httpDelete(sprintf('/v3/domains/%s/webhooks/%s', $domain, $id)); |
|
| 109 | ||
| 110 | return $this->safeDeserialize($response, DeleteResponse::class); |
|
| 111 | } |
|
| 112 | } |
|
| 113 | ||