@@ -67,13 +67,24 @@ public static function fromSoapFault(\SoapFault $soapFault)
67
67
/**
68
68
* Get the full SOAP enveloppe response.
69
69
*
70
+ * @deprecated removed in v2 and replaced by toPsrResponse
70
71
* @return string
71
72
*/
72
73
public function getResponse (): string
73
74
{
74
75
return $ this ->response ;
75
76
}
76
77
78
+ /**
79
+ * Get the underlying PSR response for the response.
80
+ *
81
+ * @return \Psr\Http\Message\ResponseInterface
82
+ */
83
+ public function toPsrResponse ()
84
+ {
85
+ return $ this ->response ;
86
+ }
87
+
77
88
/**
78
89
* Get the JSON decoded body of the response as an object.
79
90
*
@@ -133,6 +144,16 @@ public function ok()
133
144
return $ this ->status () === 200 ;
134
145
}
135
146
147
+ /**
148
+ * Determine if the response indicates a client or server error occurred.
149
+ *
150
+ * @return bool
151
+ */
152
+ public function failed ()
153
+ {
154
+ return $ this ->serverError () || $ this ->clientError ();
155
+ }
156
+
136
157
/**
137
158
* Determine if the response was a redirect.
138
159
*
@@ -152,7 +173,7 @@ public function redirect()
152
173
*/
153
174
public function throw ()
154
175
{
155
- if ($ this ->serverError () || $ this -> clientError ()) {
176
+ if ($ this ->failed ()) {
156
177
throw new RequestException ($ this );
157
178
}
158
179
@@ -242,6 +263,16 @@ public function offsetUnset($offset)
242
263
throw new LogicException ('Response data may not be mutated using array access. ' );
243
264
}
244
265
266
+ /**
267
+ * Get the body of the response.
268
+ *
269
+ * @return string
270
+ */
271
+ public function __toString ()
272
+ {
273
+ return $ this ->body ();
274
+ }
275
+
245
276
/**
246
277
* Dynamically proxy other methods to the underlying response.
247
278
*
0 commit comments