Grovo API Service Provider for Laravel 5
47
1
1
Package Data
Maintainer Username: upwebdesign
Maintainer Contact: jvista@upwebdesign.com (Jesse Vista)
Package Create Date: 2015-08-10
Package Last Update: 2015-12-29
Language: PHP
License: MIT
Last Refreshed: 2024-03-28 03:11:51
Package Statistics
Total Downloads: 47
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 1
Total Forks: 1
Total Open Issues: 0

Grovo

Laravel 5.1 Grovo API Service Provider

Grovo API Documentation

http://docs.grovo.apiary.io

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