Class: Wes::Data::API::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/wes/data/api/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



8
9
10
# File 'lib/wes/data/api/response.rb', line 8

def initialize(response)
  @response = response
end

Instance Method Details

#buildObject



12
13
14
15
16
17
# File 'lib/wes/data/api/response.rb', line 12

def build
  raise unexpected_error unless valid_response(response)
  raise api_error unless VALID_RESPONSE_CODES.include?(response.status)
  data = response.body || {}
  data.map { |e| OpenStruct.new e }
end