Class: SpotifyWebApi::ExternalIdObject

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

Overview

ExternalIdObject Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(isrc = SKIP, ean = SKIP, upc = SKIP) ⇒ ExternalIdObject

Returns a new instance of ExternalIdObject.



51
52
53
54
55
# File 'lib/spotify_web_api/models/external_id_object.rb', line 51

def initialize(isrc = SKIP, ean = SKIP, upc = SKIP)
  @isrc = isrc unless isrc == SKIP
  @ean = ean unless ean == SKIP
  @upc = upc unless upc == SKIP
end

Instance Attribute Details

#eanString

Returns:

  • (String)


21
22
23
# File 'lib/spotify_web_api/models/external_id_object.rb', line 21

def ean
  @ean
end

#isrcString

[International Standard Recording Code](en.wikipedia.org/wiki/International_Standard_Recording_Code)

Returns:

  • (String)


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

def isrc
  @isrc
end

#upcString

Returns:

  • (String)


26
27
28
# File 'lib/spotify_web_api/models/external_id_object.rb', line 26

def upc
  @upc
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/spotify_web_api/models/external_id_object.rb', line 58

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  isrc = hash.key?('isrc') ? hash['isrc'] : SKIP
  ean = hash.key?('ean') ? hash['ean'] : SKIP
  upc = hash.key?('upc') ? hash['upc'] : SKIP

  # Create object from extracted values.
  ExternalIdObject.new(isrc,
                       ean,
                       upc)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
# File 'lib/spotify_web_api/models/external_id_object.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['isrc'] = 'isrc'
  @_hash['ean'] = 'ean'
  @_hash['upc'] = 'upc'
  @_hash
end

.nullablesObject

An array for nullable fields



47
48
49
# File 'lib/spotify_web_api/models/external_id_object.rb', line 47

def self.nullables
  []
end

.optionalsObject

An array for optional fields



38
39
40
41
42
43
44
# File 'lib/spotify_web_api/models/external_id_object.rb', line 38

def self.optionals
  %w[
    isrc
    ean
    upc
  ]
end