Class: Dwolla::Response::ParseJson
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Dwolla::Response::ParseJson
- Defined in:
- lib/dwolla/response/parse_json.rb
Instance Method Summary collapse
Instance Method Details
#on_complete(env) ⇒ Object
7 8 9 10 11 |
# File 'lib/dwolla/response/parse_json.rb', line 7 def on_complete(env) if respond_to? :parse env[:body] = parse(env[:body]) unless [204,302,304,307].index env[:status] end end |
#parse(body) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dwolla/response/parse_json.rb', line 13 def parse(body) case body when '' nil else response_hash = ::MultiJson.decode(body) response_hash["Response"] || response_hash["SendResult"] || response_hash["RequestResult"] || response_hash end end |