Class: AppleMusic::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/apple_music/response.rb

Overview

Direct Known Subclasses

SearchResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(props = {}) ⇒ Response

Returns a new instance of Response.



8
9
10
11
12
13
14
15
16
17
# File 'lib/apple_music/response.rb', line 8

def initialize(props = {})
  props ||= {}
  @data = Array(props['data']).map { |attrs| Resource.build(attrs) }
  @errors = Array(props['errors']).map { |attrs| Error.new(attrs) }
  @href = props['href']
  @meta = props['meta']
  @next = props['next']
  @results = props['results']
  raise_api_error unless success?
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/apple_music/response.rb', line 6

def data
  @data
end

#errorsObject (readonly)

Returns the value of attribute errors.



6
7
8
# File 'lib/apple_music/response.rb', line 6

def errors
  @errors
end

#hrefObject (readonly)

Returns the value of attribute href.



6
7
8
# File 'lib/apple_music/response.rb', line 6

def href
  @href
end

#metaObject (readonly)

Returns the value of attribute meta.



6
7
8
# File 'lib/apple_music/response.rb', line 6

def meta
  @meta
end

#nextObject (readonly)

Returns the value of attribute next.



6
7
8
# File 'lib/apple_music/response.rb', line 6

def next
  @next
end

#resultsObject (readonly)

Returns the value of attribute results.



6
7
8
# File 'lib/apple_music/response.rb', line 6

def results
  @results
end