<?php
/**
 * Created by PhpStorm.
 * User: steven
 * Date: 7/26/19
 * Time: 2:35 PM
 */

namespace Hilco\XMLBuilder;

use Hilco\XMLBuilder\XMLUtility;
class RateShopUtility extends XMLUtility
{
    public function __construct($attributes)
    {
        parent::__construct($attributes);
    }


    public function getRates(){
        $rateValues = [];
        if($this->simpleXML == null){
            $this->simpleXML = simplexml_load_string($this->xml);
        }
        $simpleXML = $this->simpleXML;
        if ($simpleXML != null) {
            $Rates = $simpleXML->RateShop->Rate;
            $rateValues = XMLUtility::retrieveStackValues($Rates, [], [
                'carrier_name' => ['Carrier'],
                'api_code' => ['CarrierServiceCode'],
                'carrier_desc' => ['Service'],
                'rate' => ['PublishedRate'],
                'discounted_rate' => ['DiscountedRate'],
                'delivery_datetime' => ['EstmatedTime'] // Yes, it's mispelled like that at least as of this time (7/26/2019: 3:13 PM)
            ]);
        }

        return $rateValues;
    }
    


}