Module: OfficialFM::Playlists

Included in:
Client
Defined in:
lib/officialfm/playlists.rb

Defined Under Namespace

Modules: PlaylistMethods

Instance Method Summary collapse

Instance Method Details

#playlist(id, options = {}) ⇒ Object

Retrieve information about a specific playlist



21
22
23
24
25
26
# File 'lib/officialfm/playlists.rb', line 21

def playlist(id, options={})
  url = resource_url(id, parent: 'playlists')

  response = get(url, options).body.playlist
  extend_response(response, PlaylistMethods)
end

#playlist_tracks(id, options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/officialfm/playlists.rb', line 28

def playlist_tracks(id, options={})
  url = resource_url(id, { parent: 'playlists', child: 'tracks' })

  response = get url, options

  tracks = response.body.tracks.map do |t|
    # remove the unnecessary root
    t.track
  end

  tracks
end

#playlists(search_param, options = {}) ⇒ Object

Search for a playlist



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/officialfm/playlists.rb', line 5

def playlists(search_param, options={})
  response = get '/playlists/search', options.merge(:q => search_param)

  response.body.playlists.map! do |p|
    # remove the unnecessary root
    actual_playlist = p.playlist

    extend_response(actual_playlist, PlaylistMethods)

    actual_playlist
  end

  response.body
end