Skip to content

Commit

Permalink
SHQ16-1119 process merged rates
Browse files Browse the repository at this point in the history
  • Loading branch information
wsagen committed Jun 23, 2016
2 parents 383545d + 7cdaf52 commit 54c30fa
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 128 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Added
- SHQ16-1026 - display selected carrier and code for single carrier display
- SHQ16-1117 - correct customer group in request

## [20.0.9] - 2016-06-23
### Added
- SHQ16-1119 - process merged rates
78 changes: 0 additions & 78 deletions src/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
protected static $showTransId;
protected static $wsTimeout;
protected $prodAttributes;
protected $baseCurrencyRate;

Expand Down Expand Up @@ -264,60 +263,6 @@ public function getMultiAddressTemplate()
return 'checkout/multishipping/shipping.phtml';
}


/**
* Retrieve url for getting allowed methods
* @return string
*/
public function getAllowedMethodGatewayUrl()
{
return $this->_getGatewayUrl().'allowed_methods';
}

/**
* Retrieve url for getting shipping rates
* @return string
*/
public function getRateGatewayUrl()
{
return $this->_getGatewayUrl().'rates';

}

/*
* *Retrieve url for retrieving attributes
*/
public function getAttributeGatewayUrl()
{
return $this->_getGatewayUrl().'attributes/get';
}

/*
* *Retrieve url for retrieving attributes
*/
public function getCheckSynchronizedUrl()
{
return $this->_getGatewayUrl().'attributes/check';
}

/*
* Retrieve configured timeout for webservice
*/
public function getWebserviceTimeout()
{

if (self::$wsTimeout==NULL) {
$timeout = $this->getConfigValue('carriers/shipper/ws_timeout');
if(!is_numeric($timeout) || $timeout < 120) {
$timeout = 120;
}
self::$wsTimeout = $timeout;
}
return self::$wsTimeout;
}



public function encodeShippingDetails($shippingDetails)
{
return $this->jsonHelper->jsonEncode($shippingDetails);
Expand Down Expand Up @@ -496,29 +441,6 @@ public function getAttribute($attribute_code, $store = null) {
return $attribute;
}


/**
* Returns url to use - live if present, otherwise dev
* @return array
*/
protected function _getGatewayUrl()
{
$live = $this->_cleanUpUrl($this->getConfigValue('carriers/shipper/live_url'));

$test = $this->_cleanUpUrl($this->getConfigValue('carriers/shipper/url'));
return $this->getConfigValue('carriers/shipper/sandbox_mode') ? $test : $live;
}

protected function _cleanUpUrl($urlStart)
{
$url = trim($urlStart);
$lastChar = substr("abcdef", -1);
if($lastChar != '/') {
$url .= '/';
}
return $url;
}

/**
* Get carrier by its code
*
Expand Down
137 changes: 137 additions & 0 deletions src/Helper/Rest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?php
/**
*
* ShipperHQ Shipping Module
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* Shipper HQ Shipping
*
* @category ShipperHQ
* @package ShipperHQ_Shipping_Carrier
* @copyright Copyright (c) 2015 Zowta LLC (http://www.ShipperHQ.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author ShipperHQ Team sales@shipperhq.com
*/
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace ShipperHQ\Shipper\Helper;

/**
* Shipping data helper
*/
class Rest extends Data
{
protected static $wsTimeout;

/*
* @var \ShipperHQ\Lib\Helper\Rest
*/
protected $restHelper;
/*
* $var Data $shipperHelperData
*/

/**
* @param \ShipperHQ\Lib\Helper\Rest $restHelper
* @param Data $shipperHelperData
*/
public function __construct(\ShipperHQ\Lib\Helper\Rest $restHelper,
Data $shipperHelperData)
{
$this->restHelper = $restHelper;
$this->shipperHelperData = $shipperHelperData;
$this->restHelper->setBaseUrl($this->getGatewayUrl());
}

/**
* Retrieve url for getting allowed methods
* @return string
*/
public function getAllowedMethodGatewayUrl()
{
return $this->restHelper->getAllowedMethodGatewayUrl();
}

/**
* Retrieve url for getting shipping rates
* @return string
*/
public function getRateGatewayUrl()
{
return $this->restHelper->getRateGatewayUrl();

}

/*
* *Retrieve url for retrieving attributes
*/
public function getAttributeGatewayUrl()
{
return $this->restHelper->getAttributeGatewayUrl();
}

/*
* *Retrieve url for retrieving attributes
*/
public function getCheckSynchronizedUrl()
{
return $this->restHelper->getCheckSynchronizedUrl();
}

/*
* Retrieve configured timeout for webservice
*/
public function getWebserviceTimeout()
{

if (self::$wsTimeout==NULL) {
$timeout = $this->shipperHelperData->getConfigValue('carriers/shipper/ws_timeout');
if(!is_numeric($timeout) || $timeout < 120) {
$timeout = 120;
}
self::$wsTimeout = $timeout;
}
return self::$wsTimeout;
}


/**
* Returns url to use - live if present, otherwise dev
* @return array
*/
protected function getGatewayUrl()
{
$live = $this->cleanUpUrl($this->shipperHelperData->getConfigValue('carriers/shipper/live_url'));

$test = $this->cleanUpUrl($this->shipperHelperData->getConfigValue('carriers/shipper/url'));
return $this->shipperHelperData->getConfigValue('carriers/shipper/sandbox_mode') ? $test : $live;
}

protected function cleanUpUrl($urlStart)
{
$url = trim($urlStart);
$lastChar = substr("abcdef", -1);
if($lastChar != '/') {
$url .= '/';
}
return $url;
}
}
Loading

0 comments on commit 54c30fa

Please sign in to comment.