Skip to content

Commit

Permalink
Fixed support for private apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Cooper committed Nov 12, 2022
1 parent 2764051 commit 1078b41
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"require": {
"illuminate/support": ">=5.3",
"hubspot/hubspot-php": "^3.0"
"hubspot/hubspot-php": "^5.0"
},
"autoload": {
"psr-4": {
Expand Down
14 changes: 7 additions & 7 deletions src/HubSpotServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public function register()
{
//Bind the HubSpot wrapper class
$this->app->bind('Rossjcooper\LaravelHubSpot\HubSpot', function ($app) {
if (config('hubspot.use_oauth2')) {
return HubSpot::createWithOAuth2Token(
config('hubspot.api_key'),
null,
config('hubspot.client_options', [])
);
}
if (env('HUBSPOT_USE_OAUTH2', config('hubspot.use_oauth2'))) {
return HubSpot::createWithOAuth2Token(
env('HUBSPOT_API_KEY', config('hubspot.api_key')),
null,
config('hubspot.client_options', [])
);
}

return HubSpot::create(
env('HUBSPOT_API_KEY', config('hubspot.api_key')),
Expand Down
16 changes: 8 additions & 8 deletions src/config/hubspot.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

return [
/*
* Either the API key or the private app access token
*/
/*
* Either the API key or the private app access token
*/
'api_key' => env('HUBSPOT_API_KEY'),

/*
* Should the library connect via OAuth2 or use the API key. The usage of the API key will be deprecated on
* November 30th, 2022.
*/
'use_oauth2' => env('HUBSPOT_USE_OAUTH2', false),
/*
* Should the library connect via OAuth2 or use the API key. The usage of the API key will be deprecated on
* November 30th, 2022.
*/
'use_oauth2' => env('HUBSPOT_USE_OAUTH2', false),

'client_options' => [
'http_errors' => true,
Expand Down
14 changes: 7 additions & 7 deletions tests/Unit/ServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public function test_api_key_set()
}

public function test_oauth2_client_is_built()
{
Config::set('hubspot.use_oauth2', true);
Config::set('hubspot.api_key', 'FooBarBaz');
{
Config::set('hubspot.use_oauth2', true);
Config::set('hubspot.api_key', 'FooBarBaz');

$hubspot = app(HubSpot::class);
$hubspot = app(HubSpot::class);

$this->assertEquals('FooBarBaz', $hubspot->getClient()->key);
$this->assertTrue($hubspot->getClient()->oauth2);
}
$this->assertEquals(env('HUBSPOT_API_KEY'), $hubspot->getClient()->key);
$this->assertTrue($hubspot->getClient()->oauth2);
}
}

0 comments on commit 1078b41

Please sign in to comment.