Closed barryvdh closed 6 years ago
Or should we decorate the response, instead of returning a plain psr-7 response?
See #163
Many gateways use different send and receive formats. I'm working on GiroCheckout where you send form-encoded and receive JSON on response. So the request and response data types are by no means paired up.
With the decorator we can decouple that, so we could have a method to send json/formdata, but process it separately.
Presumably a driver can extend that decorator to add other conversions too, such as CSV and name/value lines, just to keep the logic in the right place..
I think this would probably be a bit to opiniated.
This adds a
json
andxml
helper method to the HttpClient, to make it easier to request/process json or xml feeds.The
Accept
andContent-Type
are set by default when not set.Note that this slightly changes the
ResponseParser::json()
method to be inline with the normaljson_decode
options, but perhaps these can be made private, because these helpers would make them not so much needed.