From cb3673549999efb4136e39cb529a85ac8fa9dca2 Mon Sep 17 00:00:00 2001 From: Jonathan Kressaty Date: Fri, 9 Oct 2015 10:11:41 -0700 Subject: [PATCH] laravel and lumen framework support --- README.md | 35 ++++++++++++ .../Laravel/InfusionsoftFacade.php | 7 +++ .../Laravel/InfusionsoftServiceProvider.php | 52 +++++++++++++++++ .../Laravel/config/config.php | 17 ++++++ .../Lumen/InfusionsoftServiceProvider.php | 56 +++++++++++++++++++ 5 files changed, 167 insertions(+) create mode 100644 src/Infusionsoft/FrameworkSupport/Laravel/InfusionsoftFacade.php create mode 100644 src/Infusionsoft/FrameworkSupport/Laravel/InfusionsoftServiceProvider.php create mode 100644 src/Infusionsoft/FrameworkSupport/Laravel/config/config.php create mode 100644 src/Infusionsoft/FrameworkSupport/Lumen/InfusionsoftServiceProvider.php diff --git a/README.md b/README.md index 6a83b0f..a8185d2 100755 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/Infusionsoft/FrameworkSupport/Laravel/InfusionsoftFacade.php b/src/Infusionsoft/FrameworkSupport/Laravel/InfusionsoftFacade.php new file mode 100644 index 0000000..1a97d4e --- /dev/null +++ b/src/Infusionsoft/FrameworkSupport/Laravel/InfusionsoftFacade.php @@ -0,0 +1,7 @@ +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'); + } + +} \ No newline at end of file diff --git a/src/Infusionsoft/FrameworkSupport/Laravel/config/config.php b/src/Infusionsoft/FrameworkSupport/Laravel/config/config.php new file mode 100644 index 0000000..a5cd20c --- /dev/null +++ b/src/Infusionsoft/FrameworkSupport/Laravel/config/config.php @@ -0,0 +1,17 @@ + env('INFUSIONSOFT_CLIENT_ID'), + + 'client_secret' => env('INFUSIONSOFT_SECRET'), + + 'redirect_url' => env('INFUSIONSOFT_REDIRECT_URL'), + +); \ No newline at end of file diff --git a/src/Infusionsoft/FrameworkSupport/Lumen/InfusionsoftServiceProvider.php b/src/Infusionsoft/FrameworkSupport/Lumen/InfusionsoftServiceProvider.php new file mode 100644 index 0000000..3fe85b2 --- /dev/null +++ b/src/Infusionsoft/FrameworkSupport/Lumen/InfusionsoftServiceProvider.php @@ -0,0 +1,56 @@ +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'); + } + +} \ No newline at end of file