<?php
/**
 * Copyright © 2018 EaDesign by Eco Active S.R.L. All rights reserved.
 * See LICENSE for license details.
 */

namespace Eadesigndev\Awb\Helper;

use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\UrlInterface;
use Eadesigndev\Urgent\Model\Sources\PickupId as PickupUrgent;
use Eadesigndev\FanCourier\Model\Sources\PickupId as PickupFanCourier;
use Eadesigndev\DPD\Model\Sources\PickupId as PickupDPD;
use Eadesigndev\GLS\Model\Sources\PickupId as PickupGLS;
use Eadesigndev\DragonStar\Model\Sources\PickupId as PickupDragonStar;
use Eadesigndev\xCurier\Model\Sources\PickupId as PickupXCurier;
use Eadesigndev\Awb\Model\Sources\CarrierType;

/**
 * Handles the config and other settings
 *
 * Class Data
 * @package Eadesigndev\Awb\Helper
 */
#[\AllowDynamicProperties]
class PickupName extends AbstractHelper
{
    protected $_urlInterface;
    protected $_objectManager;

    public function __construct(
        Context $context,
        UrlInterface $urlInterface,
        PickupUrgent $pickupUrgent,
        PickupFanCourier $pickupFanCourier,
        PickupDPD $pickupDPD,
        PickupGLS $pickupGLS,
        PickupDragonStar $pickupDragonStar,
        PickupXCurier $pickupXCurier
    )
    {
        $this->pickupUrgent = $pickupUrgent;
        $this->pickupFanCourier = $pickupFanCourier;
        $this->pickupDPD = $pickupDPD;
        $this->pickupGLS = $pickupGLS;
        $this->pickupDragonStar = $pickupDragonStar;
        $this->pickupXCurier = $pickupXCurier;

        $this->_urlInterface = $urlInterface;
        parent::__construct($context);
    }

    public function getPickUpName($carrierId, $identifier)
    {
        switch ($carrierId)
        {
            case CarrierType::URGENT_CURRIER:
                $currentCarrierPickupPointsRepository = $this->pickupUrgent->getAvailable();
                break;
            case CarrierType::FAN_CURRIER:
                $currentCarrierPickupPointsRepository = $this->pickupFanCourier->getAvailable();
                break;
            case CarrierType::DPD:
                $currentCarrierPickupPointsRepository = $this->pickupDPD->getAvailable();
                break;
            case CarrierType::GLS:
                $currentCarrierPickupPointsRepository = $this->pickupGLS->getAvailable();
                break;
            case CarrierType::DRAGON_STAR:
                $currentCarrierPickupPointsRepository = $this->pickupDragonStar->getAvailable();
                break;
            case CarrierType::X_CURIER:
                $currentCarrierPickupPointsRepository = $this->pickupXCurier->getAvailable();
                break;
        }

        return $currentCarrierPickupPointsRepository[$identifier];
    }
}