Skip to content

Commit

Permalink
Merge pull request #137 from ash-jc-allen/rename-to-https
Browse files Browse the repository at this point in the history
Renamed `ssl` config option to `https`
  • Loading branch information
ash-jc-allen authored Oct 28, 2023
2 parents ad64d2c + baeca5d commit ec5c00e
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions config/laravel-exchange-rates.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,

];
2 changes: 1 addition & 1 deletion src/Drivers/ExchangeRateHost/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/ExchangeRatesApiIo/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/ExchangeRatesDataApi/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/Drivers/ExchangeRateHost/RequestBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}

Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/Drivers/ExchangeRatesApiIo/RequestBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit ec5c00e

Please sign in to comment.