@@ 30-45 (lines=16) @@ | ||
27 | * |
|
28 | * @return mixed|ResponseInterface |
|
29 | */ |
|
30 | public function create(string $projectKey, string $name, array $params = []) |
|
31 | { |
|
32 | $params['name'] = $name; |
|
33 | ||
34 | $response = $this->httpPost(sprintf('/api/v2/projects/%s/keys', $projectKey), $params); |
|
35 | ||
36 | if (!$this->hydrator) { |
|
37 | return $response; |
|
38 | } |
|
39 | ||
40 | if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) { |
|
41 | $this->handleErrors($response); |
|
42 | } |
|
43 | ||
44 | return $this->hydrator->hydrate($response, KeyCreated::class); |
|
45 | } |
|
46 | ||
47 | /** |
|
48 | * Search keys. |
@@ 32-47 (lines=16) @@ | ||
29 | * |
|
30 | * @return string|ResponseInterface |
|
31 | */ |
|
32 | public function download(string $projectKey, string $localeId, string $ext, array $params = []) |
|
33 | { |
|
34 | $params['file_format'] = $ext; |
|
35 | ||
36 | $response = $this->httpGet(sprintf('/api/v2/projects/%s/locales/%s/download', $projectKey, $localeId), $params); |
|
37 | ||
38 | if (!$this->hydrator) { |
|
39 | return $response; |
|
40 | } |
|
41 | ||
42 | if ($response->getStatusCode() !== 200) { |
|
43 | $this->handleErrors($response); |
|
44 | } |
|
45 | ||
46 | return (string) $response->getBody(); |
|
47 | } |
|
48 | } |
|
49 |
@@ 90-105 (lines=16) @@ | ||
87 | * |
|
88 | * @return mixed|ResponseInterface |
|
89 | */ |
|
90 | public function update(string $projectKey, string $translationId, string $content, array $params = []) |
|
91 | { |
|
92 | $params['content'] = $content; |
|
93 | ||
94 | $response = $this->httpPatch(sprintf('/api/v2/projects/%s/translations/%s', $projectKey, $translationId), $params); |
|
95 | ||
96 | if (!$this->hydrator) { |
|
97 | return $response; |
|
98 | } |
|
99 | ||
100 | if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) { |
|
101 | $this->handleErrors($response); |
|
102 | } |
|
103 | ||
104 | return $this->hydrator->hydrate($response, TranslationUpdated::class); |
|
105 | } |
|
106 | ||
107 | /** |
|
108 | * List translations for a specific key. |