Class: Response::VividSeat
- Inherits:
-
Middleware
- Object
- Middleware
- Response::VividSeat
- Defined in:
- lib/vivid_seat_api/response.rb
Instance Method Summary collapse
Instance Method Details
#call(environment) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/vivid_seat_api/response.rb', line 19 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
10 11 12 13 14 15 16 17 |
# File 'lib/vivid_seat_api/response.rb', line 10 def check_status(env) status = env[:status].to_s if status =~ /^5/ raise ApiException.new("Bad Token, status #{status}") elsif status =~ /^4/ raise ApiException.new("Error #{status}") end end |
#parse_body(body) ⇒ Object
6 7 8 |
# File 'lib/vivid_seat_api/response.rb', line 6 def parse_body(body) Nokogiri::XML(body) end |