This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.
There is no license information available for the latest version (dev-master) of this package.

This bundle provides integration with ECONT Courier. Module is based on Bozhidar Hristov's vm/econt.

Maintainers

Details

github.com/todstoychev/econt

Source

Installs: 31

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 5

Type:component

dev-master 2018-03-15 05:29 UTC

This package is not auto-updated.

Last update: 2021-06-12 12:03:14 UTC


README

PHP Component to integrate with ECONT Courier

So far only calculation is possible.

$guzzle = new \GuzzleHttp\Client();
$client = new \Todstoychev\Econt\Client($guzzle, true, 'demo', 'demo');

$parcelRequest = new \Todstoychev\Econt\Request\ParcelRequest();
$parcelRequest->setOnlyCalculate(true);


$loading = new \Todstoychev\Econt\Model\Loading();

$sender = new \Todstoychev\Econt\Model\Sender();
$sender->setCountryCode('BRG');
$sender->setCity('София');
$sender->setPostCode('1000');
$loading->setSender($sender);


$receiver = new \Todstoychev\Econt\Model\Receiver();
$receiver->setCountryCode('BRG');
$receiver->setCity('Бургас');
$receiver->setPostCode('80001');
$loading->setReceiver($receiver);


$shipment = new \Todstoychev\Econt\Model\Shipment();
$shipment->setShipmentType(\Todstoychev\Econt\Model\Shipment::SHIPMENT_TYPE_PACK);
$shipment->setPackCount(1);
$shipment->setWeight(1);
$shipment->setTariffSubCode(\Todstoychev\Econt\Model\Shipment::TARIFF_SUB_CODE_DOOR_DOOR);
$loading->setShipment($shipment);

$parcelRequest->addLoading($loading);

/** @var \Todstoychev\Econt\Response\ParcelResponse $response */
$response = $client->execute($parcelRequest);

foreach ($response->getParcelResults() as $parcelResult) {
    if ($parcelResult->hasError()) {
        echo 'Грешка: ';
        foreach ($parcelResult->getError()->getMessages() as $errorMsg) {
            echo $errorMsg;
        }

    } else {
        echo 'Цена за доставка '.$parcelResult->getLoadingPrice()->getTotal().' '.$parcelResult->getLoadingPrice()->getCurrency()->getName();
    }
}

Example output with error:

Грешка: получател: Не е намерено населено място с пощенски код 80001

Example output without error:

Цена за доставка 7.8 лв