Skip to content

Commit

Permalink
Merge pull request #48 from infusionsoft/feature/frameworksupport
Browse files Browse the repository at this point in the history
Add Initial Framework Support
  • Loading branch information
MicFai committed Oct 15, 2015
2 parents 28c5b83 + 994b702 commit 4138b44
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,41 @@ $infusionsoft->setHttpLogAdapter(new MonologLogAdapter($logger));
$ phpunit
```

## Laravel/Lumen Providers

In config/app.php, register the service provider

```
Infusionsoft\FrameworkSupport\Laravel\InfusionsoftServiceProvider::class,
```

Register the Facade (optional)

```
'Infusionsoft' => Infusionsoft\FrameworkSupport\Laravel\InfusionsoftFacade::class
```

Publish the config

```
php artisan vendor:publish --provider="Infusionsoft\FrameworkSupport\Laravel\InfusionsoftServiceProvider"
```

Set your env variables

```
INFUSIONSOFT_CLIENT_ID=xxxxxxxx
INFUSIONSOFT_SECRET=xxxxxxxx
INFUSIONSOFT_REDIRECT_URL=http://localhost/auth/callback
```

Access Infusionsoft from the Facade or Binding

```
$data = Infusionsoft::query("Contact",1000,0,['Id' => '123'],['Id','FirstName','LastName','Email']);
$data = app('infusionsoft')->query("Contact",1000,0,['Id' => '123'],['Id','FirstName','LastName','Email']);
```

## Contributing

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php namespace Infusionsoft\FrameworkSupport\Laravel;

use Illuminate\Support\Facades\Facade;

class InfusionsoftFacade extends Facade {
protected static function getFacadeAccessor() { return 'infusionsoft'; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php namespace Infusionsoft\FrameworkSupport\Laravel;

use Illuminate\Support\ServiceProvider;
use Infusionsoft\Infusionsoft;

class InfusionsoftServiceProvider extends ServiceProvider
{

/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;

/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$config = __DIR__ . '/config/config.php';
$this->mergeConfigFrom($config, 'infusionsoft');
$this->publishes([$config => config_path('infusionsoft.php')]);
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton('infusionsoft', function ($app) {

return new Infusionsoft(config('infusionsoft'));

});
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array('infusionsoft');
}

}
17 changes: 17 additions & 0 deletions src/Infusionsoft/FrameworkSupport/Laravel/config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

return array(

/*
|--------------------------------------------------------------------------
| Your Infusionsoft OAuth2 Credentials
|--------------------------------------------------------------------------
*/

'client_id' => env('INFUSIONSOFT_CLIENT_ID'),

'client_secret' => env('INFUSIONSOFT_SECRET'),

'redirect_url' => env('INFUSIONSOFT_REDIRECT_URL'),

);
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php namespace Infusionsoft\FrameworkSupport\Lumen;

use Illuminate\Support\ServiceProvider;
use Infusionsoft\Infusionsoft;

class InfusionsoftServiceProvider extends ServiceProvider
{

/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;

/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{

}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton('infusionsoft', function ($app) {

$config = [
'client_id' => env('INFUSIONSOFT_CLIENT_ID'),
'client_secret' => env('INFUSIONSOFT_SECRET'),
'redirect_url' => env('INFUSIONSOFT_REDIRECT_URL'),
];

return new Infusionsoft($config);

});
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array('infusionsoft');
}

}

0 comments on commit 4138b44

Please sign in to comment.