Class: SpotifyWebApi::EpisodeBase

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

Overview

EpisodeBase Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(audio_preview_url = nil, description = nil, html_description = nil, duration_ms = nil, explicit = nil, external_urls = nil, href = nil, id = nil, images = nil, is_externally_hosted = nil, is_playable = nil, languages = nil, name = nil, release_date = nil, release_date_precision = nil, type = nil, uri = nil, language = SKIP, resume_point = SKIP, restrictions = SKIP) ⇒ EpisodeBase

Returns a new instance of EpisodeBase.



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/spotify_web_api/models/episode_base.rb', line 145

def initialize(audio_preview_url = nil, description = nil,
               html_description = nil, duration_ms = nil, explicit = nil,
               external_urls = nil, href = nil, id = nil, images = nil,
               is_externally_hosted = nil, is_playable = nil,
               languages = nil, name = nil, release_date = nil,
               release_date_precision = nil, type = nil, uri = nil,
               language = SKIP, resume_point = SKIP, restrictions = SKIP)
  @audio_preview_url = audio_preview_url
  @description = description
  @html_description = html_description
  @duration_ms = duration_ms
  @explicit = explicit
  @external_urls = external_urls
  @href = href
  @id = id
  @images = images
  @is_externally_hosted = is_externally_hosted
  @is_playable = is_playable
  @language = language unless language == SKIP
  @languages = languages
  @name = name
  @release_date = release_date
  @release_date_precision = release_date_precision
  @resume_point = resume_point unless resume_point == SKIP
  @type = type
  @uri = uri
  @restrictions = restrictions unless restrictions == SKIP
end

Instance Attribute Details

#audio_preview_urlString

A URL to a 30 second preview (MP3 format) of the episode. ‘null` if not available.

Returns:

  • (String)


15
16
17
# File 'lib/spotify_web_api/models/episode_base.rb', line 15

def audio_preview_url
  @audio_preview_url
end

#descriptionString

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

Returns:

  • (String)


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

def description
  @description
end

#duration_msInteger

The episode length in milliseconds.

Returns:

  • (Integer)


28
29
30
# File 'lib/spotify_web_api/models/episode_base.rb', line 28

def duration_ms
  @duration_ms
end

#explicitTrueClass | FalseClass

Whether or not the episode has explicit content (true = yes it does; false

no it does not OR unknown).

Returns:

  • (TrueClass | FalseClass)


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

def explicit
  @explicit
end

#external_urlsExternalUrlObject

External URLs for this episode.

Returns:



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

def external_urls
  @external_urls
end

#hrefString

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

Returns:

  • (String)


41
42
43
# File 'lib/spotify_web_api/models/episode_base.rb', line 41

def href
  @href
end

#html_descriptionString

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

Returns:

  • (String)


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

def html_description
  @html_description
end

#idString

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

Returns:

  • (String)


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

def id
  @id
end

#imagesArray[ImageObject]

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

Returns:



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

def images
  @images
end

#is_externally_hostedTrueClass | FalseClass

True if the episode is hosted outside of Spotify’s CDN.

Returns:

  • (TrueClass | FalseClass)


54
55
56
# File 'lib/spotify_web_api/models/episode_base.rb', line 54

def is_externally_hosted
  @is_externally_hosted
end

#is_playableTrueClass | FalseClass

True if the episode is playable in the given market. Otherwise false.

Returns:

  • (TrueClass | FalseClass)


58
59
60
# File 'lib/spotify_web_api/models/episode_base.rb', line 58

def is_playable
  @is_playable
end

#languageString

The language used in the episode, identified by a [ISO 639](en.wikipedia.org/wiki/ISO_639) code. This field is deprecated and might be removed in the future. Please use the ‘languages` field instead.

Returns:

  • (String)


65
66
67
# File 'lib/spotify_web_api/models/episode_base.rb', line 65

def language
  @language
end

#languagesArray[String]

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

Returns:

  • (Array[String])


70
71
72
# File 'lib/spotify_web_api/models/episode_base.rb', line 70

def languages
  @languages
end

#nameString

The name of the episode.

Returns:

  • (String)


74
75
76
# File 'lib/spotify_web_api/models/episode_base.rb', line 74

def name
  @name
end

#release_dateString

The date the episode was first released, for example ‘“1981-12-15”`. Depending on the precision, it might be shown as `“1981”` or `“1981-12”`.

Returns:

  • (String)


79
80
81
# File 'lib/spotify_web_api/models/episode_base.rb', line 79

def release_date
  @release_date
end

#release_date_precisionReleaseDatePrecisionEnum

The precision with which ‘release_date` value is known.



83
84
85
# File 'lib/spotify_web_api/models/episode_base.rb', line 83

def release_date_precision
  @release_date_precision
end

#restrictionsEpisodeRestrictionObject

Included in the response when a content restriction is applied.



101
102
103
# File 'lib/spotify_web_api/models/episode_base.rb', line 101

def restrictions
  @restrictions
end

#resume_pointResumePointObject

The user’s most recent position in the episode. Set if the supplied access token is a user token and has the scope ‘user-read-playback-position’.

Returns:



88
89
90
# File 'lib/spotify_web_api/models/episode_base.rb', line 88

def resume_point
  @resume_point
end

#typeType8Enum

The object type.

Returns:



92
93
94
# File 'lib/spotify_web_api/models/episode_base.rb', line 92

def type
  @type
end

#uriString

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

Returns:

  • (String)


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

def uri
  @uri
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/spotify_web_api/models/episode_base.rb', line 175

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  audio_preview_url =
    hash.key?('audio_preview_url') ? hash['audio_preview_url'] : nil
  description = hash.key?('description') ? hash['description'] : nil
  html_description =
    hash.key?('html_description') ? hash['html_description'] : nil
  duration_ms = hash.key?('duration_ms') ? hash['duration_ms'] : 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')
  is_externally_hosted =
    hash.key?('is_externally_hosted') ? hash['is_externally_hosted'] : nil
  is_playable = hash.key?('is_playable') ? hash['is_playable'] : nil
  languages = hash.key?('languages') ? hash['languages'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  release_date = hash.key?('release_date') ? hash['release_date'] : nil
  release_date_precision =
    hash.key?('release_date_precision') ? hash['release_date_precision'] : nil
  type = hash.key?('type') ? hash['type'] : nil
  uri = hash.key?('uri') ? hash['uri'] : nil
  language = hash.key?('language') ? hash['language'] : SKIP
  resume_point = ResumePointObject.from_hash(hash['resume_point']) if hash['resume_point']
  restrictions = EpisodeRestrictionObject.from_hash(hash['restrictions']) if
    hash['restrictions']

  # Create object from extracted values.
  EpisodeBase.new(audio_preview_url,
                  description,
                  html_description,
                  duration_ms,
                  explicit,
                  external_urls,
                  href,
                  id,
                  images,
                  is_externally_hosted,
                  is_playable,
                  languages,
                  name,
                  release_date,
                  release_date_precision,
                  type,
                  uri,
                  language,
                  resume_point,
                  restrictions)
end

.namesObject

A mapping from model property names to API property names.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/spotify_web_api/models/episode_base.rb', line 104

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['audio_preview_url'] = 'audio_preview_url'
  @_hash['description'] = 'description'
  @_hash['html_description'] = 'html_description'
  @_hash['duration_ms'] = 'duration_ms'
  @_hash['explicit'] = 'explicit'
  @_hash['external_urls'] = 'external_urls'
  @_hash['href'] = 'href'
  @_hash['id'] = 'id'
  @_hash['images'] = 'images'
  @_hash['is_externally_hosted'] = 'is_externally_hosted'
  @_hash['is_playable'] = 'is_playable'
  @_hash['language'] = 'language'
  @_hash['languages'] = 'languages'
  @_hash['name'] = 'name'
  @_hash['release_date'] = 'release_date'
  @_hash['release_date_precision'] = 'release_date_precision'
  @_hash['resume_point'] = 'resume_point'
  @_hash['type'] = 'type'
  @_hash['uri'] = 'uri'
  @_hash['restrictions'] = 'restrictions'
  @_hash
end

.nullablesObject

An array for nullable fields



139
140
141
142
143
# File 'lib/spotify_web_api/models/episode_base.rb', line 139

def self.nullables
  %w[
    audio_preview_url
  ]
end

.optionalsObject

An array for optional fields



130
131
132
133
134
135
136
# File 'lib/spotify_web_api/models/episode_base.rb', line 130

def self.optionals
  %w[
    language
    resume_point
    restrictions
  ]
end