upwebdesign / grovo
Grovo API Service Provider for Laravel 5
Requires
- php: >=5.5.9
- illuminate/support: 5.1.*
- upwebdesign/grovo-php: dev-master
This package is auto-updated.
Last update: 2024-12-21 21:08:24 UTC
README
Laravel 5.1 Grovo API Service Provider
Grovo API Documentation
Required setup
In the repositories
key of composer.json
file add the following
"require": { "php": ">=5.5.9", "laravel/framework": "5.1.*", ... "upwebdesign/grovo": "dev-master", }, ... "repositories": [ { "type": "vcs", "url": "https://github.com/upwebdesign/grovo" }],
Run the Composer update comand
$ composer update
or
$ composer update upwebdesign/grovo
In your config/app.php
add 'Upwebdesign\Grovo\GrovoServiceProvider'
to the end of the $providers
array
'providers' => array( 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 'Illuminate\Auth\AuthServiceProvider', ... 'Upwebdesign\Grovo\GrovoServiceProvider', ),
Don't forget to dump composer autoload
$ composer dump-autoload
Configuration
In config/filesystems.php
, add new disk
'config' => [ 'driver' => 'local', 'root' => config_path() ],
Publish the grovo.config file
$ php artisan vendor:publish
In order to make requests to Grovo, we need to obtain an API Token. You can do so by running:
$ php artisan grovo:requestToken
When this command finishes, it will update your config/grovo.config
file with the new token. It is recommended to store your token in your .env
. Example:
APP_ENV=local APP_DEBUG=true ... GROVO_TOKEN=xxxxxxxx
In your config/grovo.php
config file, update
'client_id' => '', 'client_secret' => '', ... 'token' => env(GROVO_TOKEN),
Now, access to your Grovo Token is securely stored in your .env
file.
Usage
So, we have our Grovo API Token and are ready to start making requests.
In case of an error a exception, HttpException
, will be thrown and can be caught.
use Upwebdesign\Grovo\Grovo
Type-hint
public function method(Grovo $grovo)
Get User
$grovo->user()->get($id);
Creat User
$grovo->user()->create([ 'email': 'jimmys@grovo.com', 'first_name': 'Jon', 'last_name': 'Sales', 'groups': [ 'Engineering', 'Platform', 'API' ], 'office_location': 'New York', 'department': 'Engineering', 'job_title': 'Senior Engineer', 'employee_id': 8, 'employment_type': 'fulltime', 'hire_date': '2014-11-17 22:36:59', 'status': 'active' ]);
Update User
$grovo->user()->update($id, [ 'first_name': 'Feddy', 'groups': 'Architecture' ]);
Delete User
$grovo->user()->delete($id);
A full example
<?php namespace App\Http\Controllers; use Upwebdesign\Grovo\Grovo class UserController extends Controller { public function show(Grovo $grovo) { $user = $grovo->user()->get(1); return view('user.show', compact('user')); } }