2017 © Pedro Peláez
 

library sdk-php

PHP SDK to create a custom module for Invoice Ninja

image

invoiceninja/sdk-php

PHP SDK to create a custom module for Invoice Ninja

  • Friday, April 27, 2018
  • by hillel369
  • Repository
  • 5 Watchers
  • 33 Stars
  • 1,551 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 12 Forks
  • 8 Open issues
  • 6 Versions
  • 17 % Grown

The README.md

Invoice Ninja SDK

Installation

Add the Invoice Ninja SDK, (*1)

composer require invoiceninja/sdk-php

Setup


require __DIR__ . '/vendor/autoload.php'; use InvoiceNinja\Config as NinjaConfig; use InvoiceNinja\Models\Client; NinjaConfig::setURL('https://ninja.dev/api/v1'); NinjaConfig::setToken('Your Token'); NinjaConfig::setPerPage(15); NinjaConfig::setPage(1);
  • To connect to the hosted version use https://app.invoiceninja.com/api/v1 as the URL.
  • You can either use the free hosted trial or install the app to create an API token.

Supports

  • Clients
  • Invoices/Quotes
  • Products
  • Payments
  • Tasks
  • Vendors
  • Expenses
  • TaxRates
  • Credits

Retrieving Models

Pagination
To iterate through more than 1 page of results, increment NinjaConfig::setPage(1) value until an empty array of results is returned. Adjust the number of results per page using the NinjaConfig::setPerPage(15); value (maximum 5000)., (*2)

Retrieve all clients, (*3)

    $clients = Client::all();

Retrieve a client by its primary key., (*4)

    $client = Client::find(1);

Retrieving an invoice by it's number:, (*5)

    $invoice = Invoice::findByCustomQuery(["invoice_number" => "0123"]);

Inserting & Updating Models

Create a new client, (*6)

    $client = new Client('test@example.com');
    $client->save();

Update an existing client, (*7)

    $client->vat_number = '123456';
    $client->save();

Create an invoice, (*8)

    $invoice = $client->createInvoice();
    $invoice->addInvoiceItem('Item', 'Some notes', 10);
    $invoice->save();

Download an invoice PDF, (*9)

    $pdf = $invoice->download();

Deleting Models

    $client->archive();
    $client->delete();
    $client->restore();

Events

Register subscription for new client, (*10)

    Client::subscribeCreate('http://example.com/...');

Convert posted data to a model, (*11)

    $input = file_get_contents('php://input'); 
    $client = Client::hydrate($input);

Currently supported for clients, invoices, quotes and payments, (*12)

Statics

Retrieve the static dataset Invoice Ninja uses, (*13)

Get all statics, (*14)

    Statics::all();

Get specific static, (*15)

    Statics::countries();

List of available statics, (*16)

    Statics::currencies();
    Statics::sizes();
    Statics::timezones();
    Statics::dateFormats();
    Statics::datetimeFormats();
    Statics::languages();
    Statics::paymentTerms();
    Statics::paymentTypes();
    Statics::countries();
    Statics::invoiceDesigns();
    Statics::invoiceStatus();
    Statics::frequencies();
    Statics::gateways();
    Statics::fonts();
    Statics::banks();

The Versions

27/04 2018

dev-master

9999999-dev https://www.invoiceninja.com

PHP SDK to create a custom module for Invoice Ninja

  Sources   Download

MIT

by Hillel Coren

invoice

30/09 2017

v0.5

0.5.0.0 https://www.invoiceninja.com

PHP SDK to create a custom module for Invoice Ninja

  Sources   Download

MIT

by Hillel Coren

invoice

25/06 2017

v0.4

0.4.0.0 https://www.invoiceninja.com

PHP SDK to create a custom module for Invoice Ninja

  Sources   Download

MIT

by Hillel Coren

invoice

28/11 2016

v0.3

0.3.0.0 https://www.invoiceninja.com

PHP SDK to create a custom module for Invoice Ninja

  Sources   Download

MIT

by Hillel Coren

invoice

13/11 2016

v0.2

0.2.0.0 https://www.invoiceninja.com

PHP SDK to create a custom module for Invoice Ninja

  Sources   Download

MIT

by Hillel Coren

invoice

13/11 2016

v0.1

0.1.0.0 https://www.invoiceninja.com

PHP SDK to create a custom module for Invoice Ninja

  Sources   Download

MIT

by Hillel Coren

invoice