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.
Full docs of the SendCloud API can be found on https://docs.sendcloud.sc/api/v2/index.html
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, API secret and Sendcloud Partner id (optional)
$connection = new \Picqer\Carriers\SendCloud\Connection('apikey', 'apisecret', 'partnerid');
$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, get possibilities from $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());
}