| @@ 71-83 (lines=13) @@ | ||
| 68 | * @return string |
|
| 69 | * @throws \DigitalEquation\Teamwork\Exceptions\TeamworkHttpException |
|
| 70 | */ |
|
| 71 | public function inboxes(): string |
|
| 72 | { |
|
| 73 | try { |
|
| 74 | /** @var Response $response */ |
|
| 75 | $response = $this->client->get('inboxes.json'); |
|
| 76 | /** @var Stream $body */ |
|
| 77 | $body = $response->getBody(); |
|
| 78 | ||
| 79 | return $body->getContents(); |
|
| 80 | } catch (ClientException $e) { |
|
| 81 | throw new TeamworkHttpException($e->getMessage(), 400); |
|
| 82 | } |
|
| 83 | } |
|
| 84 | ||
| 85 | /** |
|
| 86 | * Return the current client info. |
|
| @@ 91-103 (lines=13) @@ | ||
| 88 | * @return string |
|
| 89 | * @throws \DigitalEquation\Teamwork\Exceptions\TeamworkHttpException |
|
| 90 | */ |
|
| 91 | public function me(): string |
|
| 92 | { |
|
| 93 | try { |
|
| 94 | /** @var Response $response */ |
|
| 95 | $response = $this->client->get('me.json'); |
|
| 96 | /** @var Stream $body */ |
|
| 97 | $body = $response->getBody(); |
|
| 98 | ||
| 99 | return $body->getContents(); |
|
| 100 | } catch (ClientException $e) { |
|
| 101 | throw new TeamworkHttpException($e->getMessage(), 400); |
|
| 102 | } |
|
| 103 | } |
|
| 104 | ||
| 105 | /** |
|
| 106 | * Upload file to teamwork desk. |
|
| @@ 36-48 (lines=13) @@ | ||
| 33 | * @return string |
|
| 34 | * @throws \DigitalEquation\Teamwork\Exceptions\TeamworkHttpException |
|
| 35 | */ |
|
| 36 | public function getSites(): string |
|
| 37 | { |
|
| 38 | try { |
|
| 39 | /** @var Response $response */ |
|
| 40 | $response = $this->client->get('helpdocs/sites.json'); |
|
| 41 | /** @var Stream $body */ |
|
| 42 | $body = $response->getBody(); |
|
| 43 | ||
| 44 | return $body->getContents(); |
|
| 45 | } catch (ClientException $e) { |
|
| 46 | throw new TeamworkHttpException($e->getMessage(), 400); |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * Get Helpdocs site. |
|
| @@ 58-70 (lines=13) @@ | ||
| 55 | * @return string |
|
| 56 | * @throws \DigitalEquation\Teamwork\Exceptions\TeamworkHttpException |
|
| 57 | */ |
|
| 58 | public function getSite($siteID): string |
|
| 59 | { |
|
| 60 | try { |
|
| 61 | /** @var Response $response */ |
|
| 62 | $response = $this->client->get(sprintf('helpdocs/sites/%s.json', $siteID)); |
|
| 63 | /** @var Stream $body */ |
|
| 64 | $body = $response->getBody(); |
|
| 65 | ||
| 66 | return $body->getContents(); |
|
| 67 | } catch (ClientException $e) { |
|
| 68 | throw new TeamworkHttpException($e->getMessage(), 400); |
|
| 69 | } |
|
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * Get articles within a category. |
|
| @@ 130-142 (lines=13) @@ | ||
| 127 | * @return string |
|
| 128 | * @throws \DigitalEquation\Teamwork\Exceptions\TeamworkHttpException |
|
| 129 | */ |
|
| 130 | public function getArticle($articleID): string |
|
| 131 | { |
|
| 132 | try { |
|
| 133 | /** @var Response $response */ |
|
| 134 | $response = $this->client->get(sprintf('helpdocs/articles/%s.json', $articleID)); |
|
| 135 | /** @var Stream $body */ |
|
| 136 | $body = $response->getBody(); |
|
| 137 | ||
| 138 | return $body->getContents(); |
|
| 139 | } catch (ClientException $e) { |
|
| 140 | throw new TeamworkHttpException($e->getMessage(), 400); |
|
| 141 | } |
|
| 142 | } |
|
| 143 | ||
| 144 | /** |
|
| 145 | * Get articles (in bulk) |
|
| @@ 182-194 (lines=13) @@ | ||
| 179 | * @return string |
|
| 180 | * @throws \DigitalEquation\Teamwork\Exceptions\TeamworkHttpException |
|
| 181 | */ |
|
| 182 | public function getSiteCategories($siteID): string |
|
| 183 | { |
|
| 184 | try { |
|
| 185 | /** @var Response $response */ |
|
| 186 | $response = $this->client->get(sprintf('helpdocs/sites/%s/categories.json', $siteID)); |
|
| 187 | /** @var Stream $body */ |
|
| 188 | $body = $response->getBody(); |
|
| 189 | ||
| 190 | return $body->getContents(); |
|
| 191 | } catch (ClientException $e) { |
|
| 192 | throw new TeamworkHttpException($e->getMessage(), 400); |
|
| 193 | } |
|
| 194 | } |
|
| 195 | } |
|
| 196 | ||
| @@ 35-47 (lines=13) @@ | ||
| 32 | * @return string |
|
| 33 | * @throws \DigitalEquation\Teamwork\Exceptions\TeamworkHttpException |
|
| 34 | */ |
|
| 35 | public function priorities(): string |
|
| 36 | { |
|
| 37 | try { |
|
| 38 | /** @var Response $response */ |
|
| 39 | $response = $this->client->get('ticketpriorities.json'); |
|
| 40 | /** @var Stream $body */ |
|
| 41 | $body = $response->getBody(); |
|
| 42 | ||
| 43 | return $body->getContents(); |
|
| 44 | } catch (ClientException $e) { |
|
| 45 | throw new TeamworkHttpException($e->getMessage(), 400); |
|
| 46 | } |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * Get a list of tickets for a customer. |
|
| @@ 57-69 (lines=13) @@ | ||
| 54 | * @return string |
|
| 55 | * @throws \DigitalEquation\Teamwork\Exceptions\TeamworkHttpException |
|
| 56 | */ |
|
| 57 | public function customer($customerId): string |
|
| 58 | { |
|
| 59 | try { |
|
| 60 | /** @var Response $response */ |
|
| 61 | $response = $this->client->get(sprintf('customers/%s/previoustickets.json', $customerId)); |
|
| 62 | /** @var Stream $body */ |
|
| 63 | $body = $response->getBody(); |
|
| 64 | ||
| 65 | return $body->getContents(); |
|
| 66 | } catch (ClientException $e) { |
|
| 67 | throw new TeamworkHttpException($e->getMessage(), 400); |
|
| 68 | } |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * Send a ticket to teamwork desk. |
|
| @@ 79-94 (lines=16) @@ | ||
| 76 | * @return string |
|
| 77 | * @throws \DigitalEquation\Teamwork\Exceptions\TeamworkHttpException |
|
| 78 | */ |
|
| 79 | public function post($data): string |
|
| 80 | { |
|
| 81 | try { |
|
| 82 | /** @var Response $response */ |
|
| 83 | $response = $this->client->post('tickets.json', [ |
|
| 84 | 'form_params' => $data, |
|
| 85 | ]); |
|
| 86 | ||
| 87 | /** @var Stream $body */ |
|
| 88 | $body = $response->getBody(); |
|
| 89 | ||
| 90 | return $body->getContents(); |
|
| 91 | } catch (ClientException $e) { |
|
| 92 | throw new TeamworkHttpException($e->getMessage(), 400); |
|
| 93 | } |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * Post a reply to a ticket. |
|
| @@ 134-146 (lines=13) @@ | ||
| 131 | * @return string |
|
| 132 | * @throws \DigitalEquation\Teamwork\Exceptions\TeamworkHttpException |
|
| 133 | */ |
|
| 134 | public function ticket($ticketId): string |
|
| 135 | { |
|
| 136 | try { |
|
| 137 | /** @var Response $response */ |
|
| 138 | $response = $this->client->get(sprintf('tickets/%s.json', $ticketId)); |
|
| 139 | /** @var Stream $body */ |
|
| 140 | $body = $response->getBody(); |
|
| 141 | ||
| 142 | return $body->getContents(); |
|
| 143 | } catch (ClientException $e) { |
|
| 144 | throw new TeamworkHttpException($e->getMessage(), 400); |
|
| 145 | } |
|
| 146 | } |
|
| 147 | } |
|
| 148 | ||