Skip to content

Commit 4138b44

Browse files
committed
Merge pull request #48 from infusionsoft/feature/frameworksupport
Add Initial Framework Support
2 parents 28c5b83 + 994b702 commit 4138b44

File tree

5 files changed

+167
-0
lines changed

5 files changed

+167
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,41 @@ $infusionsoft->setHttpLogAdapter(new MonologLogAdapter($logger));
103103
$ phpunit
104104
```
105105

106+
## Laravel/Lumen Providers
107+
108+
In config/app.php, register the service provider
109+
110+
```
111+
Infusionsoft\FrameworkSupport\Laravel\InfusionsoftServiceProvider::class,
112+
```
113+
114+
Register the Facade (optional)
115+
116+
```
117+
'Infusionsoft' => Infusionsoft\FrameworkSupport\Laravel\InfusionsoftFacade::class
118+
```
119+
120+
Publish the config
121+
122+
```
123+
php artisan vendor:publish --provider="Infusionsoft\FrameworkSupport\Laravel\InfusionsoftServiceProvider"
124+
```
125+
126+
Set your env variables
127+
128+
```
129+
INFUSIONSOFT_CLIENT_ID=xxxxxxxx
130+
INFUSIONSOFT_SECRET=xxxxxxxx
131+
INFUSIONSOFT_REDIRECT_URL=http://localhost/auth/callback
132+
```
133+
134+
Access Infusionsoft from the Facade or Binding
135+
136+
```
137+
$data = Infusionsoft::query("Contact",1000,0,['Id' => '123'],['Id','FirstName','LastName','Email']);
138+
139+
$data = app('infusionsoft')->query("Contact",1000,0,['Id' => '123'],['Id','FirstName','LastName','Email']);
140+
```
106141

107142
## Contributing
108143

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php namespace Infusionsoft\FrameworkSupport\Laravel;
2+
3+
use Illuminate\Support\Facades\Facade;
4+
5+
class InfusionsoftFacade extends Facade {
6+
protected static function getFacadeAccessor() { return 'infusionsoft'; }
7+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php namespace Infusionsoft\FrameworkSupport\Laravel;
2+
3+
use Illuminate\Support\ServiceProvider;
4+
use Infusionsoft\Infusionsoft;
5+
6+
class InfusionsoftServiceProvider extends ServiceProvider
7+
{
8+
9+
/**
10+
* Indicates if loading of the provider is deferred.
11+
*
12+
* @var bool
13+
*/
14+
protected $defer = false;
15+
16+
/**
17+
* Bootstrap the application events.
18+
*
19+
* @return void
20+
*/
21+
public function boot()
22+
{
23+
$config = __DIR__ . '/config/config.php';
24+
$this->mergeConfigFrom($config, 'infusionsoft');
25+
$this->publishes([$config => config_path('infusionsoft.php')]);
26+
}
27+
28+
/**
29+
* Register the service provider.
30+
*
31+
* @return void
32+
*/
33+
public function register()
34+
{
35+
$this->app->singleton('infusionsoft', function ($app) {
36+
37+
return new Infusionsoft(config('infusionsoft'));
38+
39+
});
40+
}
41+
42+
/**
43+
* Get the services provided by the provider.
44+
*
45+
* @return array
46+
*/
47+
public function provides()
48+
{
49+
return array('infusionsoft');
50+
}
51+
52+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
return array(
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Your Infusionsoft OAuth2 Credentials
8+
|--------------------------------------------------------------------------
9+
*/
10+
11+
'client_id' => env('INFUSIONSOFT_CLIENT_ID'),
12+
13+
'client_secret' => env('INFUSIONSOFT_SECRET'),
14+
15+
'redirect_url' => env('INFUSIONSOFT_REDIRECT_URL'),
16+
17+
);
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php namespace Infusionsoft\FrameworkSupport\Lumen;
2+
3+
use Illuminate\Support\ServiceProvider;
4+
use Infusionsoft\Infusionsoft;
5+
6+
class InfusionsoftServiceProvider extends ServiceProvider
7+
{
8+
9+
/**
10+
* Indicates if loading of the provider is deferred.
11+
*
12+
* @var bool
13+
*/
14+
protected $defer = false;
15+
16+
/**
17+
* Bootstrap the application events.
18+
*
19+
* @return void
20+
*/
21+
public function boot()
22+
{
23+
24+
}
25+
26+
/**
27+
* Register the service provider.
28+
*
29+
* @return void
30+
*/
31+
public function register()
32+
{
33+
$this->app->singleton('infusionsoft', function ($app) {
34+
35+
$config = [
36+
'client_id' => env('INFUSIONSOFT_CLIENT_ID'),
37+
'client_secret' => env('INFUSIONSOFT_SECRET'),
38+
'redirect_url' => env('INFUSIONSOFT_REDIRECT_URL'),
39+
];
40+
41+
return new Infusionsoft($config);
42+
43+
});
44+
}
45+
46+
/**
47+
* Get the services provided by the provider.
48+
*
49+
* @return array
50+
*/
51+
public function provides()
52+
{
53+
return array('infusionsoft');
54+
}
55+
56+
}

0 commit comments

Comments
 (0)