Class: Vidsy::Data::API::Response

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



13
14
15
# File 'lib/vidsy/data/api/response.rb', line 13

def initialize(response)
  @response = response
end

Class Method Details

.build(response) ⇒ Object



9
10
11
# File 'lib/vidsy/data/api/response.rb', line 9

def self.build(response)
  new(response).data
end

Instance Method Details

#dataObject



17
18
19
20
21
# File 'lib/vidsy/data/api/response.rb', line 17

def data
  raise unexpected_error unless response.body
  data = response.body["data"] || raise(response_error)
  data.map { |e| OpenStruct.new e }
end