PHP code example of zippendo / zippendo-php
1. Go to this page and download the library: Download zippendo/zippendo-php library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zippendo / zippendo-php example snippets
fig = Zippendo\Sdk\Configuration::getDefaultConfiguration()
->setAccessToken(getenv("ZIPPENDO_API_TOKEN"));
$shipments = new Zippendo\Sdk\Api\ShipmentsApi(new GuzzleHttp\Client(), $config);
$orders = new Zippendo\Sdk\Api\OrdersApi(new GuzzleHttp\Client(), $config);
$acme = new GuzzleHttp\Client([
'headers' => ['X-Zippendo-Brand' => 'acme'], // brand ID or slug
]);
$shipments = new Zippendo\Sdk\Api\ShipmentsApi($acme, $config);
$shipments->listShipments('org_8f3kd92ld0', 1, 50); // Acme's shipments only
$acme = new GuzzleHttp\Client([
'headers' => ['X-Zippendo-Brand' => 'acme', 'X-Zippendo-Brand-Scope' => 'own'],
]);
$brands = new Zippendo\Sdk\Api\BrandsApi(new GuzzleHttp\Client(), $config);
$created = $brands->createOrgBrand('org_8f3kd92ld0', new Zippendo\Sdk\Model\CreateOrgBrandRequest([
'name' => 'Acme',
'company_name' => 'Acme ApS',
]));
$page = $brands->listOrgBrands('org_8f3kd92ld0');
$brands->updateOrgBrand('org_8f3kd92ld0', $created->getId(), new Zippendo\Sdk\Model\UpdateOrgBrandRequest([
'vat_number' => 'DK12345678',
]));
$brands->archiveOrgBrand('org_8f3kd92ld0', $created->getId());
$result = $shipments->listShipments("org_8f3kd92ld0", 1, 50);
foreach ($result->getData() as $shipment) {
echo $shipment->getId(), PHP_EOL;
}
echo $result->getTotal(), " / ", $result->getTotalPages(), PHP_EOL;
$order = $orders->createOrder("org_8f3kd92ld0", new \Zippendo\Sdk\Model\CreateOrderRequest([
"order_number" => "1001",
"order_channel_id" => "chan_7d2k1",
"order_lines" => [
new \Zippendo\Sdk\Model\CreateOrderRequestOrderLinesInner(["name" => "T-shirt", "quantity" => 2]),
],
]));
echo $order->getId(), PHP_EOL;
try {
$shipments->getShipment("org_8f3kd92ld0", "shp_missing");
} catch (\Zippendo\Sdk\ApiException $e) {
echo $e->getCode(), PHP_EOL; // HTTP status
echo $e->getResponseBody(), PHP_EOL; // JSON, e.g. {"code":"SHIPMENT_NOT_FOUND", ...}
}
$config = Zippendo\Sdk\Configuration::getDefaultConfiguration()
->setAccessToken(getenv("ZIPPENDO_API_TOKEN"))
->setHost("https://staging.api.zippendo.com");