diff --git a/spec/Akeneo/Crowdin/Api/AddDirectorySpec.php b/spec/Akeneo/Crowdin/Api/AddDirectorySpec.php
index 30e4834..5e0b74a 100644
--- a/spec/Akeneo/Crowdin/Api/AddDirectorySpec.php
+++ b/spec/Akeneo/Crowdin/Api/AddDirectorySpec.php
@@ -41,8 +41,11 @@ public function it_adds_a_directory(HttpClientInterface $http, ResponseInterface
$response->getContent()->willReturn($content);
$http->request(
'POST',
- 'project/sylius/add-directory?key=1234',
- ['body' => ['name' => 'directory-to-create']]
+ 'project/sylius/add-directory',
+ [
+ 'headers' => ['Authorization' => 'Bearer 1234'],
+ 'body' => ['name' => 'directory-to-create']
+ ]
)->willReturn($response);
$this->execute()->shouldBe($content);
diff --git a/spec/Akeneo/Crowdin/Api/AddFileSpec.php b/spec/Akeneo/Crowdin/Api/AddFileSpec.php
index 7c65bc2..c929d73 100644
--- a/spec/Akeneo/Crowdin/Api/AddFileSpec.php
+++ b/spec/Akeneo/Crowdin/Api/AddFileSpec.php
@@ -47,7 +47,11 @@ public function it_should_not_add_with_no_file(HttpClientInterface $http, Respon
$content = '';
$response->getContent()->willReturn($content);
- $http->request('POST', 'project/sylius/add-file?key=1234')->willReturn($response);
+ $http->request(
+ 'POST',
+ 'project/sylius/add-file',
+ ['headers' => ['Authorization' => 'Bearer 1234']]
+ )->willReturn($response);
$this->shouldThrow('\InvalidArgumentException')->duringExecute();
}
@@ -61,10 +65,11 @@ public function it_adds_a_file(FileReader $fileReader, HttpClientInterface $http
$fileReader->readTranslation(Argument::any())->willReturn($fakeResource);
$http->request(
'POST',
- 'project/sylius/add-file?key=1234',
+ 'project/sylius/add-file',
[
'headers' => [
- 'Content-Type' => 'multipart/form-data'
+ 'Content-Type' => 'multipart/form-data',
+ 'Authorization' => 'Bearer 1234'
],
'body' => [
'files[path/to/crowdin.yml]' => $fakeResource,
diff --git a/spec/Akeneo/Crowdin/Api/ChangeDirectorySpec.php b/spec/Akeneo/Crowdin/Api/ChangeDirectorySpec.php
index ed4f2cc..da73874 100644
--- a/spec/Akeneo/Crowdin/Api/ChangeDirectorySpec.php
+++ b/spec/Akeneo/Crowdin/Api/ChangeDirectorySpec.php
@@ -33,8 +33,11 @@ public function it_should_set_name(
ResponseInterface $response
) {
$this->setName('myname');
- $path = 'project/sylius/change-directory?key=1234';
- $data = ['body' => ['name' => 'myname']];
+ $path = 'project/sylius/change-directory';
+ $data = [
+ 'headers' => ['Authorization' => 'Bearer 1234'],
+ 'body' => ['name' => 'myname']
+ ];
$http->request('POST', $path, $data)->willReturn($response);
$response->getContent(Argument::any())->willReturn('content');
@@ -50,8 +53,9 @@ public function it_should_set_data(
$this->setExportPattern('myExportPattern');
$this->setTitle('myTitle');
$this->setNewName('myNewName');
- $path = 'project/sylius/change-directory?key=1234';
+ $path = 'project/sylius/change-directory';
$data = [
+ 'headers' => ['Authorization' => 'Bearer 1234'],
'body' => [
'name' => 'myName',
'branch' => 'myBranch',
diff --git a/spec/Akeneo/Crowdin/Api/DeleteDirectorySpec.php b/spec/Akeneo/Crowdin/Api/DeleteDirectorySpec.php
index 711d465..373550e 100644
--- a/spec/Akeneo/Crowdin/Api/DeleteDirectorySpec.php
+++ b/spec/Akeneo/Crowdin/Api/DeleteDirectorySpec.php
@@ -27,7 +27,7 @@ public function it_should_not_delete_with_no_directory(HttpClientInterface $http
$content = '';
$response->getContent()->willReturn($content);
- $http->request('POST', 'project/sylius/delete-directory?key=1234')->willReturn($response);
+ $http->request('POST', 'project/sylius/delete-directory', ['headers' => ['Authorization' => 'Bearer 1234']])->willReturn($response);
$this->shouldThrow()->duringExecute();
}
@@ -38,8 +38,11 @@ public function it_deletes_a_directory(HttpClientInterface $http, ResponseInterf
$response->getContent()->willReturn($content);
$http->request(
'POST',
- 'project/sylius/delete-directory?key=1234',
- ['body' => ['name' => 'directory-to-delete']]
+ 'project/sylius/delete-directory',
+ [
+ 'headers' => ['Authorization' => 'Bearer 1234'],
+ 'body' => ['name' => 'directory-to-delete']
+ ]
)->willReturn($response);
$this->execute()->shouldBe($content);
diff --git a/spec/Akeneo/Crowdin/Api/DeleteFileSpec.php b/spec/Akeneo/Crowdin/Api/DeleteFileSpec.php
index 7290ce6..b0d7ebb 100644
--- a/spec/Akeneo/Crowdin/Api/DeleteFileSpec.php
+++ b/spec/Akeneo/Crowdin/Api/DeleteFileSpec.php
@@ -30,7 +30,7 @@ public function it_should_not_delete_with_no_file(HttpClientInterface $http, Res
$content = '';
$response->getContent()->willReturn($content);
- $http->request('POST', 'project/sylius/delete-file?key=1234')->willReturn($response);
+ $http->request('POST', 'project/sylius/delete-file', ['headers' => ['Authorization' => 'Bearer 1234']])->willReturn($response);
$this->shouldThrow()->duringExecute();
}
@@ -41,8 +41,11 @@ public function it_deletes_a_file(HttpClientInterface $http, ResponseInterface $
$response->getContent()->willReturn($content);
$http->request(
'POST',
- 'project/sylius/delete-file?key=1234',
- ['body' => ['file' => 'path/to/my/file']]
+ 'project/sylius/delete-file',
+ [
+ 'headers' => ['Authorization' => 'Bearer 1234'],
+ 'body' => ['file' => 'path/to/my/file']
+ ]
)->willReturn($response);
$this->execute()->shouldBe($content);
diff --git a/spec/Akeneo/Crowdin/Api/DownloadSpec.php b/spec/Akeneo/Crowdin/Api/DownloadSpec.php
index f8a8af8..b39afb5 100644
--- a/spec/Akeneo/Crowdin/Api/DownloadSpec.php
+++ b/spec/Akeneo/Crowdin/Api/DownloadSpec.php
@@ -44,7 +44,7 @@ public function it_downloads_all_translations(HttpClientInterface $http, Respons
{
$this->setCopyDestination('/tmp');
$this->setPackage('all.zip');
- $http->request('GET', 'project/akeneo/download/all.zip?key=1234')
+ $http->request('GET', 'project/akeneo/download/all.zip', ['headers' => ['Authorization' => 'Bearer 1234']])
->willReturn($response);
$response->getContent()->willReturn('translations content');
$this->execute()->shouldBe('translations content');
@@ -54,7 +54,7 @@ public function it_downloads_french_translations(HttpClientInterface $http, Resp
{
$this->setCopyDestination('/tmp');
$this->setPackage('fr.zip');
- $http->request('GET', 'project/akeneo/download/fr.zip?key=1234')
+ $http->request('GET', 'project/akeneo/download/fr.zip', ['headers' => ['Authorization' => 'Bearer 1234']])
->willReturn($response);
$response->getContent()->willReturn('translations content');
$this->execute()->shouldBe('translations content');
diff --git a/spec/Akeneo/Crowdin/Api/ExportSpec.php b/spec/Akeneo/Crowdin/Api/ExportSpec.php
index 6b73c7e..ee060a1 100644
--- a/spec/Akeneo/Crowdin/Api/ExportSpec.php
+++ b/spec/Akeneo/Crowdin/Api/ExportSpec.php
@@ -26,7 +26,7 @@ public function it_builds_last_translations(HttpClientInterface $http, ResponseI
{
$content = '';
$response->getContent()->willReturn($content);
- $http->request('GET', 'project/akeneo/export?key=1234')->willReturn($response);
+ $http->request('GET', 'project/akeneo/export', ['headers' => ['Authorization' => 'Bearer 1234']])->willReturn($response);
$this->execute()->shouldBe($content);
}
@@ -34,7 +34,7 @@ public function it_skips_build_if_less_than_half_an_hour(HttpClientInterface $ht
{
$content = '';
$response->getContent()->willReturn($content);
- $http->request('GET', 'project/akeneo/export?key=1234')->willReturn($response);
+ $http->request('GET', 'project/akeneo/export', ['headers' => ['Authorization' => 'Bearer 1234']])->willReturn($response);
$this->execute()->shouldBe($content);
}
}
diff --git a/spec/Akeneo/Crowdin/Api/InfoSpec.php b/spec/Akeneo/Crowdin/Api/InfoSpec.php
index eb17f82..3583b1b 100644
--- a/spec/Akeneo/Crowdin/Api/InfoSpec.php
+++ b/spec/Akeneo/Crowdin/Api/InfoSpec.php
@@ -15,7 +15,7 @@ public function let(Client $client, HttpClientInterface $http, ResponseInterface
$client->getHttpClient()->willReturn($http);
$client->getProjectIdentifier()->willReturn('akeneo');
$client->getProjectApiKey()->willReturn('1234');
- $http->request('GET', 'project/akeneo/info?key=1234')->willReturn($response);
+ $http->request('GET', 'project/akeneo/info', ['headers' => ['Authorization' => 'Bearer 1234']])->willReturn($response);
$response->getContent()->willReturn('');
$this->beConstructedWith($client);
}
diff --git a/spec/Akeneo/Crowdin/Api/LanguageStatusSpec.php b/spec/Akeneo/Crowdin/Api/LanguageStatusSpec.php
index 0531b7d..28ebdf5 100644
--- a/spec/Akeneo/Crowdin/Api/LanguageStatusSpec.php
+++ b/spec/Akeneo/Crowdin/Api/LanguageStatusSpec.php
@@ -29,8 +29,11 @@ public function it_gets_project_language_status(
$this->setLanguage('fr')->shouldBe($this);
$http->request(
'POST',
- 'project/akeneo/language-status?key=1234',
- ['body' => ['language' => 'fr']]
+ 'project/akeneo/language-status',
+ [
+ 'headers' => ['Authorization' => 'Bearer 1234'],
+ 'body' => ['language' => 'fr']
+ ]
)->willReturn($response);
$response->getContent()->willReturn('');
$this->execute()->shouldBe('');
diff --git a/spec/Akeneo/Crowdin/Api/StatusSpec.php b/spec/Akeneo/Crowdin/Api/StatusSpec.php
index 3238924..a330b79 100644
--- a/spec/Akeneo/Crowdin/Api/StatusSpec.php
+++ b/spec/Akeneo/Crowdin/Api/StatusSpec.php
@@ -14,7 +14,7 @@ public function let(Client $client, HttpClientInterface $http, ResponseInterface
$client->getHttpClient()->willReturn($http);
$client->getProjectIdentifier()->willReturn('akeneo');
$client->getProjectApiKey()->willReturn('1234');
- $http->request('GET', 'project/akeneo/status?key=1234')->willReturn($response);
+ $http->request('GET', 'project/akeneo/status', ['headers' => ['Authorization' => 'Bearer 1234']])->willReturn($response);
$response->getContent()->willReturn('');
$this->beConstructedWith($client);
}
diff --git a/spec/Akeneo/Crowdin/Api/SupportedLanguagesSpec.php b/spec/Akeneo/Crowdin/Api/SupportedLanguagesSpec.php
index 6ac7579..89891a8 100644
--- a/spec/Akeneo/Crowdin/Api/SupportedLanguagesSpec.php
+++ b/spec/Akeneo/Crowdin/Api/SupportedLanguagesSpec.php
@@ -16,7 +16,8 @@ class SupportedLanguagesSpec extends ObjectBehavior
public function let(Client $client, HttpClientInterface $http, ResponseInterface $response)
{
$client->getHttpClient()->willReturn($http);
- $http->request('GET', 'supported-languages')->willReturn($response);
+ $client->getProjectApiKey()->willReturn('1234');
+ $http->request('GET', 'supported-languages', ['headers' => ['Authorization' => 'Bearer 1234']])->willReturn($response);
$response->getContent()->willReturn('');
$this->beConstructedWith($client);
}
diff --git a/spec/Akeneo/Crowdin/Api/UpdateFileSpec.php b/spec/Akeneo/Crowdin/Api/UpdateFileSpec.php
index 49f624a..7ecde60 100644
--- a/spec/Akeneo/Crowdin/Api/UpdateFileSpec.php
+++ b/spec/Akeneo/Crowdin/Api/UpdateFileSpec.php
@@ -45,7 +45,11 @@ public function it_should_not_allow_update_with_no_file(HttpClientInterface $htt
{
$content = '';
$response->getContent(true)->willReturn($content);
- $http->request('POST', 'project/akeneo/update-file?key=1234')->willReturn($response);
+ $http->request(
+ 'POST',
+ 'project/akeneo/update-file',
+ ['headers' => ['Authorization' => 'Bearer 1234']]
+ )->willReturn($response);
$this->shouldThrow()->duringExecute();
}
@@ -60,11 +64,13 @@ public function it_updates_some_translation_files(
$response->getContent()->willReturn($content);
$fakeResource = '[fake resource]';
$fileReader->readTranslation(Argument::any())->willReturn($fakeResource);
+
$http->request(
'POST',
- 'project/akeneo/update-file?key=1234',
+ 'project/akeneo/update-file',
[
'headers' => [
+ 'Authorization' => 'Bearer 1234',
'Content-Type' => 'multipart/form-data'
],
'body' => [
@@ -88,6 +94,7 @@ public function it_sends_additionnal_parameters(
Argument::any(),
[
'headers' => [
+ 'Authorization' => 'Bearer 1234',
'Content-Type' => 'multipart/form-data'
],
'body' => [
diff --git a/spec/Akeneo/Crowdin/Api/UploadTranslationSpec.php b/spec/Akeneo/Crowdin/Api/UploadTranslationSpec.php
index db12571..a6a926f 100644
--- a/spec/Akeneo/Crowdin/Api/UploadTranslationSpec.php
+++ b/spec/Akeneo/Crowdin/Api/UploadTranslationSpec.php
@@ -63,7 +63,11 @@ public function it_should_not_allow_upload_with_no_translation(
$this->setLocale('fr');
$content = '';
$response->getContent()->willReturn($content);
- $http->request('POST', 'project/sylius/upload-translation?key=1234')->willReturn($response);
+ $http->request(
+ 'POST',
+ 'project/sylius/upload-translation',
+ ['headers' => ['Authorization' => 'Bearer 1234']]
+ )->willReturn($response);
$this->shouldThrow('\InvalidArgumentException')->duringExecute();
}
@@ -73,7 +77,11 @@ public function it_should_not_allow_upload_with_no_locale(HttpClientInterface $h
$this->addTranslation('spec/fixtures/messages.en.yml', 'crowdin/path/file.yml');
$content = '';
$response->getContent()->willReturn($content);
- $http->request('POST', 'project/sylius/upload-translation?key=1234')->willReturn($response);
+ $http->request(
+ 'POST',
+ 'project/sylius/upload-translation',
+ ['headers' => ['Authorization' => 'Bearer 1234']]
+ )->willReturn($response);
$this->shouldThrow()->duringExecute();
}
@@ -91,9 +99,10 @@ public function it_uploads_some_translations(
$fileReader->readTranslation(Argument::any())->willReturn($fakeResource);
$http->request(
'POST',
- 'project/sylius/upload-translation?key=1234',
+ 'project/sylius/upload-translation',
[
'headers' => [
+ 'Authorization' => 'Bearer 1234',
'Content-Type' => 'multipart/form-data'
],
'body' => [
diff --git a/src/Akeneo/Crowdin/Api/AddDirectory.php b/src/Akeneo/Crowdin/Api/AddDirectory.php
index 3992017..0dab05d 100644
--- a/src/Akeneo/Crowdin/Api/AddDirectory.php
+++ b/src/Akeneo/Crowdin/Api/AddDirectory.php
@@ -25,12 +25,9 @@ public function execute()
throw new InvalidArgumentException('There is no directory to create.');
}
- $this->addUrlParameter('key', $this->client->getProjectApiKey());
-
$path = sprintf(
- "project/%s/add-directory?%s",
- $this->client->getProjectIdentifier(),
- $this->getUrlQueryString()
+ "project/%s/add-directory",
+ $this->client->getProjectIdentifier()
);
$parameters = ['name' => $this->directory];
@@ -41,7 +38,12 @@ public function execute()
$parameters['branch'] = $this->branch;
}
- $data = ['body' => $parameters];
+ $data = [
+ 'headers' => [
+ 'Authorization' => 'Bearer ' . $this->client->getProjectApiKey()
+ ],
+ 'body' => $parameters
+ ];
$response = $this->client->getHttpClient()->request('POST', $path, $data);
return $response->getContent();
diff --git a/src/Akeneo/Crowdin/Api/AddFile.php b/src/Akeneo/Crowdin/Api/AddFile.php
index 4b41b3a..80991f7 100644
--- a/src/Akeneo/Crowdin/Api/AddFile.php
+++ b/src/Akeneo/Crowdin/Api/AddFile.php
@@ -34,12 +34,9 @@ public function execute(): string
throw new InvalidArgumentException('There is no files to add.');
}
- $this->addUrlParameter('key', $this->client->getProjectApiKey());
-
$path = sprintf(
- "project/%s/add-file?%s",
- $this->client->getProjectIdentifier(),
- $this->getUrlQueryString()
+ "project/%s/add-file",
+ $this->client->getProjectIdentifier()
);
$data = $this->parameters;
@@ -61,7 +58,8 @@ public function execute(): string
$data = [
'headers' => [
- 'Content-Type' => 'multipart/form-data'
+ 'Content-Type' => 'multipart/form-data',
+ 'Authorization' => 'Bearer 1234'
],
'body' => $data
];
diff --git a/src/Akeneo/Crowdin/Api/ChangeDirectory.php b/src/Akeneo/Crowdin/Api/ChangeDirectory.php
index b7d3b11..348582a 100644
--- a/src/Akeneo/Crowdin/Api/ChangeDirectory.php
+++ b/src/Akeneo/Crowdin/Api/ChangeDirectory.php
@@ -28,12 +28,9 @@ public function execute(): string
throw new InvalidArgumentException('Argument name is required.');
}
- $this->addUrlParameter('key', $this->client->getProjectApiKey());
-
$path = sprintf(
- "project/%s/change-directory?%s",
- $this->client->getProjectIdentifier(),
- $this->getUrlQueryString()
+ "project/%s/change-directory",
+ $this->client->getProjectIdentifier()
);
$data = ['name' => $this->name];
@@ -51,7 +48,10 @@ public function execute(): string
$data['branch'] = $this->branch;
}
- $data = ['body' => $data];
+ $data = [
+ 'headers' => ['Authorization' => 'Bearer ' . $this->client->getProjectApiKey()],
+ 'body' => $data
+ ];
$response = $this->client->getHttpClient()->request('POST', $path, $data);
return $response->getContent();
diff --git a/src/Akeneo/Crowdin/Api/DeleteDirectory.php b/src/Akeneo/Crowdin/Api/DeleteDirectory.php
index 18b4a37..432add5 100644
--- a/src/Akeneo/Crowdin/Api/DeleteDirectory.php
+++ b/src/Akeneo/Crowdin/Api/DeleteDirectory.php
@@ -23,17 +23,17 @@ public function execute(): string
throw new InvalidArgumentException('There is no directory to delete.');
}
- $this->addUrlParameter('key', $this->client->getProjectApiKey());
-
$path = sprintf(
- "project/%s/delete-directory?%s",
- $this->client->getProjectIdentifier(),
- $this->getUrlQueryString()
+ "project/%s/delete-directory",
+ $this->client->getProjectIdentifier()
);
$parameters = ['name' => $this->directory];
- $data = ['body' => $parameters];
+ $data = [
+ 'headers' => ['Authorization' => 'Bearer ' . $this->client->getProjectApiKey()],
+ 'body' => $parameters
+ ];
$response = $this->client->getHttpClient()->request('POST', $path, $data);
return $response->getContent();
diff --git a/src/Akeneo/Crowdin/Api/DeleteFile.php b/src/Akeneo/Crowdin/Api/DeleteFile.php
index faf4376..c04edbc 100644
--- a/src/Akeneo/Crowdin/Api/DeleteFile.php
+++ b/src/Akeneo/Crowdin/Api/DeleteFile.php
@@ -23,17 +23,17 @@ public function execute(): string
throw new InvalidArgumentException('There is no file to delete.');
}
- $this->addUrlParameter('key', $this->client->getProjectApiKey());
-
$path = sprintf(
- "project/%s/delete-file?%s",
- $this->client->getProjectIdentifier(),
- $this->getUrlQueryString()
+ "project/%s/delete-file",
+ $this->client->getProjectIdentifier()
);
$parameters = ['file' => $this->file];
- $data = ['body' => $parameters];
+ $data = [
+ 'headers' => ['Authorization' => 'Bearer ' . $this->client->getProjectApiKey()],
+ 'body' => $parameters
+ ];
$response = $this->client->getHttpClient()->request('POST', $path, $data);
return $response->getContent();
diff --git a/src/Akeneo/Crowdin/Api/Download.php b/src/Akeneo/Crowdin/Api/Download.php
index b83fd59..df31e77 100644
--- a/src/Akeneo/Crowdin/Api/Download.php
+++ b/src/Akeneo/Crowdin/Api/Download.php
@@ -19,20 +19,17 @@ class Download extends AbstractApi
*/
public function execute(): string
{
- $this->addUrlParameter('key', $this->client->getProjectApiKey());
-
$path = sprintf(
- "project/%s/download/%s?%s",
+ "project/%s/download/%s",
$this->client->getProjectIdentifier(),
- $this->package,
- $this->getUrlQueryString()
+ $this->package
);
if (null !== $this->branch) {
$path = sprintf('%s&branch=%s', $path, $this->branch);
}
$filePath = $this->getCopyDestination() . '/' . $this->getPackage();
- $response = $this->client->getHttpClient()->request('GET', $path);
+ $response = $this->client->getHttpClient()->request('GET', $path, ['headers' => ['Authorization' => 'Bearer 1234']]);
$fileContent = $response->getContent();
file_put_contents($filePath, $fileContent);
diff --git a/src/Akeneo/Crowdin/Api/Export.php b/src/Akeneo/Crowdin/Api/Export.php
index 638539f..074a35c 100644
--- a/src/Akeneo/Crowdin/Api/Export.php
+++ b/src/Akeneo/Crowdin/Api/Export.php
@@ -17,17 +17,18 @@ class Export extends AbstractApi
*/
public function execute(): string
{
- $this->addUrlParameter('key', $this->client->getProjectApiKey());
-
$path = sprintf(
- "project/%s/export?%s",
- $this->client->getProjectIdentifier(),
- $this->getUrlQueryString()
+ "project/%s/export",
+ $this->client->getProjectIdentifier()
);
if (null !== $this->branch) {
$path = sprintf('%s&branch=%s', $path, $this->branch);
}
- $response = $this->client->getHttpClient()->request('GET', $path);
+ $response = $this->client->getHttpClient()->request(
+ 'GET',
+ $path,
+ ['headers' => ['Authorization' => 'Bearer ' . $this->client->getProjectApiKey()]]
+ );
return $response->getContent();
}
diff --git a/src/Akeneo/Crowdin/Api/Info.php b/src/Akeneo/Crowdin/Api/Info.php
index c92290e..4ed880a 100644
--- a/src/Akeneo/Crowdin/Api/Info.php
+++ b/src/Akeneo/Crowdin/Api/Info.php
@@ -15,14 +15,15 @@ class Info extends AbstractApi
*/
public function execute(): string
{
- $this->addUrlParameter('key', $this->client->getProjectApiKey());
-
$path = sprintf(
- "project/%s/info?%s",
- $this->client->getProjectIdentifier(),
- $this->getUrlQueryString()
+ "project/%s/info",
+ $this->client->getProjectIdentifier()
+ );
+ $response = $this->client->getHttpClient()->request(
+ 'GET',
+ $path,
+ ['headers' => ['Authorization' => 'Bearer ' . $this->client->getProjectApiKey()]]
);
- $response = $this->client->getHttpClient()->request('GET', $path);
return $response->getContent();
}
diff --git a/src/Akeneo/Crowdin/Api/LanguageStatus.php b/src/Akeneo/Crowdin/Api/LanguageStatus.php
index 0f82988..070ae6e 100644
--- a/src/Akeneo/Crowdin/Api/LanguageStatus.php
+++ b/src/Akeneo/Crowdin/Api/LanguageStatus.php
@@ -27,11 +27,16 @@ public function getLanguage(): string
public function execute()
{
$path = sprintf(
- "project/%s/language-status?key=%s",
- $this->client->getProjectIdentifier(),
- $this->client->getProjectApiKey()
+ "project/%s/language-status",
+ $this->client->getProjectIdentifier()
+ );
+ $parameters = array_merge(
+ $this->parameters,
+ [
+ 'headers' => ['Authorization' => 'Bearer ' . $this->client->getProjectApiKey()],
+ 'body' => ['language' => $this->getLanguage()]
+ ]
);
- $parameters = array_merge($this->parameters, ['body' => ['language' => $this->getLanguage()]]);
$response = $this->client->getHttpClient()->request('POST', $path, $parameters);
return $response->getContent();
diff --git a/src/Akeneo/Crowdin/Api/Status.php b/src/Akeneo/Crowdin/Api/Status.php
index 0d22c6a..a0333bd 100644
--- a/src/Akeneo/Crowdin/Api/Status.php
+++ b/src/Akeneo/Crowdin/Api/Status.php
@@ -15,14 +15,15 @@ class Status extends AbstractApi
*/
public function execute()
{
- $this->addUrlParameter('key', $this->client->getProjectApiKey());
-
$path = sprintf(
- "project/%s/status?%s",
- $this->client->getProjectIdentifier(),
- $this->getUrlQueryString()
+ "project/%s/status",
+ $this->client->getProjectIdentifier()
+ );
+ $response = $this->client->getHttpClient()->request(
+ 'GET',
+ $path,
+ ['headers' => ['Authorization' => 'Bearer ' . $this->client->getProjectApiKey()]]
);
- $response = $this->client->getHttpClient()->request('GET', $path);
return $response->getContent();
}
diff --git a/src/Akeneo/Crowdin/Api/SupportedLanguages.php b/src/Akeneo/Crowdin/Api/SupportedLanguages.php
index 78f1e55..92dff94 100644
--- a/src/Akeneo/Crowdin/Api/SupportedLanguages.php
+++ b/src/Akeneo/Crowdin/Api/SupportedLanguages.php
@@ -22,7 +22,11 @@ public function execute()
}
$http = $this->client->getHttpClient();
- $response = $http->request('GET', $path);
+ $response = $http->request(
+ 'GET',
+ $path,
+ ['headers' => ['Authorization' => 'Bearer ' . $this->client->getProjectApiKey()]]
+ );
return $response->getContent();
}
diff --git a/src/Akeneo/Crowdin/Api/UpdateFile.php b/src/Akeneo/Crowdin/Api/UpdateFile.php
index 6043aa8..2e3224b 100644
--- a/src/Akeneo/Crowdin/Api/UpdateFile.php
+++ b/src/Akeneo/Crowdin/Api/UpdateFile.php
@@ -33,12 +33,9 @@ public function execute(): string
throw new InvalidArgumentException('There is no files to update');
}
- $this->addUrlParameter('key', $this->client->getProjectApiKey());
-
$path = sprintf(
- "project/%s/update-file?%s",
- $this->client->getProjectIdentifier(),
- $this->getUrlQueryString()
+ "project/%s/update-file",
+ $this->client->getProjectIdentifier()
);
$data = $this->parameters;
@@ -58,6 +55,7 @@ public function execute(): string
$data = [
'headers' => [
+ 'Authorization' => 'Bearer ' . $this->client->getProjectApiKey(),
'Content-Type' => 'multipart/form-data'
],
'body' => $data
diff --git a/src/Akeneo/Crowdin/Api/UploadTranslation.php b/src/Akeneo/Crowdin/Api/UploadTranslation.php
index 19a46b3..7b26ace 100644
--- a/src/Akeneo/Crowdin/Api/UploadTranslation.php
+++ b/src/Akeneo/Crowdin/Api/UploadTranslation.php
@@ -46,12 +46,9 @@ public function execute(): string
throw new InvalidArgumentException('Locale is not set.');
}
- $this->addUrlParameter('key', $this->client->getProjectApiKey());
-
$path = sprintf(
- "project/%s/upload-translation?%s",
- $this->client->getProjectIdentifier(),
- $this->getUrlQueryString()
+ "project/%s/upload-translation",
+ $this->client->getProjectIdentifier()
);
$data['import_duplicates'] = (int)$this->areDuplicatesImported;
@@ -69,6 +66,7 @@ public function execute(): string
$data = [
'headers' => [
+ 'Authorization' => 'Bearer ' . $this->client->getProjectApiKey(),
'Content-Type' => 'multipart/form-data'
],
'body' => $data