2017 © Pedro Peláez
 

library grovo

Grovo API Service Provider for Laravel 5

image

upwebdesign/grovo

Grovo API Service Provider for Laravel 5

  • Tuesday, December 29, 2015
  • by upwebdesign
  • Repository
  • 1 Watchers
  • 1 Stars
  • 36 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 6 % Grown

The README.md

Grovo

Laravel 5.1 Grovo API Service Provider, (*1)

Grovo API Documentation, (*2)

http://docs.grovo.apiary.io, (*3)

Required setup

In the repositories key of composer.json file add the following, (*4)

"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, (*5)

$ composer update

or, (*6)

$ composer update upwebdesign/grovo

In your config/app.php add 'Upwebdesign\Grovo\GrovoServiceProvider' to the end of the $providers array, (*7)

'providers' => array(

    'Illuminate\Foundation\Providers\ArtisanServiceProvider',
    'Illuminate\Auth\AuthServiceProvider',
    ...
    'Upwebdesign\Grovo\GrovoServiceProvider',

),

Don't forget to dump composer autoload, (*8)

$ composer dump-autoload

Configuration

In config/filesystems.php, add new disk, (*9)

'config' => [
    'driver' => 'local',
    'root' => config_path()
],

Publish the grovo.config file, (*10)

$ php artisan vendor:publish

In order to make requests to Grovo, we need to obtain an API Token. You can do so by running:, (*11)

$ 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:, (*12)

APP_ENV=local
APP_DEBUG=true
...
GROVO_TOKEN=xxxxxxxx

In your config/grovo.php config file, update, (*13)


'client_id' => '', 'client_secret' => '', ... 'token' => env(GROVO_TOKEN),

Now, access to your Grovo Token is securely stored in your .env file., (*14)

Usage

So, we have our Grovo API Token and are ready to start making requests., (*15)

In case of an error a exception, HttpException, will be thrown and can be caught., (*16)

use Upwebdesign\Grovo\Grovo

Type-hint, (*17)

public function method(Grovo $grovo)

Get User, (*18)

$grovo->user()->get($id);

Creat User, (*19)

$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, (*20)

$grovo->user()->update($id, [
  'first_name': 'Feddy',
  'groups': 'Architecture'
]);

Delete User, (*21)

$grovo->user()->delete($id);

A full example, (*22)

<?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'));
    }
}

The Versions

29/12 2015

dev-master

9999999-dev

Grovo API Service Provider for Laravel 5

  Sources   Download

MIT

The Requires

 

by Jesse Vista

laravel api grovo

20/10 2015