Class: Scrapinghub::ApiResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/scrapinghub/api_response.rb

Instance Method Summary collapse

Constructor Details

#initialize(net_http_request) ⇒ ApiResponse

Returns a new instance of ApiResponse.



5
6
7
8
9
10
11
12
# File 'lib/scrapinghub/api_response.rb', line 5

def initialize(net_http_request)
  case net_http_request
  when Net::HTTPOK
    @body = JSON.parse(net_http_request.body)
  else
    raise "Invalid Net:HTTP request sent to ApiResponse"
  end
end

Instance Method Details

#responseObject



14
15
16
# File 'lib/scrapinghub/api_response.rb', line 14

def response
  @body
end