From baeca5d7e20dd9408afe99fbcd304e14818d59d0 Mon Sep 17 00:00:00 2001 From: Ash Allen Date: Sat, 28 Oct 2023 11:57:17 +0100 Subject: [PATCH] Renamed `ssl` config option to `https`. --- README.md | 2 +- config/laravel-exchange-rates.php | 4 ++-- src/Drivers/ExchangeRateHost/RequestBuilder.php | 2 +- src/Drivers/ExchangeRatesApiIo/RequestBuilder.php | 2 +- src/Drivers/ExchangeRatesDataApi/RequestBuilder.php | 2 +- .../Drivers/ExchangeRateHost/RequestBuilderTest.php | 12 ++++++------ .../ExchangeRatesApiIo/RequestBuilderTest.php | 12 ++++++------ .../ExchangeRatesDataApi/RequestBuilderTest.php | 4 ++-- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 0845c88..d186ff2 100755 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ If you're using an API that requires an API key, you can put it in your `.env`: EXCHANGE_RATES_API_KEY={Your-API-Key-Here} ``` -If you're using the free tier of `https://exchangeratesapi.io` or `https://exchangerate.host`, you should set the `ssl` config option in `config/laravel-exchange-rates.php` to `false`, as the free tiers of those APIs don't allow SSL requests. +If you're using the free tier of `https://exchangeratesapi.io` or `https://exchangerate.host`, you should set the `https` config option in `config/laravel-exchange-rates.php` to `false`, as the free tiers of those APIs don't allow HTTPS requests. ## Usage diff --git a/config/laravel-exchange-rates.php b/config/laravel-exchange-rates.php index c0d9f0d..a80d38d 100644 --- a/config/laravel-exchange-rates.php +++ b/config/laravel-exchange-rates.php @@ -26,13 +26,13 @@ /* |-------------------------------------------------------------------------- - | SSL Endpoints + | Use HTTPS |-------------------------------------------------------------------------- | | Define if the API should be accessed via HTTPS or HTTP. The free tiers of | exchangeratesapi.io and exchangerate.host only allow API access via HTTP. | */ - 'ssl' => true, + 'https' => true, ]; diff --git a/src/Drivers/ExchangeRateHost/RequestBuilder.php b/src/Drivers/ExchangeRateHost/RequestBuilder.php index 8b52298..c8aeeb7 100644 --- a/src/Drivers/ExchangeRateHost/RequestBuilder.php +++ b/src/Drivers/ExchangeRateHost/RequestBuilder.php @@ -22,7 +22,7 @@ class RequestBuilder implements RequestSender */ public function makeRequest(string $path, array $queryParams = []): ResponseContract { - $protocol = config('laravel-exchange-rates.ssl') ? 'https://' : 'http://'; + $protocol = config('laravel-exchange-rates.https') ? 'https://' : 'http://'; $rawResponse = Http::baseUrl($protocol.self::BASE_URL) ->get($path, $queryParams) diff --git a/src/Drivers/ExchangeRatesApiIo/RequestBuilder.php b/src/Drivers/ExchangeRatesApiIo/RequestBuilder.php index 8029968..0fa6f8c 100644 --- a/src/Drivers/ExchangeRatesApiIo/RequestBuilder.php +++ b/src/Drivers/ExchangeRatesApiIo/RequestBuilder.php @@ -29,7 +29,7 @@ public function __construct() */ public function makeRequest(string $path, array $queryParams = []): ResponseContract { - $protocol = config('laravel-exchange-rates.ssl') ? 'https://' : 'http://'; + $protocol = config('laravel-exchange-rates.https') ? 'https://' : 'http://'; $rawResponse = Http::baseUrl($protocol.self::BASE_URL) ->get( diff --git a/src/Drivers/ExchangeRatesDataApi/RequestBuilder.php b/src/Drivers/ExchangeRatesDataApi/RequestBuilder.php index b74606f..ae92e8a 100644 --- a/src/Drivers/ExchangeRatesDataApi/RequestBuilder.php +++ b/src/Drivers/ExchangeRatesDataApi/RequestBuilder.php @@ -31,7 +31,7 @@ public function __construct() */ public function makeRequest(string $path, array $queryParams = []): ResponseContract { - $protocol = config('laravel-exchange-rates.ssl') ? 'https://' : 'http://'; + $protocol = config('laravel-exchange-rates.https') ? 'https://' : 'http://'; $rawResponse = Http::baseUrl($protocol.self::BASE_URL) ->withHeaders([ diff --git a/tests/Unit/Drivers/ExchangeRateHost/RequestBuilderTest.php b/tests/Unit/Drivers/ExchangeRateHost/RequestBuilderTest.php index 124c55e..3b3fc6c 100644 --- a/tests/Unit/Drivers/ExchangeRateHost/RequestBuilderTest.php +++ b/tests/Unit/Drivers/ExchangeRateHost/RequestBuilderTest.php @@ -39,23 +39,23 @@ public function request_can_be_made_successfully(): void } /** @test */ - public function request_protocol_respects_ssl_config_option(): void + public function request_protocol_respects_https_config_option(): void { - config(['laravel-exchange-rates.ssl' => false]); + config(['laravel-exchange-rates.https' => false]); - $noSslUrl = 'http://api.exchangerate.host/latest?base=USD'; + $noHttpsUrl = 'http://api.exchangerate.host/latest?base=USD'; Http::fake([ - $noSslUrl => Http::response(['RESPONSE']), + $noHttpsUrl => Http::response(['RESPONSE']), '*' => Http::response('SHOULD NOT HIT THIS!', 500), ]); $requestBuilder = new RequestBuilder(); $requestBuilder->makeRequest('latest', ['base' => 'USD']); - Http::assertSent(static function (Request $request) use ($noSslUrl): bool { + Http::assertSent(static function (Request $request) use ($noHttpsUrl): bool { return $request->method() === 'GET' - && $request->url() === $noSslUrl; + && $request->url() === $noHttpsUrl; }); } diff --git a/tests/Unit/Drivers/ExchangeRatesApiIo/RequestBuilderTest.php b/tests/Unit/Drivers/ExchangeRatesApiIo/RequestBuilderTest.php index 80c3d24..5cdd2a4 100644 --- a/tests/Unit/Drivers/ExchangeRatesApiIo/RequestBuilderTest.php +++ b/tests/Unit/Drivers/ExchangeRatesApiIo/RequestBuilderTest.php @@ -39,23 +39,23 @@ public function request_can_be_made_successfully(): void } /** @test */ - public function request_protocol_respects_ssl_config_option(): void + public function request_protocol_respects_https_config_option(): void { - config(['laravel-exchange-rates.ssl' => false]); + config(['laravel-exchange-rates.https' => false]); - $noSslUrl = 'http://api.exchangeratesapi.io/v1/latest?access_key=API-KEY&base=USD'; + $noHttpsUrl = 'http://api.exchangeratesapi.io/v1/latest?access_key=API-KEY&base=USD'; Http::fake([ - $noSslUrl => Http::response(['RESPONSE']), + $noHttpsUrl => Http::response(['RESPONSE']), '*' => Http::response('SHOULD NOT HIT THIS!', 500), ]); $requestBuilder = new RequestBuilder(); $requestBuilder->makeRequest('latest', ['base' => 'USD']); - Http::assertSent(static function (Request $request) use ($noSslUrl): bool { + Http::assertSent(static function (Request $request) use ($noHttpsUrl): bool { return $request->method() === 'GET' - && $request->url() === $noSslUrl; + && $request->url() === $noHttpsUrl; }); } diff --git a/tests/Unit/Drivers/ExchangeRatesDataApi/RequestBuilderTest.php b/tests/Unit/Drivers/ExchangeRatesDataApi/RequestBuilderTest.php index dcd8688..3d46d7e 100644 --- a/tests/Unit/Drivers/ExchangeRatesDataApi/RequestBuilderTest.php +++ b/tests/Unit/Drivers/ExchangeRatesDataApi/RequestBuilderTest.php @@ -40,9 +40,9 @@ public function request_can_be_made_successfully(): void } /** @test */ - public function request_protocol_respects_ssl_config_option(): void + public function request_protocol_respects_https_config_option(): void { - config(['laravel-exchange-rates.ssl' => false]); + config(['laravel-exchange-rates.https' => false]); $url = 'http://api.apilayer.com/exchangerates_data/latest?base=USD';