Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
wsagen committed Jun 16, 2016
2 parents ad7b398 + c384dd0 commit 46cc034
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 55 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [20.0.3] - 2016-06-01
### Added
- SHQ16-613 Modified request to support inventory objects

## [20.0.4] - 2016-06-15
### Added
- SHQ16-1094 Changed permissions on inventory objects
- SHQ16-1085, SHQ16-873 Support for WooCommerce
50 changes: 50 additions & 0 deletions src/Client/WebServiceClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,54 @@ public function sendAndReceive(WebServiceRequestInterface $requestObj, $webServi

return $result;
}

/**
* @param \ShipperHQ\WS\WebServiceRequest $requestObj
* @param $webServicePath
* @return mixed|null
*/
public function sendAndReceiveWp(WebServiceRequestInterface $requestObj, $webServiceURL, $timeout = 30)
{

$jsonRequest = json_encode($requestObj);
$debugRequest = $requestObj;
$debugRequest->credentials->password = null;
$jsonDebugRequest = json_encode($debugRequest, JSON_PRETTY_PRINT);
$debugData['json_request'] = $jsonDebugRequest;
$debugData['url'] = $webServiceURL;
$responseBody = '';

$headers = array(
'Content-Type' => 'application/json',
);

try {

$args = array(
'timeout' => $timeout,
'headers' => $headers,
'body' => $jsonRequest
);

//$client->setConfig(['maxredirects' => 0, 'timeout' => $timeout]); // TODO maxredirects
$response = wp_remote_post( $webServiceURL, $args );

if (!is_null($response)) {
$body = wp_remote_retrieve_body( $response );

// Decode if it's json
$responseBody = json_decode( $body, false );
}

$debugData['response'] = $responseBody;

} catch (\Exception $e) {
$debugData['error'] = ['error' => $e->getMessage(), 'code' => $e->getCode()];
$debugData['response'] = '';
}

$result = ['result' => $responseBody, 'debug' => $debugData];

return $result;
}
}
57 changes: 2 additions & 55 deletions src/Rate/Request/Checkout/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
*/
class Cart {

public $weight;
public $price;
public $qty;
public $declaredValue;
public $freeShipping;
public $items;
Expand All @@ -57,15 +54,12 @@ function __construct($declaredValue = 0.0, $freeShipping = false, $items = [],
$this->declaredValue = $declaredValue;
$this->freeShipping = $freeShipping;
$this->items = $items;
$this->price = $price;
$this->qty = $qty;
$this->weight = $weight;
}

/**
* @param float $declaredValue
*/
public function setDeclaredValue(float $declaredValue)
public function setDeclaredValue($declaredValue)
{
$this->declaredValue = $declaredValue;
}
Expand All @@ -81,7 +75,7 @@ public function getDeclaredValue()
/**
* @param boolean $freeShipping
*/
public function setFreeShipping(boolean $freeShipping)
public function setFreeShipping($freeShipping)
{
$this->freeShipping = $freeShipping;
}
Expand Down Expand Up @@ -110,51 +104,4 @@ public function getItems()
return $this->items;
}

/**
* @param float $price
*/
public function setPrice(float $price)
{
$this->price = $price;
}

/**
* @return float
*/
public function getPrice()
{
return $this->price;
}

/**
* @param int $qty
*/
public function setQty(integer $qty)
{
$this->qty = $qty;
}

/**
* @return int
*/
public function getQty()
{
return $this->qty;
}

/**
* @param float $weight
*/
public function setWeight(float $weight)
{
$this->weight = $weight;
}

/**
* @return float
*/
public function getWeight()
{
return $this->weight;
}
}

0 comments on commit 46cc034

Please sign in to comment.