PHP code example of agsystemspl / fakturownia-rest-client

1. Go to this page and download the library: Download agsystemspl/fakturownia-rest-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

agsystemspl / fakturownia-rest-client example snippets


use AGSystems\Fakturownia\REST\Client;

$accessToken = 'JDxxxxxxxxxxxxxx';

// For Fakturownia (Polish version)
$apiUrl = 'https://YOUR_DOMAIN.fakturownia.pl/';

// For InvoiceOcean (English version)
// $apiUrl = 'https://YOUR_DOMAIN.invoiceocean.com/';

$client = new Client($accessToken, $apiUrl);

// Get a list of clients with pagination
$clients = $client->clients->get([
    'page' => 1,
    'per_page' => 25
]);

// Get a list of invoices
$invoices = $client->invoices->get();

// Get a client by ID
$clientData = $client->clients(123)->get();

// Get an invoice by ID
$invoice = $client->invoices(456)->get();

// Add a new client
$newClient = $client->clients->post([
    'client' => [
        'name' => 'Company XYZ',
        'tax_no' => '1234567890',
        'city' => 'Warsaw'
    ]
]);

// Create an invoice
$newInvoice = $client->invoices->post([
    'invoice' => [
        'kind' => 'vat',
        'number' => null,
        'sell_date' => '2024-01-15',
        'issue_date' => '2024-01-15',
        'payment_to' => '2024-01-29',
        'client_id' => $newClient->id,
        'positions' => [
            ['name' => 'Service', 'quantity' => 1, 'total_price_gross' => 123.00]
        ]
    ]
]);

// Update client data
$client->clients(123)->put([
    'client' => [
        'name' => 'New Company Name'
    ]
]);

// Delete a client
$client->clients(123)->delete();

$client->invoices(456)->send_by_email->post();