Followable

public protocol Followable

A type representing a Spotify item that can be followed or unfollowed by the current authenticated user.

Types that conform to this protocol provide a set of request factories and convenience methods to either follow, unfollow, or check to see if the current authenticated user is already following the item. These types must also contain a valid Spotify ID.

Note

Although a Spotify playlist is technically a followable catalog item, the method declarations and implementations for following playlists differ from those defined here. Thus, the SKPlaylist type does not conform to this protocol, but instead provides its own comparable methods and request factories.
  • id

    The Spotify ID for the item. Required.

    Declaration

    Swift

    var id: String { get }
  • makeFollowRequest() Default implementation

    Creates and returns the request used to add the current authenticated user as a follower of the item.

    Default Implementation

    Declaration

    Swift

    func makeFollowRequest() -> SKRequest

    Return Value

    An SKRequest instance with which to perform the API request.

  • makeUnfollowRequest() Default implementation

    Creates and returns the request used to remove the current authenticated user as a follower of the item.

    Default Implementation

    Declaration

    Swift

    func makeUnfollowRequest() -> SKRequest

    Return Value

    An SKRequest instance with which to perform the API request.

  • makeFollowStatusRequest() Default implementation

    Creates and returns the request used to check whether the current authenticated user is following the item.

    Default Implementation

    Declaration

    Swift

    func makeFollowStatusRequest() -> SKRequest

    Return Value

    An SKRequest instance with which to perform the API request.

  • follow(completion:) Default implementation

    Adds the current authenticated user as a follower of the item.

    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. The access token must have been issued on behalf of the current user.

    Modifying the list of items that the current authenticated user follows also requires authorization of the user-follow-modify scope. See Using Scopes for more details.

    Default Implementation

    Declaration

    Swift

    func follow(completion handler: @escaping SKErrorHandler)

    Parameters

    handler

    The callback handler for the request, providing an error identifying if and why the request failed, or nil if the request was successful.

  • unfollow(completion:) Default implementation

    Removes the current authenticated user as a follower of the item.

    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. The access token must have been issued on behalf of the current user.

    Modifying the list of items that the current authenticated user follows also requires authorization of the user-follow-modify scope. See Using Scopes for more details.

    Default Implementation

    Declaration

    Swift

    func unfollow(completion handler: @escaping SKErrorHandler)

    Parameters

    handler

    The callback handler for the request, providing an error identifying if and why the request failed, or nil if the request was successful.

  • checkIfFollowing(completion:) Default implementation

    Checks whether the current authenticated user is following the item.

    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. The access token must have been issued on behalf of the current user.

    Reading the list of items that the current authenticated user follows also requires authorization of the user-follow-read scope. See Using Scopes for more details.

    Default Implementation

    Declaration

    Swift

    func checkIfFollowing(completion handler: @escaping (Bool?, Error?) -> Void)

    Parameters

    handler

    The callback handler for the request. The parameters for this handler are:

    • isFollowing: A Boolean value indicating whether the current authenticated user is following the item: true if following, false otherwise.
    • error: An error identifying if and why the request failed, or nil if the request was successful.