Throw FedexRequestException with message from FedEx when FedEx returns error instead of \Exception with generic error message.
parent
d1281805ea
commit
539ea90a14
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace pdt256\Shipping\Fedex;
|
||||
|
||||
use pdt256\Shipping\RateRequest\RequestException;
|
||||
|
||||
class FedexRequestException extends RequestException
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $severity;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSeverity()
|
||||
{
|
||||
return $this->severity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $severity
|
||||
*/
|
||||
public function setSeverity($severity)
|
||||
{
|
||||
$this->severity = $severity;
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><RateReply xmlns="http://fedex.com/ws/rate/v13"><HighestSeverity>WARNING</HighestSeverity><Notifications><Severity>WARNING</Severity><Source>crs</Source><Code>556</Code><Message>There are no valid services available. </Message><LocalizedMessage>There are no valid services available. </LocalizedMessage></Notifications><Version><ServiceId>crs</ServiceId><Major>13</Major><Intermediate>0</Intermediate><Minor>0</Minor></Version></RateReply></SOAP-ENV:Body></SOAP-ENV:Envelope>
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace pdt256\Shipping\RateRequest;
|
||||
|
||||
class StubFailingFedex extends StubFedex
|
||||
{
|
||||
public function execute($url, $data = null)
|
||||
{
|
||||
if ($this->artificialDelay > 0) {
|
||||
sleep($this->artificialDelay);
|
||||
}
|
||||
|
||||
return file_get_contents(__DIR__ . '/FedexErrorResponse.xml');
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace pdt256\Shipping\RateRequest;
|
||||
|
||||
class StubIncorrectResponseAdapter extends Adapter
|
||||
{
|
||||
protected $artificialDelay = 0;
|
||||
|
||||
public function __construct($artificial_delay = 0)
|
||||
{
|
||||
$this->artificialDelay = $artificial_delay;
|
||||
}
|
||||
|
||||
public function execute($url, $data = null)
|
||||
{
|
||||
if ($this->artificialDelay > 0) {
|
||||
sleep($this->artificialDelay);
|
||||
}
|
||||
|
||||
return '<html/>';
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue