SKUser
public struct SKUser : User, JSONDecodable
A Spotify user.
See also
The Web API Public User object.-
Declaration
Swift
public let displayName: String?
-
Declaration
Swift
public let externalURLs: [String : URL]
-
Declaration
Swift
public let followers: SKFollowers?
-
Declaration
Swift
public let id: String
-
Declaration
Swift
public let images: [SKImage]?
-
Declaration
Swift
public let uri: String
-
Declaration
Swift
public let url: URL
-
Creates and returns the request used to get a user.
Declaration
Swift
public static func makeUserRequest(id: String) -> SKRequest
Parameters
id
The user’s Spotify user ID.
Return Value
An
SKRequest
instance with which to perform the API request. -
Gets public profile information about a Spotify user.
Note
This method uses the
SPTAuth
default instance session to authenticate the underlying request. If this session does not contain a valid access token, the request will result in an error.Declaration
Swift
public static func getUser(withID id: String, completion handler: @escaping (SKUser?, Error?) -> Void)
Parameters
id
The user’s Spotify user ID.
handler
The callback handler for the request. The parameters for this handler are:
user
: The requested user, if available.error
: An error identifying if and why the request failed, ornil
if the request was successful.
-
Creates and returns the request used to get the user’s playlists.
Declaration
Swift
public func makePlaylistsRequest(page: Pagination?) -> SKRequest
Parameters
page
The parameters for paginating the results, specifying the index and number of items to return. If no parameters are supplied, the request will return the default number of items beginning with first item.
Return Value
An
SKRequest
instance with which to perform the API request. -
Gets a list of the playlists owned or followed by the user.
Note
This method uses theSPTAuth
default instance session to authenticate the underlying request. If this session does not contain a valid access token, the request will result in an error. The access token must have been issued on behalf of the current user.Private playlists are only retrievable for the current user and requires the
playlist-read-private
scope to have been authorized by the user. Note that this scope alone will not return collaborative playlists, even though they are always private.See Using Scopes for more details.
Declaration
Swift
public func getPlaylists(page: Pagination? = nil, completion handler: @escaping (Page<SKPlaylist>?, Error?) -> Void)
Parameters
page
The parameters for paginating the results, specifying the index and number of items to return. If no parameters are supplied, the request will return the default number of items beginning with first item. The default value is
nil
.handler
The callback handler for the request. The parameters for this handler are:
user
: The current authenticated user, if available.error
: An error identifying if and why the request failed, ornil
if the request was successful.