friendsofapi / billogram
Library for connecting to the Billogram v2 API
Installs: 13 351
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 13
Open Issues: 5
Requires
- php: ^7.0
- php-http/client-common: ^1.5
- php-http/client-implementation: ^1.0
- php-http/discovery: ^1.0
- php-http/httplug: ^1.0
- php-http/message-factory: ^1.0
- php-http/multipart-stream-builder: ^1.0
Requires (Dev)
- guzzlehttp/psr7: ^1.3
- nyholm/nsa: ^1.0
- php-http/curl-client: ^1.6
- php-http/message: ^1.0
- php-http/message-factory: ^1.0
- php-http/mock-client: ^1.0
- phpunit/phpunit: ^6.2
This package is auto-updated.
Last update: 2024-11-29 03:47:49 UTC
README
This Billogram fork was created to because we wanted to have a modern API client that followed PHP standards. Attempts were made to improve the original library but they were quickly shutdown. This fork will live "forever".
Installation:
composer require friendsofapi/billogram php-http/guzzle6-adapter php-http/message
Why php-http/guzzle6-adapter php-http/message
? We are decoupled from any HTTP messaging client with help by
HTTPlug. Read about clients in the HTTPlug docs.
Usage
First you need to register an account. it's recommend that you sign up on Billogram sandbox environment Sandbox Billogram or on Billogram, then generate an API user.
Authentication:
After you have generated an API user you need to create a BillogramClient and pass your user and the password to the factory function.
$billogram = BillogramClient::create($username, $apikey);
Create a customer:
use Billogram\Model\Customer\CustomerContact; use Billogram\Model\Customer\CustomerBillingAddress; use Billogram\Model\Customer\CustomerDeliveryAddress; use Billogram\Model\Customer\Customer; $contact = CustomerContact::createFromArray(['name' => 'ib92g', 'email' => 'ib922@gmail.com', 'phone' => '0712223344']); $addressCustomer = CustomerBillingAddress::createFromArray(['careof' => 'ibrahim', 'use_careof_as_attention' => false, 'street_address' => 'Flygarvägen 189B', 'zipcode' => '175 69', 'city' => 'Järfälla', 'country' => 'SE']); $addressDelivery = CustomerDeliveryAddress::createFromArray(['name' => 'ibrahim', 'street_address' => 'Flygarvägen 189B', 'careof' => 'ibrahim', 'zipcode' => '175 69', 'city' => 'Järfälla', 'country' => 'SE']); $customer = new Customer(); $customer = $customer->withCustomerNo(1); $customer = $customer->withName('Ibrahim AA'); $customer = $customer->withNotes('aa'); $customer = $customer->withOrgNo('556801-7155'); $customer = $customer->withVatNo('SE556677889901'); $customer = $customer->withContact($contact); $customer = $customer->withAddress($addressCustomer); $customer = $customer->withDeliveryAddress($addressDelivery); $customer = $customer->withCompanyType('individual'); $customer = $billogram->customers()->create($customer->toArray());
Fetch a customer:
$customer = $billogram->customers()->fetch($customerNo);
Create an item:
use Billogram\Model\Item\Bookkeeping; use Billogram\Model\Item\Item; $bookkeeping = Bookkeeping::createFromArray(['income_account' => '302', 'vat_account' => '303']); $item = new Item(); $item = $item->withTitle('cc'); $item = $item->withDescription('cc'); $item = $item->withPrice(12); $item = $item->withVat(12); $item = $item->withUnit('hour'); $item = $item->withBookkeeping($bookkeeping); $item = $billogram->items()->create($item->toArray());
Fetch items:
$items = $billogram->items()->search(['page' => 1]);
Delete an item:
$billogram->items()->delete($itemNo);
Create an invoice:
We consider that you have created a customer and an item (See the docs above) and you will you them to create a new invoice:
use Billogram\Model\Invoice\Item; use Billogram\Model\Invoice\Invoice; // ... $itemOfinvoice = new Item(); $itemOfinvoice = $itemOfinvoice->withItemNo($itemFetched->getItemNo()); $itemOfinvoice = $itemOfinvoice->withCount(2) $itemOfinvoice = $itemOfinvoice->withDiscount(1) $invoice = new Invoice(); $invoice = $invoice->withCustomer($customer); $invoice = $invoice->withItems([$itemOfinvoice]); $invoice = $invoice->withInvoiceDate('2013-11-14'); $invoice = $billogram->invoices()->create($invoice->toArray());
API documentation
The Billogram API documentation is a good place to start if you want to learn more of the API.
Contribute
Do you want to make a change? Pull requests are welcome.