@@ -124,6 +124,12 @@ protected function array2xml($arr, &$xml)
124124
125125final class Client extends iClient
126126{
127+
128+ /**
129+ * Store the last response body string
130+ */
131+ protected $ lastResponseBody = null ;
132+
127133 public function __construct ($ login , $ password , $ options = [])
128134 {
129135 if (empty ($ login ) || empty ($ password ))
@@ -270,6 +276,7 @@ public function raw_file_put($url, $content, $headers = [])
270276 */
271277 public function request ($ method , $ url , $ options = [], $ parse = true )
272278 {
279+ $ this ->lastResponseBody = null ;
273280 try
274281 {
275282 $ response = $ this ->client ->request ($ method , ltrim ($ url , '/ ' ), $ options );
@@ -285,6 +292,14 @@ public function request($method, $url, $options = [], $parse = true)
285292 }
286293 }
287294
295+ /**
296+ * Returns the XML string received in the last response.
297+ * @return string $lastResponseBody
298+ */
299+ public function getLastResponseBody () {
300+ return $ this ->lastResponseBody ;
301+ }
302+
288303 /**
289304 * Prepare XML string body
290305 *
@@ -335,6 +350,7 @@ private function parseResponse($response)
335350 }
336351
337352 $ responseBody = (string ) $ response ->getBody ();
353+ $ this ->lastResponseBody = $ responseBody ;
338354
339355 if (!$ responseBody )
340356 {
0 commit comments