Class: Response::StubHub
- Inherits:
-
Middleware
- Object
- Middleware
- Response::StubHub
- Defined in:
- lib/stub_hub_api/response.rb
Instance Method Summary collapse
Instance Method Details
#call(environment) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/stub_hub_api/response.rb', line 37 def call(environment) @app.call(environment).on_complete do |env| check_status(env) env[:body] = parse_body(env[:body]) end end |
#check_status(env) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/stub_hub_api/response.rb', line 27 def check_status(env) status = env[:status].to_s body = env[:body] if status =~ /^5/ raise ApiException.new({status: status, body: body}) elsif status =~ /^4/ raise ApiException.new({status: status, body: body}) end end |