lasserafn/laravel-intempus

A laravel API wrapper for Intempus

2.0.7 2017-09-07 07:43 UTC

README

Version Downloads StyleCI Shield Software License

Install

Via Composer

$ composer require lasserafn/laravel-intempus

Laravel Service Provider

Add the follwing to your providers array in config/app.php:

\LasseRafn\LaravelIntempus\LaravelIntempusServiceProvider::class,

Publish configs

Run this in your terminal

php artisan vendor:publish --provider="LasseRafn\LaravelIntempus\LaravelIntempusServiceProvider" --tag="config"

Route (for Auth)

Add this to your web.php file (or where-ever you desire)

Route::get('intempus/connect', function(\Illuminate\Http\Request $request) {
	dd($request->all()); // Of cause, you can do whatever you need.
	// Returned attributes are:
	    // pk
	    // hash
	    // token
});

Usage

Auth

$intempus = new Intempus();

$auth = $intempus->getAuth(); // returns url, hash and nonce in an array

return Redirect::to($auth['url']);

Remember to store the nonce, as you'll need it do send future requests.

Doing stuff

In order to send a request, you'll need the nonce (returned from the getAuth() method) and the token that is returned from Intempus. Look at the "Route (for Auth)" section for help.

An example of this could be:

Route::get('intempus/start', function(\Illuminate\Http\Request $request) {
    $intempus = new Intempus();
    
    $auth = $intempus->getAuth(); // returns url, hash and nonce in an array
    
    $request->session()->set('intempus_nonce', $auth['nonce']);
    
    return Redirect::to($auth['url']);
});
Route::get('intempus/connect', function(\Illuminate\Http\Request $request) {
    $nonce = $request->session()->get('intempus_nonce');
    $token = $request->get('token');
    $pk = $request->get('pk');

   	$intempus = new Intempus($nonce, $token, $pk);
   	
   	dd( $intempus->products()->find(1) );
});

Change log

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email lasserafn@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

todo

  • Allow deleting models/entities through the API
  • Allow creating models/entities through the API
  • Allow updating models/entities through the API
  • Limit ->get() method to X results and include an ->all() method that uses pagination
  • Add missing models
  • Add relationship-ish behaviour

Reason for doing this

As of creating this package, I'm employeed at Bizz Zolutions - and one of my tasks was integrating Intempus timeregistrering with e-conomic regnskabsprogram. I believe in open sourcing as much as possible so this felt very natural. Had a talk with the boss and we're equally minded :-)

Use as you please. Oh, and sorry for the shameless backlinks.