File: D:/HostingSpaces/SBogers10/topswtw.komma.pro/app/KommaApp/Shop/Dpd/dpdService.php
<?php
namespace KommaApp\Shop\Dpd;
/**
* This class bundles the dpd services.
*
* @author Tim Van Samang <timvansamang@komma.pro>
* @copyright (c) 2012-2015, Komma Mediadesign
*/
use KommaApp\Shop\Dpd\DpdParcelShopFinder;
class DpdService
{
public $parcelShopFinder;
public function __construct(DpdParcelShopFinder $parcelShopFinder)
{
//Load the parcelShopFinder
$this->parcelShopFinder = $parcelShopFinder;
//Login
if (!$this->parcelShopFinder->login()) mooi('stop');
}
public function searchParcelShops($data = null)
{
$this->parcelShopFinder->search($data);
foreach($this->parcelShopFinder->results as $key => $shop)
{
$parcelshop_cookie[$shop->parcelShopId] = new \stdClass();
$parcelshop_cookie[$shop->parcelShopId]->id = $shop->parcelShopId;
$parcelshop_cookie[$shop->parcelShopId]->name = $shop->company;
$parcelshop_cookie[$shop->parcelShopId]->address = $shop->street . ' ' . $shop->houseNo;
$parcelshop_cookie[$shop->parcelShopId]->postcode = $shop->zipCode;
$parcelshop_cookie[$shop->parcelShopId]->city = $shop->city;
//todo dynamic
$parcelshop_cookie[$shop->parcelShopId]->id_country = $shop->isoAlpha2;
}
\Cookie::make('parcelshops', serialize($parcelshop_cookie));
return json_encode($this->parcelShopFinder->results);
}
}