PHP code example of darvis / supplydrive-api

1. Go to this page and download the library: Download darvis/supplydrive-api 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/ */

    

darvis / supplydrive-api example snippets


use Darvis\SupplydriveApi\Exceptions\SupplydriveException;
use Darvis\SupplydriveApi\SupplydriveClient;
use Darvis\SupplydriveApi\SupplydriveSender;
use Illuminate\Http\Client\ConnectionException;

try {
    // Send: a 2xx gives the message id, a refusal throws, nothing is retried.
    $result = app(SupplydriveSender::class)->send($ublXml, $invoice->invoice_nr);
    $invoice->update(['peppol_sent_at' => now(), 'peppol_message_id' => $result->messageId]);

    // Look up: by invoice number, by the message id, or per debtor.
    $supplydrive = app(SupplydriveClient::class);

    foreach ($supplydrive->byFunctionalId($invoice->invoice_nr) as $message) {
        $message->status;          // "Afgeleverd", as the API returns it
        $message->description();   // "The message has been delivered."
        $message->isDelivered();   // true
    }

    $supplydrive->byMessageId(1234);            // the id Supplydrive answered with when you sent it
    $supplydrive->byDebtorKvk('12345678');      // the last hundred messages of that debtor
    $supplydrive->messageStatus(['debiteurBTW' => 'NL123456789B01', 'functioneelId' => 'F260001']);
} catch (ConnectionException $e) {
    // Supplydrive could not be reached, or did not answer within the timeout. A send that timed
    // out may have arrived: look the invoice number up before you send it again.
} catch (SupplydriveException $e) {
    $status = $e->status();   // 401, 403, 500 ..., or 0 when there was no response
}
bash
php artisan supplydrive:status --functional-id=F260001