| @@ 31-49 (lines=19) @@ | ||
| 28 | * |
|
| 29 | * @return mixed|ResponseInterface |
|
| 30 | */ |
|
| 31 | public function indexLocale(string $projectKey, string $localeId, array $params = []) |
|
| 32 | { |
|
| 33 | if (isset($params['tags'])) { |
|
| 34 | $params['q'] = 'tags:'.$params['tags']; |
|
| 35 | unset($params['tags']); |
|
| 36 | } |
|
| 37 | ||
| 38 | $response = $this->httpGet(sprintf('/api/v2/projects/%s/locales/%s/translations', $projectKey, $localeId), $params); |
|
| 39 | ||
| 40 | if (!$this->hydrator) { |
|
| 41 | return $response; |
|
| 42 | } |
|
| 43 | ||
| 44 | if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) { |
|
| 45 | $this->handleErrors($response); |
|
| 46 | } |
|
| 47 | ||
| 48 | return $this->hydrator->hydrate($response, Index::class); |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * Create a translation. |
|
| @@ 116-134 (lines=19) @@ | ||
| 113 | * |
|
| 114 | * @return mixed|ResponseInterface |
|
| 115 | */ |
|
| 116 | public function indexKey(string $projectKey, string $keyId, array $params = []) |
|
| 117 | { |
|
| 118 | if (isset($params['tags'])) { |
|
| 119 | $params['q'] = 'tags:'.$params['tags']; |
|
| 120 | unset($params['tags']); |
|
| 121 | } |
|
| 122 | ||
| 123 | $response = $this->httpGet(sprintf('/api/v2/projects/%s/keys/%s/translations', $projectKey, $keyId), $params); |
|
| 124 | ||
| 125 | if (!$this->hydrator) { |
|
| 126 | return $response; |
|
| 127 | } |
|
| 128 | ||
| 129 | if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) { |
|
| 130 | $this->handleErrors($response); |
|
| 131 | } |
|
| 132 | ||
| 133 | return $this->hydrator->hydrate($response, Index::class); |
|
| 134 | } |
|
| 135 | } |
|
| 136 | ||