Savable
public protocol Savable
A type representing a Spotify item that can be saved to the current authenticated user’s Spotify music library.
Types that conform to this protocol provide a set of request factories and convenience methods to either save, remove, or check to see if the user has already saved the item. These types must also contain a valid Spotify ID.
-
The Spotify ID for the item. Required.
Declaration
Swift
var id: String { get } -
makeSaveToLibraryRequest()Default implementation -
makeRemoveFromLibraryRequest()Default implementation -
makeSaveStatusRequest()Default implementation -
saveToLibrary(completion:)Default implementationSaves the item to the current authenticated user’s Spotify music library.
Note
This method uses theSPTAuthdefault 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.Modifying the current user’s
Your Music
collection requires authorization of theuser-library-modifyscope. See Using Scopes for more details.Default Implementation
Declaration
Swift
func saveToLibrary(completion handler: @escaping SKErrorHandler)Parameters
handlerThe callback handler for the request, providing an error identifying if and why the request failed, or
nilif the request was successful. -
removeFromLibrary(completion:)Default implementationRemoves the item from the current authenticated user’s Spotify music library.
Note
This method uses theSPTAuthdefault 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.Modifying the current user’s
Your Music
collection requires authorization of theuser-library-modifyscope. See Using Scopes for more details.Default Implementation
Declaration
Swift
func removeFromLibrary(completion handler: @escaping SKErrorHandler)Parameters
handlerThe callback handler for the request, providing an error identifying if and why the request failed, or
nilif the request was successful. -
checkIfSaved(completion:)Default implementationChecks whether the item has been saved to the current authenticated user’s Spotify music library.
Note
This method uses theSPTAuthdefault 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.Reading the current user’s
Your Music
collection requires authorization of theuser-library-readscope. See Using Scopes for more details.Default Implementation
Declaration
Swift
func checkIfSaved(completion handler: @escaping (Bool?, Error?) -> Void)Parameters
handlerThe callback handler for the request. The parameters for this handler are:
isSaved: A Boolean value indicating whether the item has been saved to the current user’s library:trueif saved,falseotherwise.error: An error identifying if and why the request failed, ornilif the request was successful.
View on GitHub
Savable Protocol Reference