torfs-ict / crembl
Crembl API wrapper, allows you send regular (or registered) mail through the Crembl web service.
Requires
- php: >=7.0.0
- guzzlehttp/guzzle: ^6.2
- jms/serializer: ^1.4
This package is auto-updated.
Last update: 2024-12-21 20:52:29 UTC
README
API wrapper for the Crembl web service.
Please note that we are in no way affiliated with neither Crembl nor bpost. Issues regarding this API wrapper can be filed at our GitHub page, while issues regarding to the actual API should be filed with Crembl.
Usage
Before using this API make sure to check out the official documentation. The API only has three methods:
- Creating a task (i.e. document to be sent):
createTask
. - Uploading a file for an existing task:
uploadFile
oruploadFileFromString
. - Retrieve information about an existing task:
getTaskInfo
.
Error handling
Whenever an error occurs, the client will throw an exception of type Crembl\Exception
, where you can find the
actual error information by calling the getInfo()
method.
Examples
use bpost\Crembl\Client; use bpost\Crembl\Config\TaskConfig; $client = new Client('<secret>');
Creating a task
$task = new TaskConfig(); $task ->setDocumentTypeRegular() ->setAddresseeLine1('Microsoft Belgium') ->setAddresseeLine2('Corporate Village - Bayreuth Building') ->setAddressCountry('BE') ->setAddressZipCode('1935') ->setAddressCity('Zaventem') ->setAddressStreetName('Leonardo Da Vincilaan') ->setAddressStreetNumber('3'); $id = $client->createTask($task);
Returns the id generated by the Crembl API e.g. A12345678910111213141516171819209
.
Uploading a file
$success = $client->uploadFile($id, __DIR__ . '/myletter.pdf');
Returns TRUE
in case of success, or throws an error otherwise.
Retrieve task information
$task = $client->getTaskInfo($id); var_dump($task);
Returns an object of type Crembl\Task\Info
.