<?php
    
    include("../include/config.php");
    
    
    include("../include/functions.php");
    
    
    include("../include/CourierService.php");
    
    
    //print_r($obj);
    $ups = new CourierService($obj);
    if ($_REQUEST['type'] == 'zone') {
        $ups->setStoreID(1);
        
        $ups->setShipToPostalCode($_REQUEST['zipcode']);
        
        
        $label = $ups->getZone();
        
        
        $errors = (json_decode($ups->getError()));
        
      
        
        if (isset($errors->Status->result) && $errors->Status->result == false) {
            
            echo $errors->Status->message;
            
            exit;
            
        } else {
            print_r($label);
        }
    }
    if ($_REQUEST['type'] == 'delivery') {
        $estmateDArray = array('PostalCodeShipper' => '60659',
            'StateProvinceCodeShipper' => 'IL',
            'CountryCodeShipper' => 'US', 'PostalCodeShipTo' => $_REQUEST['zipcode'],
            'StateProvinceCodeShipTo' => 'IL', 'CountryCodeShipTo' => 'US'
        , 'UnitOfMeasurement' => 'LBS', 'Weight' => '5', 'ServiceCode' => 'GND', 'ServiceDescription' => 'UPS Ground'
        , 'PickupDate' => '20190429');
        $EstimateDeliveryDate = $ups->getEstimateDeliveryDate($estmateDArray);
        if ($EstimateDeliveryDate != '') {
            $EstimateDeliveryDate = date("m-d-Y", strtotime($EstimateDeliveryDate));
        }
        print_r('Estimate Delivery Date: ' . $EstimateDeliveryDate);
    }

?>
