Class: SpotifyWebApi::SearchItems

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

Overview

SearchItems Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(tracks = SKIP, artists = SKIP, albums = SKIP, playlists = SKIP, shows = SKIP, episodes = SKIP, audiobooks = SKIP) ⇒ SearchItems

Returns a new instance of SearchItems.



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/spotify_web_api/models/search_items.rb', line 71

def initialize(tracks = SKIP, artists = SKIP, albums = SKIP,
               playlists = SKIP, shows = SKIP, episodes = SKIP,
               audiobooks = SKIP)
  @tracks = tracks unless tracks == SKIP
  @artists = artists unless artists == SKIP
  @albums = albums unless albums == SKIP
  @playlists = playlists unless playlists == SKIP
  @shows = shows unless shows == SKIP
  @episodes = episodes unless episodes == SKIP
  @audiobooks = audiobooks unless audiobooks == SKIP
end

Instance Attribute Details

#albumsPagingSimplifiedAlbumObject

TODO: Write general description for this method



22
23
24
# File 'lib/spotify_web_api/models/search_items.rb', line 22

def albums
  @albums
end

#artistsPagingArtistObject

TODO: Write general description for this method

Returns:



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

def artists
  @artists
end

#audiobooksPagingSimplifiedAudiobookObject

TODO: Write general description for this method



38
39
40
# File 'lib/spotify_web_api/models/search_items.rb', line 38

def audiobooks
  @audiobooks
end

#episodesPagingSimplifiedEpisodeObject

TODO: Write general description for this method



34
35
36
# File 'lib/spotify_web_api/models/search_items.rb', line 34

def episodes
  @episodes
end

#playlistsPagingPlaylistObject

TODO: Write general description for this method



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

def playlists
  @playlists
end

#showsPagingSimplifiedShowObject

TODO: Write general description for this method



30
31
32
# File 'lib/spotify_web_api/models/search_items.rb', line 30

def shows
  @shows
end

#tracksPagingTrackObject

TODO: Write general description for this method

Returns:



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

def tracks
  @tracks
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/spotify_web_api/models/search_items.rb', line 84

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  tracks = PagingTrackObject.from_hash(hash['tracks']) if hash['tracks']
  artists = PagingArtistObject.from_hash(hash['artists']) if hash['artists']
  albums = PagingSimplifiedAlbumObject.from_hash(hash['albums']) if hash['albums']
  playlists = PagingPlaylistObject.from_hash(hash['playlists']) if hash['playlists']
  shows = PagingSimplifiedShowObject.from_hash(hash['shows']) if hash['shows']
  episodes = PagingSimplifiedEpisodeObject.from_hash(hash['episodes']) if hash['episodes']
  audiobooks = PagingSimplifiedAudiobookObject.from_hash(hash['audiobooks']) if
    hash['audiobooks']

  # Create object from extracted values.
  SearchItems.new(tracks,
                  artists,
                  albums,
                  playlists,
                  shows,
                  episodes,
                  audiobooks)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/spotify_web_api/models/search_items.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['tracks'] = 'tracks'
  @_hash['artists'] = 'artists'
  @_hash['albums'] = 'albums'
  @_hash['playlists'] = 'playlists'
  @_hash['shows'] = 'shows'
  @_hash['episodes'] = 'episodes'
  @_hash['audiobooks'] = 'audiobooks'
  @_hash
end

.nullablesObject

An array for nullable fields



67
68
69
# File 'lib/spotify_web_api/models/search_items.rb', line 67

def self.nullables
  []
end

.optionalsObject

An array for optional fields



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/spotify_web_api/models/search_items.rb', line 54

def self.optionals
  %w[
    tracks
    artists
    albums
    playlists
    shows
    episodes
    audiobooks
  ]
end