2017 © Pedro Peláez
 

library php-ordrestyring

A PHP Api wrapper for Ordrestyring.dk

image

lasserafn/php-ordrestyring

A PHP Api wrapper for Ordrestyring.dk

  • Friday, September 22, 2017
  • by lasserafn
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

PHP wrapper for Ordrestyring.dk

REST Api Wrapper for Ordrestyring v2 API., (*1)

Build Status Coverage StyleCI Status Total Downloads Latest Stable Version License , (*2)

It's inspired by the Query Builder from Laravel and similar, and uses a nice fluent syntax. Example:, (*3)

$ordrestyring->cases()
             ->with('hours', 'type')
             ->where('status', 1)
             ->sortDescending()
             ->sortBy('id')
             ->perPage(15)
             ->page(4)
             ->get();

This will return a Illuminate/Collection of cases, with related hours and type, ordered descending by id, and take 15 results from page 4., (*4)

You can also do things like:, (*5)

$ordrestyring->users()->find(10);
$ordrestyring->debtors()->first();
$ordrestyring->departments()->where('number', '!=', 19)->all();
$ordrestyring->debtors()->where('id', [1,2,3,4])->get(); // Will get debtors with id 1, 2, 3 and/or 4

Installation

composer require lasserafn/php-ordrestyring

Usage

First step is to get an API token for you Ordrestyring account by contacting Ordrestyring., (*6)

$ordrestyring = new LasseRafn\Ordrestyring\Ordrestyring('API-KEY');

$ordrestyring->cases()->get();

You'd probably want to add a use statement instead:, (*7)

use LasseRafn\Ordrestyring\Ordrestyring;

Exceptions

All request exceptions will throw an exception, which extends GuzzleHttp\Exception\ClientException. The returned exception is LasseRafn\Ordrestyring\Exceptions\RequestException and will get the error message from Ordrestyring if one is present, and default to the ClientException message if none is present. So handling exceptions can be as simple as:, (*8)

try {
    // try to get something from the api, but nothing is found.
}
catch( LasseRafn\Ordrestyring\Exceptions\RequestException $exception ) {
    echo $exception->message; // could redirect back with the message.
}

Would echo out something like: "This item does not exists" (according to their API), (*9)

Supported endpoints

  • Debtors
  • Debtor Invoices
  • Delivery Addresses
  • Cases
  • More to come...

Tests

Tests are in the making..., (*10)

The Versions

22/09 2017

dev-master

9999999-dev

A PHP Api wrapper for Ordrestyring.dk

  Sources   Download

MIT

The Requires

 

22/09 2017

0.0.2

0.0.2.0

A PHP Api wrapper for Ordrestyring.dk

  Sources   Download

MIT

The Requires

 

22/09 2017

0.0.1

0.0.1.0

A PHP Api wrapper for Ordrestyring.dk

  Sources   Download

MIT

The Requires