A simple Laravel API wrapper for Intempus
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.editorconfig
.styleci.yml
CHANGELOG.md
LICENSE.md
README.md
composer.json
composer.lock

README.md

laravel-intempus

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.