Class: SpotifyWebApi::LinkedTrackObject

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

Overview

LinkedTrackObject Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(external_urls = SKIP, href = SKIP, id = SKIP, type = SKIP, uri = SKIP) ⇒ LinkedTrackObject

Returns a new instance of LinkedTrackObject.



61
62
63
64
65
66
67
68
# File 'lib/spotify_web_api/models/linked_track_object.rb', line 61

def initialize(external_urls = SKIP, href = SKIP, id = SKIP, type = SKIP,
               uri = SKIP)
  @external_urls = external_urls unless external_urls == SKIP
  @href = href unless href == SKIP
  @id = id unless id == SKIP
  @type = type unless type == SKIP
  @uri = uri unless uri == SKIP
end

Instance Attribute Details

#external_urlsExternalUrlObject

Known external URLs for this track.

Returns:



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

def external_urls
  @external_urls
end

#hrefString

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

Returns:

  • (String)


18
19
20
# File 'lib/spotify_web_api/models/linked_track_object.rb', line 18

def href
  @href
end

#idString

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

Returns:

  • (String)


23
24
25
# File 'lib/spotify_web_api/models/linked_track_object.rb', line 23

def id
  @id
end

#typeString

The object type: “track”.

Returns:

  • (String)


27
28
29
# File 'lib/spotify_web_api/models/linked_track_object.rb', line 27

def type
  @type
end

#uriString

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

Returns:

  • (String)


32
33
34
# File 'lib/spotify_web_api/models/linked_track_object.rb', line 32

def uri
  @uri
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/spotify_web_api/models/linked_track_object.rb', line 71

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  external_urls = ExternalUrlObject.from_hash(hash['external_urls']) if hash['external_urls']
  href = hash.key?('href') ? hash['href'] : SKIP
  id = hash.key?('id') ? hash['id'] : SKIP
  type = hash.key?('type') ? hash['type'] : SKIP
  uri = hash.key?('uri') ? hash['uri'] : SKIP

  # Create object from extracted values.
  LinkedTrackObject.new(external_urls,
                        href,
                        id,
                        type,
                        uri)
end

.namesObject

A mapping from model property names to API property names.



35
36
37
38
39
40
41
42
43
# File 'lib/spotify_web_api/models/linked_track_object.rb', line 35

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['external_urls'] = 'external_urls'
  @_hash['href'] = 'href'
  @_hash['id'] = 'id'
  @_hash['type'] = 'type'
  @_hash['uri'] = 'uri'
  @_hash
end

.nullablesObject

An array for nullable fields



57
58
59
# File 'lib/spotify_web_api/models/linked_track_object.rb', line 57

def self.nullables
  []
end

.optionalsObject

An array for optional fields



46
47
48
49
50
51
52
53
54
# File 'lib/spotify_web_api/models/linked_track_object.rb', line 46

def self.optionals
  %w[
    external_urls
    href
    id
    type
    uri
  ]
end