Professional Parcel Logistic MyApi client in PHP
- PHP 5.4 or higher
Install salamek/PplMyApi using Composer
$ composer require salamek/ppl-my-api:dev-master
Check if PPL MyApi is in working shape
$pplMyApi = new Salamek\PplMyApi\Api();
if ($pplMyApi->isHealthy())
{
echo 'Healthly :)' . PHP_EOL;
}
else
{
echo 'Ill :(' . PHP_EOL;
}
Returns version of PPL MyApi
$pplMyApi = new Salamek\PplMyApi\Api();
echo $pplMyApi->getVersion() . PHP_EOL;
Returns array of parcel shops filtered by $code
and $countryCode
$pplMyApi = new Salamek\PplMyApi\Api();
$result = $pplMyApi->getParcelShops($code = null, $countryCode = Country::CZ);
print_r($result);
Returns array of sprint routes
$pplMyApi = new Salamek\PplMyApi\Api();
$result = $pplMyApi->getSprintRoutes();
print_r($result);
Creates package/s on PPL MyApi (sends Package object to PPL)
$username = 'my_api_username';
$password = 'my_api_password';
$customerId = 'my_api_customer_id';
$pplMyApi = new Salamek\PplMyApi\Api($username, $password, $customerId);
$sender = new Salamek\PplMyApi\Model\Sender('Olomouc', 'My Compamy s.r.o.', 'My Address', '77900', '[email protected]', '+420123456789', 'http://www.example.cz', Country::CZ);
$recipient = new Salamek\PplMyApi\Model\Recipient('Olomouc', 'Adam Schubert', 'My Address', '77900', '[email protected]', '+420123456789', 'http://www.salamek.cz', Country::CZ, 'My Compamy a.s.');
$myPackageIdFromNumberSeries = 115;
$weight = 3.15;
$package = new Salamek\PplMyApi\Model\Package($myPackageIdFromNumberSeries, Product::PPL_PARCEL_CZ_PRIVATE, $weight, 'Testpvaci balik', Depo::CODE_09, $sender, $recipient);
try
{
$pplMyApi->createPackages([$package]);
}
catch (\Exception $e)
{
echo $e->getMessage() . PHP_EOL;
}
Creates order/s on PPL MyApi (send Order object to PPL)
$username = 'my_api_username';
$password = 'my_api_password';
$customerId = 'my_api_customer_id';
$pplMyApi = new Salamek\PplMyApi\Api($username, $password, $customerId);
$order = new Salamek\PplMyApi\Model\Order($countPack, $orderReferenceId, $packProductType, \DateTimeInterface $sendDate, Sender $sender, Recipient $recipient, $customerReference = null, $email = null, $note = null, \DateTimeInterface $sendTimeFrom = null, \DateTimeInterface $sendTimeTo = null);
try
{
$pplMyApi->createOrders([$order]);
}
catch (\Exception $e)
{
echo $e->getMessage() . PHP_EOL;
}
Creates pickup order/s on PPL MyApi (send PickupOrder object to PPL)
$username = 'my_api_username';
$password = 'my_api_password';
$customerId = 'my_api_customer_id';
$pplMyApi = new Salamek\PplMyApi\Api($username, $password, $customerId);
$order = new Salamek\PplMyApi\Model\PickUpOrder($orderReferenceId, $customerReference, $countPackages, $note, $email, \DateTimeInterface $sendDate, $sendTimeFrom, $sendTimeTo, Sender $sender);
try
{
$pplMyApi->createPickupOrders([$order]);
}
catch (\Exception $e)
{
echo $e->getMessage() . PHP_EOL;
}
Returns cities routing filtered by $countryCode
, $dateFrom
, $zipCode
$username = 'my_api_username';
$password = 'my_api_password';
$customerId = 'my_api_customer_id';
$pplMyApi = new Salamek\PplMyApi\Api($username, $password, $customerId);
$result = $pplMyApi->getCitiesRouting($countryCode = Country::CZ, \DateTimeInterface $dateFrom = null, $zipCode = null);
print_r($result);
Returns package/s info from ppl filtered by $customRefs
, $dateFrom
, $dateTo
, $packageNumbers
useful for tracking and checking status of package/s
$username = 'my_api_username';
$password = 'my_api_password';
$customerId = 'my_api_customer_id';
$pplMyApi = new Salamek\PplMyApi\Api($username, $password, $customerId);
$result = $pplMyApi->getPackages($customRefs = null, \DateTimeInterface $dateFrom = null, \DateTimeInterface $dateTo = null, array $packageNumbers = []);
print_r($result);
Returns PDF with label/s for print on paper, two decompositions are supported, LabelDecomposition::FULL (one A4 Label per page) or LabelDecomposition::QUARTER (one label per 1/4 of A4 page)
$pplMyApi = new Salamek\PplMyApi\Api();
$sender = new Salamek\PplMyApi\Model\Sender('Olomouc', 'My Compamy s.r.o.', 'My Address', '77900', '[email protected]', '+420123456789', 'http://www.example.cz', Country::CZ);
$recipient = new Salamek\PplMyApi\Model\Recipient('Olomouc', 'Adam Schubert', 'My Address', '77900', '[email protected]', '+420123456789', 'http://www.salamek.cz', Country::CZ, 'My Compamy a.s.');
$myPackageIdFromNumberSeries = 115;
$weight = 3.15;
$package = new Salamek\PplMyApi\Model\Package($myPackageIdFromNumberSeries, Product::PPL_PARCEL_CZ_PRIVATE, $weight, 'Testpvaci balik', Depo::CODE_09, $sender, $recipient);
$rawPdf = $pplMyApi->getLabels([$package]);
file_put_contents($package->getPackageNumber() . '.pdf', $rawPdf);