harm-smits/sendcloud-shipping-api

A PHP Client for the SendCloud Shipping API with async support and full object mapping

v1.5.10 2021-12-06 08:15 UTC

README

A simple API that supports almost all calls and which is mapped to objects accordingly.

Initialize the client as follows and work with the api

$client = new \HarmSmits\SendCloudClient\Client(
    "...",
    "..."
);

Going over all parcels is really easy:

$cursor = null;
while (($result = $client->getParcels($cursor))) {
    $cursor = $result->getNext();
    foreach ($result->getParcels() as $parcel) {
        ...
    }
}

Statuses work likewise:

foreach ($client->getParcelStatuses() as $parcelStatus) {
    ...
}

Same for brands:

$cursor = null;
while (($result = $client->getBrands($cursor))) {
    $cursor = $result->getNext();
    foreach ($result->getBrands() as $brand) {
        ...
    }
}

Everything can be done asynchronously as well

$promise = $client->asyncGetParcelStatuses();
...
$result = $promise->wait();

The following methods can be used directly from the client, suffix with Async if you want to get a promise.

  • getParcels
  • getParcel
  • createParcel
  • createParcels
  • updateParcel
  • cancelOrDeleteParcel
  • getParcelReturnPortalUrl
  • getParcelDocuments
  • getParcelStatuses
  • getReturns
  • getReturn
  • getBrands
  • getBrand
  • getShippingMethods
  • getShippingMethod
  • getPdfLabel
  • getBulkPdfLabel
  • getUser
  • getInvoices
  • getInvoice
  • getSenderAddresses
  • getSenderAddress
  • getIntegrations