From 74f69bc521bdddc8b047a552159338efcd68eda6 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 12 Feb 2020 16:32:37 +0200 Subject: [PATCH 1/2] feat(Client) - added option to get last response body from client --- core/Client.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/Client.php b/core/Client.php index 4e80038..76e0578 100644 --- a/core/Client.php +++ b/core/Client.php @@ -124,6 +124,9 @@ protected function array2xml($arr, &$xml) final class Client extends iClient { + + protected $lastResponseBody = null; + public function __construct($login, $password, $options = []) { if (empty($login) || empty($password)) @@ -270,6 +273,7 @@ public function raw_file_put($url, $content, $headers = []) */ public function request($method, $url, $options = [], $parse = true) { + $this->lastResponseBody = null; try { $response = $this->client->request($method, ltrim($url, '/'), $options); @@ -285,6 +289,14 @@ public function request($method, $url, $options = [], $parse = true) } } + /** + * Returns the XML string received in the last response. + * @return type + */ + public function getLastResponseBody() { + return $this->lastResponseBody; + } + /** * Prepare XML string body * @@ -335,6 +347,7 @@ private function parseResponse($response) } $responseBody = (string) $response->getBody(); + $this->lastResponseBody = $responseBody; if (!$responseBody) { From ae88037c9196739117dede84320883eca6c005ef Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 14 Feb 2020 19:27:12 +0200 Subject: [PATCH 2/2] doc(Client) - added missing description --- core/Client.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/Client.php b/core/Client.php index 76e0578..1cd4181 100644 --- a/core/Client.php +++ b/core/Client.php @@ -125,6 +125,9 @@ protected function array2xml($arr, &$xml) final class Client extends iClient { + /** + * Store the last response body string + */ protected $lastResponseBody = null; public function __construct($login, $password, $options = []) @@ -291,7 +294,7 @@ public function request($method, $url, $options = [], $parse = true) /** * Returns the XML string received in the last response. - * @return type + * @return string $lastResponseBody */ public function getLastResponseBody() { return $this->lastResponseBody;