Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
abel-wanglei committed Jan 12, 2018
1 parent 0bbc666 commit 35282a1
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 35 deletions.
2 changes: 0 additions & 2 deletions src/Amazon/MarketplaceWebService/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,6 @@ private function invoke(array $converted, $dataHandle = null, $contentMd5 = null
do {
try {
$response = $this->performRequest($actionName, $converted, $dataHandle, $contentMd5);

$httpStatus = $response['Status'];

switch ($httpStatus) {
Expand Down Expand Up @@ -1017,7 +1016,6 @@ private function parseHttpHeader($header) {
*/
private function responseCallback($ch, $string) {
$httpStatusCode = (int) curl_getinfo($this->curlClient, CURLINFO_HTTP_CODE);

// For unsuccessful responses, i.e. non-200 HTTP responses, we write the response body
// into a separate stream.
$responseHandle = null;
Expand Down
19 changes: 10 additions & 9 deletions src/Amazon/MarketplaceWebService/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
*/
namespace Amazon\MarketplaceWebService;

use DateTime;
use DateTimeZone;
use DOMElement;
Expand Down Expand Up @@ -172,8 +173,6 @@ private function fromDOMElement(DOMElement $dom)
if ($this->isComplexType($fieldType[0])) {
$elements = $xpath->query("./a:$fieldName", $dom);
if ($elements->length >= 1) {
//TODO
require_once (str_replace('_', DIRECTORY_SEPARATOR, $fieldType[0]) . ".php");
foreach ($elements as $element) {
$this->fields[$fieldName]['FieldValue'][] = new $fieldType[0]($element);
}
Expand All @@ -191,8 +190,6 @@ private function fromDOMElement(DOMElement $dom)
if ($this->isComplexType($fieldType)) {
$elements = $xpath->query("./a:$fieldName", $dom);
if ($elements->length == 1) {
//TODO
require_once (dirname(__FILE__) . '/../' . str_replace('_', DIRECTORY_SEPARATOR, $fieldType) . ".php");
$this->fields[$fieldName]['FieldValue'] = new $fieldType($elements->item(0));
}
} else {
Expand Down Expand Up @@ -238,8 +235,6 @@ private function fromAssociativeArray(array $array)
$elements = array($elements);
}
if (count ($elements) >= 1) {
//TODO
require_once (str_replace('_', DIRECTORY_SEPARATOR, $fieldType[0]) . ".php");
foreach ($elements as $element) {
$this->fields[$fieldName]['FieldValue'][] = new $fieldType[0]($element);
}
Expand All @@ -261,8 +256,6 @@ private function fromAssociativeArray(array $array)
} else {
if ($this->isComplexType($fieldType)) {
if (array_key_exists($fieldName, $array)) {
//TODO
require_once (str_replace('_', DIRECTORY_SEPARATOR, $fieldType) . ".php");
$this->fields[$fieldName]['FieldValue'] = new $fieldType($array[$fieldName]);
}
} else {
Expand All @@ -283,7 +276,7 @@ private function fromAssociativeArray(array $array)
*/
private function isComplexType ($fieldType)
{
return preg_match('/^MarketplaceWebService_Model_/', $fieldType);
return class_exists($fieldType);
}

/**
Expand Down Expand Up @@ -315,4 +308,12 @@ private function isDOMElement($var) {
protected function isNumericArray($var) {
return is_array($var) && array_keys($var) === range(0, sizeof($var) - 1);
}

/**
* @return string
*/
public static function className()
{
return get_called_class();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static function fromXML($xml)
if ($response->length == 1) {
return new CancelReportRequestsResponse(($response->item(0)));
} else {
throw new Exception ("Unable to construct CancelReportRequestsResponse from provided XML.
throw new \Exception ("Unable to construct CancelReportRequestsResponse from provided XML.
Make sure that CancelReportRequestsResponse is a root element");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class GetReportListResponse extends Model
public function __construct($data = null)
{
$this->fields = array (
'GetReportListResult' => array('FieldValue' => null, 'FieldType' => 'GetReportListResult'),
'ResponseMetadata' => array('FieldValue' => null, 'FieldType' => 'ResponseMetadata'),
'GetReportListResult' => array('FieldValue' => null, 'FieldType' => GetReportListResult::className()),
'ResponseMetadata' => array('FieldValue' => null, 'FieldType' => ResponseMetadata::className()),
);
parent::__construct($data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct($data = null)
$this->fields = array (
'NextToken' => array('FieldValue' => null, 'FieldType' => 'string'),
'HasNext' => array('FieldValue' => null, 'FieldType' => 'bool'),
'ReportInfo' => array('FieldValue' => array(), 'FieldType' => array('ReportInfo')),
'ReportInfo' => array('FieldValue' => array(), 'FieldType' => array(ReportInfo::className())),
);
parent::__construct($data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class GetReportRequestListResponse extends Model
public function __construct($data = null)
{
$this->fields = array (
'GetReportRequestListResult' => array('FieldValue' => null, 'FieldType' => 'GetReportRequestListResult'),
'ResponseMetadata' => array('FieldValue' => null, 'FieldType' => 'ResponseMetadata'),
'GetReportRequestListResult' => array('FieldValue' => null, 'FieldType' => GetReportRequestListResult::className()),
'ResponseMetadata' => array('FieldValue' => null, 'FieldType' => ResponseMetadata::className()),
);
parent::__construct($data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct($data = null)
$this->fields = array (
'NextToken' => array('FieldValue' => null, 'FieldType' => 'string'),
'HasNext' => array('FieldValue' => null, 'FieldType' => 'bool'),
'ReportRequestInfo' => array('FieldValue' => array(), 'FieldType' => array('ReportRequestInfo')),
'ReportRequestInfo' => array('FieldValue' => array(), 'FieldType' => array(ReportRequestInfo::className())),
);
parent::__construct($data);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Amazon/MarketplaceWebService/Model/GetReportResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class GetReportResponse extends Model
public function __construct($data = null)
{
$this->fields = array (
'GetReportResult' => array('FieldValue' => null, 'FieldType' => 'GetReportResult'),
'ResponseMetadata' => array('FieldValue' => null, 'FieldType' => 'ResponseMetadata'),
'GetReportResult' => array('FieldValue' => null, 'FieldType' => GetReportResult::className()),
'ResponseMetadata' => array('FieldValue' => null, 'FieldType' => ResponseMetadata::className()),
);
parent::__construct($data);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Amazon/MarketplaceWebService/Model/ReportInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public function __construct($data = null)
'ReportId' => array('FieldValue' => null, 'FieldType' => 'string'),
'ReportType' => array('FieldValue' => null, 'FieldType' => 'string'),
'ReportRequestId' => array('FieldValue' => null, 'FieldType' => 'string'),
'AvailableDate' => array('FieldValue' => null, 'FieldType' => 'DateTime'),
'AvailableDate' => array('FieldValue' => null, 'FieldType' => 'string'),
'Acknowledged' => array('FieldValue' => null, 'FieldType' => 'bool'),
'AcknowledgedDate' => array('FieldValue' => null, 'FieldType' => 'DateTime'),
'AcknowledgedDate' => array('FieldValue' => null, 'FieldType' => 'string'),
);
parent::__construct($data);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Amazon/MarketplaceWebService/Model/ReportRequestInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ public function __construct($data = null)
$this->fields = array (
'ReportRequestId' => array('FieldValue' => null, 'FieldType' => 'string'),
'ReportType' => array('FieldValue' => null, 'FieldType' => 'string'),
'StartDate' => array('FieldValue' => null, 'FieldType' => 'DateTime'),
'EndDate' => array('FieldValue' => null, 'FieldType' => 'DateTime'),
'StartDate' => array('FieldValue' => null, 'FieldType' => 'string'),
'EndDate' => array('FieldValue' => null, 'FieldType' => 'string'),
'Scheduled' => array('FieldValue' => null, 'FieldType' => 'bool'),
'SubmittedDate' => array('FieldValue' => null, 'FieldType' => 'DateTime'),
'SubmittedDate' => array('FieldValue' => null, 'FieldType' => 'string'),
'ReportProcessingStatus' => array('FieldValue' => null, 'FieldType' => 'string'),
'GeneratedReportId' => array('FieldValue' => null, 'FieldType' => 'string'),
'StartedProcessingDate' => array('FieldValue' => null, 'FieldType' => 'DateTime'),
'CompletedDate' => array('FieldValue' => null, 'FieldType' => 'DateTime'),
'StartedProcessingDate' => array('FieldValue' => null, 'FieldType' => 'string'),
'CompletedDate' => array('FieldValue' => null, 'FieldType' => 'string'),
);
parent::__construct($data);
}
Expand Down
13 changes: 6 additions & 7 deletions src/Amazon/MarketplaceWebService/Model/RequestReportResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,17 @@ class RequestReportResponse extends Model
public function __construct($data = null)
{
$this->fields = array (
'RequestReportResult' => array('FieldValue' => null, 'FieldType' => 'RequestReportResult'),
'ResponseMetadata' => array('FieldValue' => null, 'FieldType' => 'ResponseMetadata'),
'RequestReportResult' => array('FieldValue' => null, 'FieldType' => RequestReportResult::className()),
'ResponseMetadata' => array('FieldValue' => null, 'FieldType' => ResponseMetadata::className()),
);
parent::__construct($data);
}


/**
* Construct RequestReportResponse from XML string
*
* @param string $xml XML string to construct from
* @param $xml
* @return RequestReportResponse
* @throws \Exception
*/
public static function fromXML($xml)
{
Expand All @@ -78,7 +77,7 @@ public static function fromXML($xml)
if ($response->length == 1) {
return new RequestReportResponse(($response->item(0)));
} else {
throw new Exception ("Unable to construct RequestReportResponse from provided XML.
throw new \Exception ("Unable to construct RequestReportResponse from provided XML.
Make sure that RequestReportResponse is a root element");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RequestReportResult extends Model
public function __construct($data = null)
{
$this->fields = array (
'ReportRequestInfo' => array('FieldValue' => null, 'FieldType' => 'ReportRequestInfo'),
'ReportRequestInfo' => array('FieldValue' => null, 'FieldType' => ReportRequestInfo::className()),
);
parent::__construct($data);
}
Expand Down

0 comments on commit 35282a1

Please sign in to comment.