Class: Rapa::Responses::BaseResponse

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rapa/responses/base_response.rb

Direct Known Subclasses

ListItemsResponse, SearchItemsResponse

Instance Method Summary collapse

Constructor Details

#initialize(faraday_response) ⇒ BaseResponse



7
8
9
# File 'lib/rapa/responses/base_response.rb', line 7

def initialize(faraday_response)
  @faraday_response = faraday_response
end

Instance Method Details

#bodyString



12
13
14
# File 'lib/rapa/responses/base_response.rb', line 12

def body
  faraday_response.body
end

#each(&block) ⇒ Object

Note:

Implementation for Enumerable



17
18
19
# File 'lib/rapa/responses/base_response.rb', line 17

def each(&block)
  resources.each(&block)
end

#headersFaraday::Utils::Headers



22
23
24
# File 'lib/rapa/responses/base_response.rb', line 22

def headers
  faraday_response.headers
end

#resourcesArray<Rapa::Resources::ItemResource>



27
28
29
30
31
# File 'lib/rapa/responses/base_response.rb', line 27

def resources
  sources.map do |source|
    resource_class.new(source)
  end
end

#statusInteger



34
35
36
# File 'lib/rapa/responses/base_response.rb', line 34

def status
  faraday_response.status
end