Skip to content

Commit

Permalink
Merge pull request #1 from NSpehler/analysis-z4jOAw
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
NSpehler authored Mar 8, 2019
2 parents 69bf4d8 + bfee79a commit a830b17
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
13 changes: 6 additions & 7 deletions src/Insee.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@
namespace NSpehler\LaravelInsee;

use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;

class Insee
{
public function access_token()
{
// Base64 encode consumer key and secret
$token = base64_encode(config('insee.consumer_key') .':'. config('insee.consumer_secret'));
$token = base64_encode(config('insee.consumer_key').':'.config('insee.consumer_secret'));

// Request access token from Insee
$client = new Client();
$result = $client->post('https://api.insee.fr/token', [
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => 'Basic '. $token
'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => 'Basic '.$token,
],
'form_params' => [
'grant_type' => 'client_credentials'
'grant_type' => 'client_credentials',
],
]);

Expand All @@ -36,9 +35,9 @@ public function get($type, $number)

// Fetch company information from Insee
$client = new Client();
$result = $client->get('https://api.insee.fr/entreprises/sirene/V3/'. $type .'/'. $number, [
$result = $client->get('https://api.insee.fr/entreprises/sirene/V3/'.$type.'/'.$number, [
'headers' => [
'Authorization' => 'Bearer '. $this->access_token()
'Authorization' => 'Bearer '.$this->access_token(),
],
'http_errors' => false,
]);
Expand Down
3 changes: 1 addition & 2 deletions src/InseeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public function boot()
*/
public function register()
{
$this->app->bind('laravel-insee', function()
{
$this->app->bind('laravel-insee', function () {
return new Insee();
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/config/insee.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
|
*/

'consumer_key' => env('INSEE_CONSUMER_KEY'),
'consumer_key' => env('INSEE_CONSUMER_KEY'),
'consumer_secret' => env('INSEE_CONSUMER_SECRET'),

];

0 comments on commit a830b17

Please sign in to comment.