Skip to content

Commit e9ee9bb

Browse files
committed
WIP
1 parent 268fbbc commit e9ee9bb

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ CURRENCYLAYER_ACCESS_KEY=your-key-here
4040

4141
You can find your access key in [Currencylayer Dashboard](https://currencylayer.com/dashboard).
4242

43+
## Configuration
44+
45+
After publishing configuration file it will be available here: `app/config/currencylayer.php`
46+
47+
It has following settings:
48+
49+
* `access_key` - currencylayer.com access key, by default uses value from `.env` file
50+
* `https_connection` - if set to `true` all calls to currencylayer API endpoint will be over HTTPS, instead of default HTTP
51+
4352
## Usage
4453

4554
You can type-hint `Orkhanahmadov\LaravelCurrencylayer\Contracts\CurrencyService` to inject it from container:

config/config.php

+12
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,16 @@
1111
*/
1212

1313
'access_key' => env('CURRENCYLAYER_ACCESS_KEY'),
14+
15+
/*
16+
|--------------------------------------------------------------------------
17+
| HTTPs connection to currencylayer endpoint
18+
|--------------------------------------------------------------------------
19+
|
20+
| Paid customers can use secure HTTPS connection to currencylayer API endpoint.
21+
| Set this to "true" if you want to use HTTPS.
22+
|
23+
*/
24+
25+
'https_connection' => false,
1426
];

src/LaravelCurrencylayerServiceProvider.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ class LaravelCurrencylayerServiceProvider extends ServiceProvider
2020
public function boot(): void
2121
{
2222
$this->app->bind(Client::class, static function () {
23-
// todo: add https config
24-
return new CurrencylayerClient(config('currencylayer.access_key'));
23+
return new CurrencylayerClient(
24+
config('currencylayer.access_key'),
25+
config('currencylayer.https_connection')
26+
);
2527
});
2628
$this->app->bind(CurrencyService::class, Currencylayer::class);
2729

@@ -49,8 +51,10 @@ public function register(): void
4951
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'currencylayer');
5052

5153
$this->app->singleton('currencylayer', static function () {
52-
// todo: add https config
53-
return new Currencylayer(new CurrencylayerClient(config('currencylayer.access_key')));
54+
return new Currencylayer(new CurrencylayerClient(
55+
config('currencylayer.access_key'),
56+
config('currencylayer.https_connection')
57+
));
5458
});
5559

5660
if ($this->app->runningInConsole()) {

tests/FakeClient.php

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public function endDate($date): Client
7979

8080
/**
8181
* @return Quotes
82+
* @throws \Exception
8283
*/
8384
public function quotes(): Quotes
8485
{

0 commit comments

Comments
 (0)