Class: SpotifyWebApi::AudiobookObject

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/spotify_web_api/models/audiobook_object.rb

Overview

AudiobookObject Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(authors = nil, available_markets = nil, copyrights = nil, description = nil, html_description = nil, explicit = nil, external_urls = nil, href = nil, id = nil, images = nil, languages = nil, media_type = nil, name = nil, narrators = nil, publisher = nil, type = nil, uri = nil, total_chapters = nil, chapters = nil, edition = SKIP) ⇒ AudiobookObject

Returns a new instance of AudiobookObject.



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 137

def initialize(authors = nil, available_markets = nil, copyrights = nil,
               description = nil, html_description = nil, explicit = nil,
               external_urls = nil, href = nil, id = nil, images = nil,
               languages = nil, media_type = nil, name = nil,
               narrators = nil, publisher = nil, type = nil, uri = nil,
               total_chapters = nil, chapters = nil, edition = SKIP)
  @authors = authors
  @available_markets = available_markets
  @copyrights = copyrights
  @description = description
  @html_description = html_description
  @edition = edition unless edition == SKIP
  @explicit = explicit
  @external_urls = external_urls
  @href = href
  @id = id
  @images = images
  @languages = languages
  @media_type = media_type
  @name = name
  @narrators = narrators
  @publisher = publisher
  @type = type
  @uri = uri
  @total_chapters = total_chapters
  @chapters = chapters
end

Instance Attribute Details

#authorsArray[AuthorObject]

The author(s) for the audiobook.

Returns:



14
15
16
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 14

def authors
  @authors
end

#available_marketsArray[String]

A list of the countries in which the audiobook can be played, identified by their [ISO 3166-1 alpha-2](en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code.

Returns:

  • (Array[String])


20
21
22
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 20

def available_markets
  @available_markets
end

#chaptersPagingSimplifiedChapterObject

The chapters of the audiobook.



97
98
99
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 97

def chapters
  @chapters
end

#copyrightsArray[CopyrightObject]

The copyright statements of the audiobook.

Returns:



24
25
26
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 24

def copyrights
  @copyrights
end

#descriptionString

A description of the audiobook. HTML tags are stripped away from this field, use ‘html_description` field in case HTML tags are needed.

Returns:

  • (String)


29
30
31
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 29

def description
  @description
end

#editionString

The edition of the audiobook.

Returns:

  • (String)


37
38
39
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 37

def edition
  @edition
end

#explicitTrueClass | FalseClass

Whether or not the audiobook has explicit content (true = yes it does; false = no it does not OR unknown).

Returns:

  • (TrueClass | FalseClass)


42
43
44
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 42

def explicit
  @explicit
end

#external_urlsExternalUrlObject

External URLs for this audiobook.

Returns:



46
47
48
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 46

def external_urls
  @external_urls
end

#hrefString

A link to the Web API endpoint providing full details of the audiobook.

Returns:

  • (String)


50
51
52
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 50

def href
  @href
end

#html_descriptionString

A description of the audiobook. This field may contain HTML tags.

Returns:

  • (String)


33
34
35
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 33

def html_description
  @html_description
end

#idString

The [Spotify ID](/documentation/web-api/concepts/spotify-uris-ids) for the audiobook.

Returns:

  • (String)


55
56
57
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 55

def id
  @id
end

#imagesArray[ImageObject]

The cover art for the audiobook in various sizes, widest first.

Returns:



59
60
61
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 59

def images
  @images
end

#languagesArray[String]

A list of the languages used in the audiobook, identified by their [ISO 639](en.wikipedia.org/wiki/ISO_639) code.

Returns:

  • (Array[String])


64
65
66
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 64

def languages
  @languages
end

#media_typeString

The media type of the audiobook.

Returns:

  • (String)


68
69
70
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 68

def media_type
  @media_type
end

#nameString

The name of the audiobook.

Returns:

  • (String)


72
73
74
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 72

def name
  @name
end

#narratorsArray[NarratorObject]

The narrator(s) for the audiobook.

Returns:



76
77
78
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 76

def narrators
  @narrators
end

#publisherString

The publisher of the audiobook.

Returns:

  • (String)


80
81
82
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 80

def publisher
  @publisher
end

#total_chaptersInteger

The number of chapters in this audiobook.

Returns:

  • (Integer)


93
94
95
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 93

def total_chapters
  @total_chapters
end

#typeType9Enum

The object type.

Returns:



84
85
86
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 84

def type
  @type
end

#uriString

The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for the audiobook.

Returns:

  • (String)


89
90
91
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 89

def uri
  @uri
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 166

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  authors = nil
  unless hash['authors'].nil?
    authors = []
    hash['authors'].each do |structure|
      authors << (AuthorObject.from_hash(structure) if structure)
    end
  end

  authors = nil unless hash.key?('authors')
  available_markets =
    hash.key?('available_markets') ? hash['available_markets'] : nil
  # Parameter is an array, so we need to iterate through it
  copyrights = nil
  unless hash['copyrights'].nil?
    copyrights = []
    hash['copyrights'].each do |structure|
      copyrights << (CopyrightObject.from_hash(structure) if structure)
    end
  end

  copyrights = nil unless hash.key?('copyrights')
  description = hash.key?('description') ? hash['description'] : nil
  html_description =
    hash.key?('html_description') ? hash['html_description'] : nil
  explicit = hash.key?('explicit') ? hash['explicit'] : nil
  external_urls = ExternalUrlObject.from_hash(hash['external_urls']) if hash['external_urls']
  href = hash.key?('href') ? hash['href'] : nil
  id = hash.key?('id') ? hash['id'] : nil
  # Parameter is an array, so we need to iterate through it
  images = nil
  unless hash['images'].nil?
    images = []
    hash['images'].each do |structure|
      images << (ImageObject.from_hash(structure) if structure)
    end
  end

  images = nil unless hash.key?('images')
  languages = hash.key?('languages') ? hash['languages'] : nil
  media_type = hash.key?('media_type') ? hash['media_type'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  # Parameter is an array, so we need to iterate through it
  narrators = nil
  unless hash['narrators'].nil?
    narrators = []
    hash['narrators'].each do |structure|
      narrators << (NarratorObject.from_hash(structure) if structure)
    end
  end

  narrators = nil unless hash.key?('narrators')
  publisher = hash.key?('publisher') ? hash['publisher'] : nil
  type = hash.key?('type') ? hash['type'] : nil
  uri = hash.key?('uri') ? hash['uri'] : nil
  total_chapters =
    hash.key?('total_chapters') ? hash['total_chapters'] : nil
  chapters = PagingSimplifiedChapterObject.from_hash(hash['chapters']) if hash['chapters']
  edition = hash.key?('edition') ? hash['edition'] : SKIP

  # Create object from extracted values.
  AudiobookObject.new(authors,
                      available_markets,
                      copyrights,
                      description,
                      html_description,
                      explicit,
                      external_urls,
                      href,
                      id,
                      images,
                      languages,
                      media_type,
                      name,
                      narrators,
                      publisher,
                      type,
                      uri,
                      total_chapters,
                      chapters,
                      edition)
end

.namesObject

A mapping from model property names to API property names.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 100

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['authors'] = 'authors'
  @_hash['available_markets'] = 'available_markets'
  @_hash['copyrights'] = 'copyrights'
  @_hash['description'] = 'description'
  @_hash['html_description'] = 'html_description'
  @_hash['edition'] = 'edition'
  @_hash['explicit'] = 'explicit'
  @_hash['external_urls'] = 'external_urls'
  @_hash['href'] = 'href'
  @_hash['id'] = 'id'
  @_hash['images'] = 'images'
  @_hash['languages'] = 'languages'
  @_hash['media_type'] = 'media_type'
  @_hash['name'] = 'name'
  @_hash['narrators'] = 'narrators'
  @_hash['publisher'] = 'publisher'
  @_hash['type'] = 'type'
  @_hash['uri'] = 'uri'
  @_hash['total_chapters'] = 'total_chapters'
  @_hash['chapters'] = 'chapters'
  @_hash
end

.nullablesObject

An array for nullable fields



133
134
135
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 133

def self.nullables
  []
end

.optionalsObject

An array for optional fields



126
127
128
129
130
# File 'lib/spotify_web_api/models/audiobook_object.rb', line 126

def self.optionals
  %w[
    edition
  ]
end