2017 © Pedro Peláez
 

library billingo-api-datamapper

Billingo API DataMapper

image

voov/billingo-api-datamapper

Billingo API DataMapper

  • Wednesday, February 24, 2016
  • by danfekete
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Billingo API Data Mapper

WARNING: The functions of this package are highly experimental, and not yet recommended for production use!, (*1)

This library provides CRUD access for Billingo API with data mapped models created for every API endpoint:, (*2)

  • Invoices (Billingo\API\DataMapper\Models\Invoices)
  • Invoice blocks (Billingo\API\DataMapper\Models\InvoiceBlocks)
  • Bank accounts (Billingo\API\DataMapper\Models\BankAccounts)
  • Expenses (Billingo\API\DataMapper\Models\Expenses)
  • Clients (Billingo\API\DataMapper\Models\Clients)
  • Payment methods (Billingo\API\DataMapper\Models\PaymentMethods)
  • Vat (Billingo\API\DataMapper\Models\Vat)

Factory

While you can use the included models without using the Billingo Factory it is not recommended., (*3)

use Billingo\API\Connector\HTTP\Request;
use Billingo\API\DataMapper\BillingoFactory;

$client = new Request([
    'public_key' => 'YOUR_PUBLIC_KEY',
    'private_key' => 'YOUR_PRIVATE_KEY',
]);
$factory = new BillingoFactory($client);

Usage

Loading using the class constant

When using PHP 5.6+, you can use the ::class constant when specifying the model to make, (*4)

use Billingo\API\DataMapper\Models\Clients;
$clients = $factory->make(Clients::class)->loadAll();

Loading using name

Load class using the name of the class., (*5)

$vat = $factory->makeFromName('vat')->loadAll();

Loading given ID

Instead of loading every model using loadAll you can use the load function to load a single resource., (*6)

$client = $factory->make(Clients::class)->load('12344567');

Creating a new resource

To create a new resource, you use the same factory method., (*7)

use Billingo\API\DataMapper\Models\Clients;
$client = $factory->make(Clients::class);

// you can either use magic variables
$client->name = 'Test Client Co.';

// or simple fill the whole model with an array
$client->fill([
  'name' => 'Test Client Co.'
  // ...
]);

$client->save();

Update a resource

You can easily update an already saved resource by first loading it then modifying the neccessary fields and calling the save method. The underlying library knows that it needs to update the resource instead of creating a new., (*8)

use Billingo\API\DataMapper\Models\Clients;
$client = $factory->make(Clients::class)->load('12344567');
$client->name = 'Test Client Updated Co.';
$client->save();

Delete a resource

To delete a resource first simple load the resource and then call the delete function., (*9)

use Billingo\API\DataMapper\Models\Clients;
$client = $factory->make(Clients::class)->load('12344567')->delete();

Special invoice functions

There are a couple of auxilary functions in the Invoice model that can make the usage even easier., (*10)

use Billingo\API\DataMapper\Models\Invoices;
$invoice = $factory->make(Invoices::class)->load('12344567');
$invoice->pay(3500, 1);

Pay

Set invoice paid, or partially paid, (*11)

public function pay($amount, $paymentMethodId, $date=null)

Cancel

Cancel the invoice. The function returns the new cancel invoice., (*12)

public function cancel()

Send

Send the invoice to the client, (*13)

public function send()

The Versions

24/02 2016

dev-master

9999999-dev

Billingo API DataMapper

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fekete

23/02 2016

0.1

0.1.0.0

Billingo API DataMapper

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Fekete