postbode/postbode-api

Official supported client for Postbode.nu (https://postbode.nu)

1.0.5 2019-04-18 14:02 UTC

README

Getting started

Initialize composer package

composer require postbode/postbode-api

Complete documentation

Our complete API is available at https://api.postbode.nu

Usage

List all available mailboxes

$postbode = new \Postbode\PostbodeClient(API_KEY);
$mailboxes = $postbode->getMailboxes();
foreach($mailboxes AS $mailbox){
    // use $mailbox
}

List all letters in mailbox

$postbode = new \Postbode\PostbodeClient(API_KEY);
$letters = $postbode->getLetters(MAILBOX_ID);
foreach($letters AS $letter){
    // use $letter
}

Send letter

$postbode = new \Postbode\PostbodeClient(API_KEY);

$filename = 'example.pdf';
$envelope_id = 2;
$country = 'NL';
$registered = false; // Registered letter
$send_direct = false; // Create concept in mailbox

$letter = $postbode->sendLetter(MAILBOX_ID, $filename, $envelope_id, $country, $registered, $send_direct);
if(!is_array($letter)){
    echo 'Failed! Errorcode: '.$letter;
}else{
    echo 'Letter sent!';
    echo '<br /><pre>';
    print_r($letter);
}

Add letters to queue and send in one request

$postbode = new \Postbode\PostbodeClient(API_KEY);

$envelope_id = 2;
$country = 'NL';
$registered = false; // Registered letter
$send_direct = false; // Create concept in mailbox

$postbode->addLetterToQueue(MAILBOX_ID, 'Letter_A.pdf', $envelope_id, $country, $registered, $send_direct);
$postbode->addLetterToQueue(MAILBOX_ID, 'Letter_B.pdf', $envelope_id, $country, $registered, $send_direct);
$postbode->sendLetterQueue();

if(!is_array($letter)){
    echo 'Failed! Errorcode: '.$letter;
}else{
    echo 'Letter sent!';
    echo '<br /><pre>';
    print_r($letter);
}