An unofficial client for the SendCloud API. More info about SendCloud on http://sendcloud.nl. Below are some examples on the usage of this client.
This project can easily be installed through Composer.
composer require picqer/sendcloud-php-client
Prepare the client for connecting to SendCloud with your API key and secret
$connection = new \Picqer\Carriers\SendCloud\Connection('apikey', 'apisecret');
$sendCloud = new \Picqer\Carriers\SendCloud\SendCloud($connection);
Returns an array of Parcel objects
$parcels = $sendCloud->parcels()->all();
Returns a Parcel object
$parcel = $sendCloud->parcels()->find(2342);
$parcel = $sendCloud->parcels();
$parcel->name = 'John Smith';
$parcel->company_name = 'ACME';
$parcel->address = 'Wellingtonstreet 25';
$parcel->city = 'Wellington';
$parcel->postal_code = '3423 DD';
$parcel->country = 'NL';
$parcel->requestShipment = true;
$parcel->shipment = 10; // Shipping method ($sendCloud->shippingMethods()->all())
$parcel->order_number = 'ORDER2014-52321';
$parcel->save();
Actions to the API may cause an Exception to be thrown in case something went wrong
try
{
$parcel->save();
} catch (SendCloudApiException $e)
{
throw new Exception($e->getMessage());
}