HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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);


    }


}