Class: Spotted::Resources::Users::Playlists

Inherits:
Object
  • Object
show all
Defined in:
lib/spotted/resources/users/playlists.rb

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:



76
77
78
# File 'lib/spotted/resources/users/playlists.rb', line 76

def initialize(client:)
  @client = client
end

Instance Method Details

#create(user_id, name: , collaborative: nil, description: nil, public: nil, request_options: {}) ⇒ Spotted::Models::Users::PlaylistCreateResponse

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

Create a playlist for a Spotify user. (The playlist will be empty until you [add tracks](/documentation/web-api/reference/add-tracks-to-playlist).) Each user is generally limited to a maximum of 11000 playlists.

to

Parameters:

  • user_id (String)

    The user’s [Spotify user ID](/documentation/web-api/concepts/spotify-uris-ids).

  • name (String)

    The name for the new playlist, for example ‘“Your Coolest Playlist”`. This name

  • collaborative (Boolean)

    Defaults to ‘false`. If `true` the playlist will be collaborative. _Note:

  • description (String)

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

  • public (Boolean)

    Defaults to ‘true`. The playlist’s public/private status (if it should be added

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

Returns:

See Also:



32
33
34
35
36
37
38
39
40
41
# File 'lib/spotted/resources/users/playlists.rb', line 32

def create(user_id, params)
  parsed, options = Spotted::Users::PlaylistCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["users/%1$s/playlists", user_id],
    body: parsed,
    model: Spotted::Models::Users::PlaylistCreateResponse,
    options: options
  )
end

#list(user_id, limit: nil, offset: nil, request_options: {}) ⇒ Spotted::Internal::CursorURLPage<Spotted::Models::SimplifiedPlaylistObject>

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

Get a list of the playlists owned or followed by a Spotify user.

Parameters:

  • user_id (String)

    The user’s [Spotify user ID](/documentation/web-api/concepts/spotify-uris-ids).

  • limit (Integer)

    The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.

  • offset (Integer)

    The index of the first playlist to return. Default:

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

Returns:

See Also:



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/spotted/resources/users/playlists.rb', line 61

def list(user_id, params = {})
  parsed, options = Spotted::Users::PlaylistListParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["users/%1$s/playlists", user_id],
    query: parsed,
    page: Spotted::Internal::CursorURLPage,
    model: Spotted::SimplifiedPlaylistObject,
    options: options
  )
end