Class: Spotted::Resources::Playlists

Inherits:
Object
  • Object
show all
Defined in:
lib/spotted/resources/playlists.rb,
lib/spotted/resources/playlists/images.rb,
lib/spotted/resources/playlists/tracks.rb,
lib/spotted/resources/playlists/followers.rb

Defined Under Namespace

Classes: Followers, Images, Tracks

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Playlists

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Playlists.

Parameters:



83
84
85
86
87
88
# File 'lib/spotted/resources/playlists.rb', line 83

def initialize(client:)
  @client = client
  @tracks = Spotted::Resources::Playlists::Tracks.new(client: client)
  @followers = Spotted::Resources::Playlists::Followers.new(client: client)
  @images = Spotted::Resources::Playlists::Images.new(client: client)
end

Instance Attribute Details

#followersSpotted::Resources::Playlists::Followers (readonly)



10
11
12
# File 'lib/spotted/resources/playlists.rb', line 10

def followers
  @followers
end

#imagesSpotted::Resources::Playlists::Images (readonly)



13
14
15
# File 'lib/spotted/resources/playlists.rb', line 13

def images
  @images
end

#tracksSpotted::Resources::Playlists::Tracks (readonly)



7
8
9
# File 'lib/spotted/resources/playlists.rb', line 7

def tracks
  @tracks
end

Instance Method Details

#retrieve(playlist_id, additional_types: nil, fields: nil, market: nil, request_options: {}) ⇒ Spotted::Models::PlaylistRetrieveResponse

Some parameter documentations has been truncated, see Models::PlaylistRetrieveParams for more details.

Get a playlist owned by a Spotify user.

Parameters:

  • playlist_id (String)

    The [Spotify ID](/documentation/web-api/concepts/spotify-uris-ids) of the playli

  • additional_types (String)

    A comma-separated list of item types that your client supports besides the defau

  • fields (String)

    Filters for the query: a comma-separated list of the

  • market (String)

    An [ISO 3166-1 alpha-2 country code](en.wikipedia.org/wiki/ISO_3166-1_al

  • request_options (Spotted::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



35
36
37
38
39
40
41
42
43
44
# File 'lib/spotted/resources/playlists.rb', line 35

def retrieve(playlist_id, params = {})
  parsed, options = Spotted::PlaylistRetrieveParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["playlists/%1$s", playlist_id],
    query: parsed,
    model: Spotted::Models::PlaylistRetrieveResponse,
    options: options
  )
end

#update(playlist_id, collaborative: nil, description: nil, name: nil, public: nil, request_options: {}) ⇒ nil

Some parameter documentations has been truncated, see Models::PlaylistUpdateParams for more details.

Change a playlist’s name and public/private state. (The user must, of course, own the playlist.)

Parameters:

  • playlist_id (String)

    The [Spotify ID](/documentation/web-api/concepts/spotify-uris-ids) of the playli

  • collaborative (Boolean)

    If ‘true`, the playlist will become collaborative and other users will be able t

  • description (String)

    Value for playlist description as displayed in Spotify Clients and in the Web AP

  • name (String)

    The new name for the playlist, for example ‘“My New Playlist Title”`

  • public (Boolean)

    The playlist’s public/private status (if it should be added to the user’s profil

  • request_options (Spotted::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



69
70
71
72
73
74
75
76
77
78
# File 'lib/spotted/resources/playlists.rb', line 69

def update(playlist_id, params = {})
  parsed, options = Spotted::PlaylistUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["playlists/%1$s", playlist_id],
    body: parsed,
    model: NilClass,
    options: options
  )
end