From d155c29d3e3ef89f66ceb8eba859c8332e1643a3 Mon Sep 17 00:00:00 2001 From: amigaire Date: Wed, 13 Mar 2024 14:28:40 +0100 Subject: [PATCH 1/2] Pass api key in headers instead of url params --- spec/Akeneo/Crowdin/Api/AddDirectorySpec.php | 7 +++++-- spec/Akeneo/Crowdin/Api/AddFileSpec.php | 11 ++++++++--- spec/Akeneo/Crowdin/Api/ChangeDirectorySpec.php | 10 +++++++--- spec/Akeneo/Crowdin/Api/DeleteDirectorySpec.php | 9 ++++++--- spec/Akeneo/Crowdin/Api/DeleteFileSpec.php | 9 ++++++--- spec/Akeneo/Crowdin/Api/DownloadSpec.php | 4 ++-- spec/Akeneo/Crowdin/Api/ExportSpec.php | 4 ++-- spec/Akeneo/Crowdin/Api/InfoSpec.php | 2 +- spec/Akeneo/Crowdin/Api/LanguageStatusSpec.php | 7 +++++-- spec/Akeneo/Crowdin/Api/StatusSpec.php | 2 +- .../Akeneo/Crowdin/Api/SupportedLanguagesSpec.php | 3 ++- spec/Akeneo/Crowdin/Api/UpdateFileSpec.php | 11 +++++++++-- spec/Akeneo/Crowdin/Api/UploadTranslationSpec.php | 15 ++++++++++++--- src/Akeneo/Crowdin/Api/AddDirectory.php | 14 ++++++++------ src/Akeneo/Crowdin/Api/AddFile.php | 10 ++++------ src/Akeneo/Crowdin/Api/ChangeDirectory.php | 12 ++++++------ src/Akeneo/Crowdin/Api/DeleteDirectory.php | 12 ++++++------ src/Akeneo/Crowdin/Api/DeleteFile.php | 12 ++++++------ src/Akeneo/Crowdin/Api/Download.php | 9 +++------ src/Akeneo/Crowdin/Api/Export.php | 13 +++++++------ src/Akeneo/Crowdin/Api/Info.php | 13 +++++++------ src/Akeneo/Crowdin/Api/LanguageStatus.php | 13 +++++++++---- src/Akeneo/Crowdin/Api/Status.php | 13 +++++++------ src/Akeneo/Crowdin/Api/SupportedLanguages.php | 6 +++++- src/Akeneo/Crowdin/Api/UpdateFile.php | 8 +++----- src/Akeneo/Crowdin/Api/UploadTranslation.php | 8 +++----- 26 files changed, 140 insertions(+), 97 deletions(-) diff --git a/spec/Akeneo/Crowdin/Api/AddDirectorySpec.php b/spec/Akeneo/Crowdin/Api/AddDirectorySpec.php index 30e4834..cbee453 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..7c55cdb 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..d72d4a0 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..d695cee 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..e786b12 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..a0e85af 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..a97950c 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..77fc300 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..d23dbbf 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..33e1775 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..50b3bf5 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..ddbbbc4 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..4d4081e 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..20e52c3 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..f995a3a 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..70ece55 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..1991064 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..f2c7e66 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..ce4be66 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..66f3cf9 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..520f080 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..79a4f07 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..4adbb44 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..e34e72b 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..10c1566 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..3871561 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 From 27f12e47a01b320f2fb06dab6de4d4db94636186 Mon Sep 17 00:00:00 2001 From: amigaire Date: Wed, 13 Mar 2024 17:01:18 +0100 Subject: [PATCH 2/2] fix typo --- spec/Akeneo/Crowdin/Api/AddDirectorySpec.php | 2 +- spec/Akeneo/Crowdin/Api/AddFileSpec.php | 4 ++-- spec/Akeneo/Crowdin/Api/ChangeDirectorySpec.php | 4 ++-- spec/Akeneo/Crowdin/Api/DeleteDirectorySpec.php | 4 ++-- spec/Akeneo/Crowdin/Api/DeleteFileSpec.php | 4 ++-- spec/Akeneo/Crowdin/Api/DownloadSpec.php | 4 ++-- spec/Akeneo/Crowdin/Api/ExportSpec.php | 4 ++-- spec/Akeneo/Crowdin/Api/InfoSpec.php | 2 +- spec/Akeneo/Crowdin/Api/LanguageStatusSpec.php | 2 +- spec/Akeneo/Crowdin/Api/StatusSpec.php | 2 +- spec/Akeneo/Crowdin/Api/SupportedLanguagesSpec.php | 2 +- spec/Akeneo/Crowdin/Api/UpdateFileSpec.php | 6 +++--- spec/Akeneo/Crowdin/Api/UploadTranslationSpec.php | 6 +++--- src/Akeneo/Crowdin/Api/AddDirectory.php | 2 +- src/Akeneo/Crowdin/Api/AddFile.php | 2 +- src/Akeneo/Crowdin/Api/ChangeDirectory.php | 2 +- src/Akeneo/Crowdin/Api/DeleteDirectory.php | 2 +- src/Akeneo/Crowdin/Api/DeleteFile.php | 2 +- src/Akeneo/Crowdin/Api/Download.php | 2 +- src/Akeneo/Crowdin/Api/Export.php | 2 +- src/Akeneo/Crowdin/Api/Info.php | 2 +- src/Akeneo/Crowdin/Api/LanguageStatus.php | 2 +- src/Akeneo/Crowdin/Api/Status.php | 2 +- src/Akeneo/Crowdin/Api/SupportedLanguages.php | 2 +- src/Akeneo/Crowdin/Api/UpdateFile.php | 2 +- src/Akeneo/Crowdin/Api/UploadTranslation.php | 2 +- 26 files changed, 36 insertions(+), 36 deletions(-) diff --git a/spec/Akeneo/Crowdin/Api/AddDirectorySpec.php b/spec/Akeneo/Crowdin/Api/AddDirectorySpec.php index cbee453..5e0b74a 100644 --- a/spec/Akeneo/Crowdin/Api/AddDirectorySpec.php +++ b/spec/Akeneo/Crowdin/Api/AddDirectorySpec.php @@ -43,7 +43,7 @@ public function it_adds_a_directory(HttpClientInterface $http, ResponseInterface 'POST', 'project/sylius/add-directory', [ - 'headers' => ['authorization' => 'Bearer 1234'], + 'headers' => ['Authorization' => 'Bearer 1234'], 'body' => ['name' => 'directory-to-create'] ] )->willReturn($response); diff --git a/spec/Akeneo/Crowdin/Api/AddFileSpec.php b/spec/Akeneo/Crowdin/Api/AddFileSpec.php index 7c55cdb..c929d73 100644 --- a/spec/Akeneo/Crowdin/Api/AddFileSpec.php +++ b/spec/Akeneo/Crowdin/Api/AddFileSpec.php @@ -50,7 +50,7 @@ public function it_should_not_add_with_no_file(HttpClientInterface $http, Respon $http->request( 'POST', 'project/sylius/add-file', - ['headers' => ['authorization' => 'Bearer 1234']] + ['headers' => ['Authorization' => 'Bearer 1234']] )->willReturn($response); $this->shouldThrow('\InvalidArgumentException')->duringExecute(); } @@ -69,7 +69,7 @@ public function it_adds_a_file(FileReader $fileReader, HttpClientInterface $http [ 'headers' => [ 'Content-Type' => 'multipart/form-data', - 'authorization' => 'Bearer 1234' + '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 d72d4a0..da73874 100644 --- a/spec/Akeneo/Crowdin/Api/ChangeDirectorySpec.php +++ b/spec/Akeneo/Crowdin/Api/ChangeDirectorySpec.php @@ -35,7 +35,7 @@ public function it_should_set_name( $this->setName('myname'); $path = 'project/sylius/change-directory'; $data = [ - 'headers' => ['authorization' => 'Bearer 1234'], + 'headers' => ['Authorization' => 'Bearer 1234'], 'body' => ['name' => 'myname'] ]; $http->request('POST', $path, $data)->willReturn($response); @@ -55,7 +55,7 @@ public function it_should_set_data( $this->setNewName('myNewName'); $path = 'project/sylius/change-directory'; $data = [ - 'headers' => ['authorization' => 'Bearer 1234'], + '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 d695cee..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', ['headers' => ['authorization' => 'Bearer 1234']])->willReturn($response); + $http->request('POST', 'project/sylius/delete-directory', ['headers' => ['Authorization' => 'Bearer 1234']])->willReturn($response); $this->shouldThrow()->duringExecute(); } @@ -40,7 +40,7 @@ public function it_deletes_a_directory(HttpClientInterface $http, ResponseInterf 'POST', 'project/sylius/delete-directory', [ - 'headers' => ['authorization' => 'Bearer 1234'], + 'headers' => ['Authorization' => 'Bearer 1234'], 'body' => ['name' => 'directory-to-delete'] ] )->willReturn($response); diff --git a/spec/Akeneo/Crowdin/Api/DeleteFileSpec.php b/spec/Akeneo/Crowdin/Api/DeleteFileSpec.php index e786b12..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', ['headers' => ['authorization' => 'Bearer 1234']])->willReturn($response); + $http->request('POST', 'project/sylius/delete-file', ['headers' => ['Authorization' => 'Bearer 1234']])->willReturn($response); $this->shouldThrow()->duringExecute(); } @@ -43,7 +43,7 @@ public function it_deletes_a_file(HttpClientInterface $http, ResponseInterface $ 'POST', 'project/sylius/delete-file', [ - 'headers' => ['authorization' => 'Bearer 1234'], + 'headers' => ['Authorization' => 'Bearer 1234'], 'body' => ['file' => 'path/to/my/file'] ] )->willReturn($response); diff --git a/spec/Akeneo/Crowdin/Api/DownloadSpec.php b/spec/Akeneo/Crowdin/Api/DownloadSpec.php index a0e85af..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', ['headers' => ['authorization' => 'Bearer 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', ['headers' => ['authorization' => 'Bearer 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 a97950c..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', ['headers' => ['authorization' => 'Bearer 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', ['headers' => ['authorization' => 'Bearer 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 77fc300..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', ['headers' => ['authorization' => 'Bearer 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 d23dbbf..28ebdf5 100644 --- a/spec/Akeneo/Crowdin/Api/LanguageStatusSpec.php +++ b/spec/Akeneo/Crowdin/Api/LanguageStatusSpec.php @@ -31,7 +31,7 @@ public function it_gets_project_language_status( 'POST', 'project/akeneo/language-status', [ - 'headers' => ['authorization' => 'Bearer 1234'], + 'headers' => ['Authorization' => 'Bearer 1234'], 'body' => ['language' => 'fr'] ] )->willReturn($response); diff --git a/spec/Akeneo/Crowdin/Api/StatusSpec.php b/spec/Akeneo/Crowdin/Api/StatusSpec.php index 33e1775..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', ['headers' => ['authorization' => 'Bearer 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 50b3bf5..89891a8 100644 --- a/spec/Akeneo/Crowdin/Api/SupportedLanguagesSpec.php +++ b/spec/Akeneo/Crowdin/Api/SupportedLanguagesSpec.php @@ -17,7 +17,7 @@ public function let(Client $client, HttpClientInterface $http, ResponseInterface { $client->getHttpClient()->willReturn($http); $client->getProjectApiKey()->willReturn('1234'); - $http->request('GET', 'supported-languages', ['headers' => ['authorization' => 'Bearer 1234']])->willReturn($response); + $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 ddbbbc4..7ecde60 100644 --- a/spec/Akeneo/Crowdin/Api/UpdateFileSpec.php +++ b/spec/Akeneo/Crowdin/Api/UpdateFileSpec.php @@ -48,7 +48,7 @@ public function it_should_not_allow_update_with_no_file(HttpClientInterface $htt $http->request( 'POST', 'project/akeneo/update-file', - ['headers' => ['authorization' => 'Bearer 1234']] + ['headers' => ['Authorization' => 'Bearer 1234']] )->willReturn($response); $this->shouldThrow()->duringExecute(); } @@ -70,7 +70,7 @@ public function it_updates_some_translation_files( 'project/akeneo/update-file', [ 'headers' => [ - 'authorization' => 'Bearer 1234', + 'Authorization' => 'Bearer 1234', 'Content-Type' => 'multipart/form-data' ], 'body' => [ @@ -94,7 +94,7 @@ public function it_sends_additionnal_parameters( Argument::any(), [ 'headers' => [ - 'authorization' => 'Bearer 1234', + '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 4d4081e..a6a926f 100644 --- a/spec/Akeneo/Crowdin/Api/UploadTranslationSpec.php +++ b/spec/Akeneo/Crowdin/Api/UploadTranslationSpec.php @@ -66,7 +66,7 @@ public function it_should_not_allow_upload_with_no_translation( $http->request( 'POST', 'project/sylius/upload-translation', - ['headers' => ['authorization' => 'Bearer 1234']] + ['headers' => ['Authorization' => 'Bearer 1234']] )->willReturn($response); $this->shouldThrow('\InvalidArgumentException')->duringExecute(); @@ -80,7 +80,7 @@ public function it_should_not_allow_upload_with_no_locale(HttpClientInterface $h $http->request( 'POST', 'project/sylius/upload-translation', - ['headers' => ['authorization' => 'Bearer 1234']] + ['headers' => ['Authorization' => 'Bearer 1234']] )->willReturn($response); $this->shouldThrow()->duringExecute(); @@ -102,7 +102,7 @@ public function it_uploads_some_translations( 'project/sylius/upload-translation', [ 'headers' => [ - 'authorization' => 'Bearer 1234', + '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 20e52c3..0dab05d 100644 --- a/src/Akeneo/Crowdin/Api/AddDirectory.php +++ b/src/Akeneo/Crowdin/Api/AddDirectory.php @@ -40,7 +40,7 @@ public function execute() $data = [ 'headers' => [ - 'authorization' => 'Bearer ' . $this->client->getProjectApiKey() + 'Authorization' => 'Bearer ' . $this->client->getProjectApiKey() ], 'body' => $parameters ]; diff --git a/src/Akeneo/Crowdin/Api/AddFile.php b/src/Akeneo/Crowdin/Api/AddFile.php index f995a3a..80991f7 100644 --- a/src/Akeneo/Crowdin/Api/AddFile.php +++ b/src/Akeneo/Crowdin/Api/AddFile.php @@ -59,7 +59,7 @@ public function execute(): string $data = [ 'headers' => [ 'Content-Type' => 'multipart/form-data', - 'authorization' => 'Bearer 1234' + 'Authorization' => 'Bearer 1234' ], 'body' => $data ]; diff --git a/src/Akeneo/Crowdin/Api/ChangeDirectory.php b/src/Akeneo/Crowdin/Api/ChangeDirectory.php index 70ece55..348582a 100644 --- a/src/Akeneo/Crowdin/Api/ChangeDirectory.php +++ b/src/Akeneo/Crowdin/Api/ChangeDirectory.php @@ -49,7 +49,7 @@ public function execute(): string } $data = [ - 'headers' => ['authorization' => 'Bearer ' . $this->client->getProjectApiKey()], + 'headers' => ['Authorization' => 'Bearer ' . $this->client->getProjectApiKey()], 'body' => $data ]; $response = $this->client->getHttpClient()->request('POST', $path, $data); diff --git a/src/Akeneo/Crowdin/Api/DeleteDirectory.php b/src/Akeneo/Crowdin/Api/DeleteDirectory.php index 1991064..432add5 100644 --- a/src/Akeneo/Crowdin/Api/DeleteDirectory.php +++ b/src/Akeneo/Crowdin/Api/DeleteDirectory.php @@ -31,7 +31,7 @@ public function execute(): string $parameters = ['name' => $this->directory]; $data = [ - 'headers' => ['authorization' => 'Bearer ' . $this->client->getProjectApiKey()], + 'headers' => ['Authorization' => 'Bearer ' . $this->client->getProjectApiKey()], 'body' => $parameters ]; $response = $this->client->getHttpClient()->request('POST', $path, $data); diff --git a/src/Akeneo/Crowdin/Api/DeleteFile.php b/src/Akeneo/Crowdin/Api/DeleteFile.php index f2c7e66..c04edbc 100644 --- a/src/Akeneo/Crowdin/Api/DeleteFile.php +++ b/src/Akeneo/Crowdin/Api/DeleteFile.php @@ -31,7 +31,7 @@ public function execute(): string $parameters = ['file' => $this->file]; $data = [ - 'headers' => ['authorization' => 'Bearer ' . $this->client->getProjectApiKey()], + 'headers' => ['Authorization' => 'Bearer ' . $this->client->getProjectApiKey()], 'body' => $parameters ]; $response = $this->client->getHttpClient()->request('POST', $path, $data); diff --git a/src/Akeneo/Crowdin/Api/Download.php b/src/Akeneo/Crowdin/Api/Download.php index ce4be66..df31e77 100644 --- a/src/Akeneo/Crowdin/Api/Download.php +++ b/src/Akeneo/Crowdin/Api/Download.php @@ -29,7 +29,7 @@ public function execute(): string } $filePath = $this->getCopyDestination() . '/' . $this->getPackage(); - $response = $this->client->getHttpClient()->request('GET', $path, ['headers' => ['authorization' => 'Bearer 1234']]); + $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 66f3cf9..074a35c 100644 --- a/src/Akeneo/Crowdin/Api/Export.php +++ b/src/Akeneo/Crowdin/Api/Export.php @@ -27,7 +27,7 @@ public function execute(): string $response = $this->client->getHttpClient()->request( 'GET', $path, - ['headers' => ['authorization' => 'Bearer ' . $this->client->getProjectApiKey()]] + ['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 520f080..4ed880a 100644 --- a/src/Akeneo/Crowdin/Api/Info.php +++ b/src/Akeneo/Crowdin/Api/Info.php @@ -22,7 +22,7 @@ public function execute(): string $response = $this->client->getHttpClient()->request( 'GET', $path, - ['headers' => ['authorization' => 'Bearer ' . $this->client->getProjectApiKey()]] + ['headers' => ['Authorization' => 'Bearer ' . $this->client->getProjectApiKey()]] ); return $response->getContent(); diff --git a/src/Akeneo/Crowdin/Api/LanguageStatus.php b/src/Akeneo/Crowdin/Api/LanguageStatus.php index 79a4f07..070ae6e 100644 --- a/src/Akeneo/Crowdin/Api/LanguageStatus.php +++ b/src/Akeneo/Crowdin/Api/LanguageStatus.php @@ -33,7 +33,7 @@ public function execute() $parameters = array_merge( $this->parameters, [ - 'headers' => ['authorization' => 'Bearer ' . $this->client->getProjectApiKey()], + 'headers' => ['Authorization' => 'Bearer ' . $this->client->getProjectApiKey()], 'body' => ['language' => $this->getLanguage()] ] ); diff --git a/src/Akeneo/Crowdin/Api/Status.php b/src/Akeneo/Crowdin/Api/Status.php index 4adbb44..a0333bd 100644 --- a/src/Akeneo/Crowdin/Api/Status.php +++ b/src/Akeneo/Crowdin/Api/Status.php @@ -22,7 +22,7 @@ public function execute() $response = $this->client->getHttpClient()->request( 'GET', $path, - ['headers' => ['authorization' => 'Bearer ' . $this->client->getProjectApiKey()]] + ['headers' => ['Authorization' => 'Bearer ' . $this->client->getProjectApiKey()]] ); return $response->getContent(); diff --git a/src/Akeneo/Crowdin/Api/SupportedLanguages.php b/src/Akeneo/Crowdin/Api/SupportedLanguages.php index e34e72b..92dff94 100644 --- a/src/Akeneo/Crowdin/Api/SupportedLanguages.php +++ b/src/Akeneo/Crowdin/Api/SupportedLanguages.php @@ -25,7 +25,7 @@ public function execute() $response = $http->request( 'GET', $path, - ['headers' => ['authorization' => 'Bearer ' . $this->client->getProjectApiKey()]] + ['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 10c1566..2e3224b 100644 --- a/src/Akeneo/Crowdin/Api/UpdateFile.php +++ b/src/Akeneo/Crowdin/Api/UpdateFile.php @@ -55,7 +55,7 @@ public function execute(): string $data = [ 'headers' => [ - 'authorization' => 'Bearer ' . $this->client->getProjectApiKey(), + '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 3871561..7b26ace 100644 --- a/src/Akeneo/Crowdin/Api/UploadTranslation.php +++ b/src/Akeneo/Crowdin/Api/UploadTranslation.php @@ -66,7 +66,7 @@ public function execute(): string $data = [ 'headers' => [ - 'authorization' => 'Bearer ' . $this->client->getProjectApiKey(), + 'Authorization' => 'Bearer ' . $this->client->getProjectApiKey(), 'Content-Type' => 'multipart/form-data' ], 'body' => $data