Class: Storenvy::ResponseParser
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Storenvy::ResponseParser
- Defined in:
- lib/storenvy/core/response_parser.rb
Defined Under Namespace
Classes: HTTPUnauthorized
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/storenvy/core/response_parser.rb', line 6 def call(env) # "env" contains the request @app.call(env).on_complete do body = false if env[:status] == 200 body = env[:response].body.response || env[:response].body elsif env[:status] == 401 raise Storenvy::ResponseParser::HTTPUnauthorized.new 'invalid storeenvy credentials' elsif env[:response] && env[:response].body && env[:response].body.status body = env[:response].body.status end env[:body] = body end end |