whichdigital / active-rest-client

ActiveRestClient API Client
https://rubygems.org/gems/active_rest_client
MIT License
386 stars 44 forks source link

ProxyBase translate does not understand XML #99

Closed canatella closed 9 years ago

canatella commented 9 years ago

When using proxy to modify a response in XML, the ProxyBase#translate method tries to parse the XML as JSON.

andyjeffries commented 9 years ago

Thanks for this. The XML support is really in beta form at the moment. Are you using it and this is a showstopper for you?

canatella commented 9 years ago

Nope, I worked around it, in case someones needs it:

class Proxy < ActiveRestClient::ProxyBase
    get(/./) do
        response = passthrough
        body = Crack::XML.parse(response.body)
        .... do some stuff....
        ActiveRestClient::FaradayResponseProxy.new(OpenStruct.new(status:response.status, response_headers:response.headers, body:body))
    end
end
andyjeffries commented 9 years ago

Try that commit, if it works I'll release it as a new version.