Skip to content

Commit

Permalink
Closed #65: Raw response data
Browse files Browse the repository at this point in the history
  • Loading branch information
baibaratsky committed May 25, 2015
1 parent 9e1c5a5 commit 4486cc7
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Api/MegaStock/AddMerchant/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Response extends AbstractResponse
*/
public function __construct($response)
{
parent::__construct($response);

$responseObject = new \SimpleXMLElement($response);
$this->returnCode = (int)$responseObject->retval;
$this->returnDescription = (string)$responseObject->retdescr;
Expand Down
2 changes: 2 additions & 0 deletions Api/MegaStock/CheckMerchant/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Response extends AbstractResponse
*/
public function __construct($response)
{
parent::__construct($response);

$responseObject = new \SimpleXMLElement($response);
$this->returnCode = (int)$responseObject->retval;
$this->returnDescription = (string)$responseObject->retdescr;
Expand Down
2 changes: 2 additions & 0 deletions Api/X/X11/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class Response extends AbstractResponse
*/
public function __construct($response)
{
parent::__construct($response);

$responseObject = new \SimpleXMLElement($response);
$this->returnCode = (int)$responseObject['retval'];
$this->returnDescription = (string)$responseObject['retdesc'];
Expand Down
2 changes: 2 additions & 0 deletions Api/X/X14/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class Response extends AbstractResponse

public function __construct($response)
{
parent::__construct($response);

$responseObject = new \SimpleXMLElement($response);
$this->requestNumber = (int)$responseObject->reqn;
$this->returnCode = (int)$responseObject->retval;
Expand Down
2 changes: 2 additions & 0 deletions Api/X/X17/ContractInfo/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Response extends AbstractResponse
*/
public function __construct($response)
{
parent::__construct($response);

$responseObject = new \SimpleXMLElement($response);
$this->returnCode = (int)$responseObject->retval;
$this->returnDescription = (string)$responseObject->retdesc;
Expand Down
2 changes: 2 additions & 0 deletions Api/X/X17/CreateContract/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Response extends AbstractResponse
*/
public function __construct($response)
{
parent::__construct($response);

$responseObject = new \SimpleXMLElement($response);
$this->returnCode = (int)$responseObject->retval;
$this->returnDescription = (string)$responseObject->retdesc;
Expand Down
2 changes: 2 additions & 0 deletions Api/X/X18/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class Response extends AbstractResponse
*/
public function __construct($response)
{
parent::__construct($response);

$responseObject = new \SimpleXMLElement($response);
$this->returnCode = (int)$responseObject->retval;
$this->returnDescription = (string)$responseObject->retdesc;
Expand Down
2 changes: 2 additions & 0 deletions Api/X/X19/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Response extends AbstractResponse
*/
public function __construct($response)
{
parent::__construct($response);

$responseObject = new \SimpleXMLElement($response);
$this->returnCode = (int)$responseObject->retval;
$this->returnDescription = (string)$responseObject->retdesc;
Expand Down
2 changes: 2 additions & 0 deletions Api/X/X2/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class Response extends AbstractResponse
*/
public function __construct($response)
{
parent::__construct($response);

$responseObject = new \SimpleXMLElement($response);
$this->returnCode = (int)$responseObject->retval;
$this->returnDescription = (string)$responseObject->retdesc;
Expand Down
2 changes: 2 additions & 0 deletions Api/X/X3/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class Response extends AbstractResponse
*/
public function __construct($response)
{
parent::__construct($response);

$responseObject = new \SimpleXMLElement($response);
$this->requestNumber = (int)$responseObject->reqn;
$this->returnCode = (int)$responseObject->retval;
Expand Down
2 changes: 2 additions & 0 deletions Api/X/X6/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Response extends AbstractResponse
*/
public function __construct($response)
{
parent::__construct($response);

$responseObject = new \SimpleXMLElement($response);
$this->returnCode = (int)$responseObject->retval;
$this->returnDescription = (string)$responseObject->retdesc;
Expand Down
2 changes: 2 additions & 0 deletions Api/X/X8/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class Response extends AbstractResponse
*/
public function __construct($response)
{
parent::__construct($response);

$responseObject = new \SimpleXMLElement($response);
$this->returnCode = (int)$responseObject->retval;
$this->returnDescription = (string)$responseObject->retdesc;
Expand Down
2 changes: 2 additions & 0 deletions Api/X/X9/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Response extends AbstractResponse

public function __construct($response)
{
parent::__construct($response);

$responseObject = new \SimpleXMLElement($response);
$this->requestNumber = (int)$responseObject->reqn;
$this->returnCode = (int)$responseObject->retval;
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,14 @@ $request->setRequestedWmid('REQUESTED WMID');
$request->sign(new Signer('YOUR WMID', 'FULL PATH TO KEY FILE', 'KEY FILE PASSWORD'));
// You can access the request XML: $request->getData()
if ($request->validate()) {
/** @var WebMoney\Api\X\X9\Response $response */
$response = $webMoney->request($request);
// The response from WebMoney is here: $response->getRawData()
if ($response->getReturnCode() === 0) {
echo $response->getPurseByName('Z000000000000')->getAmount();
} else {
Expand Down
20 changes: 17 additions & 3 deletions Request/AbstractResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@

abstract class AbstractResponse
{
/** @var \DateTimeZone */
private static $timeZone;
/** @var string Raw response data from WM */
protected $rawData;

/** @var int retval */
protected $returnCode;

/** @var string retdesc */
protected $returnDescription;

/** @var \DateTimeZone */
private static $timeZone;

/**
* @param string $response
*/
abstract public function __construct($response);
public function __construct($response)
{
$this->rawData = $response;
}

/**
* @return string Fully qualified name of the class
Expand Down Expand Up @@ -63,4 +69,12 @@ public function getReturnDescription()
{
return $this->returnDescription;
}

/**
* @return string
*/
public function getRawData()
{
return $this->rawData;
}
}

0 comments on commit 4486cc7

Please sign in to comment.