-----------------------------------------------------------------------------
-- |
-- License     :  BSD-3-Clause
-- Maintainer  :  Oleg Grenrus <oleg.grenrus@iki.fi>
--
-- The user followers API as described on
-- <http://developer.github.com/v3/users/followers/>.
module GitHub.Endpoints.Users.Followers (
    usersFollowing,
    usersFollowedBy,
    usersFollowingR,
    usersFollowedByR,
    module GitHub.Data,
    ) where

import GitHub.Data
import GitHub.Internal.Prelude
import GitHub.Request
import Prelude ()

-- | All the users following the given user.
--
-- > usersFollowing "mike-burns"
usersFollowing :: Name User -> IO (Either Error (Vector SimpleUser))
usersFollowing :: Name User -> IO (Either Error (Vector SimpleUser))
usersFollowing user :: Name User
user =
    GenRequest 'MtJSON 'RO (Vector SimpleUser)
-> IO (Either Error (Vector SimpleUser))
forall (mt :: MediaType *) a.
ParseResponse mt a =>
GenRequest mt 'RO a -> IO (Either Error a)
executeRequest' (GenRequest 'MtJSON 'RO (Vector SimpleUser)
 -> IO (Either Error (Vector SimpleUser)))
-> GenRequest 'MtJSON 'RO (Vector SimpleUser)
-> IO (Either Error (Vector SimpleUser))
forall a b. (a -> b) -> a -> b
$ Name User
-> FetchCount -> GenRequest 'MtJSON 'RO (Vector SimpleUser)
forall (k :: RW).
Name User -> FetchCount -> Request k (Vector SimpleUser)
usersFollowingR Name User
user FetchCount
FetchAll

-- | List followers of a user.
-- See <https://developer.github.com/v3/users/followers/#list-followers-of-a-user>
usersFollowingR :: Name User -> FetchCount -> Request k (Vector SimpleUser)
usersFollowingR :: Name User -> FetchCount -> Request k (Vector SimpleUser)
usersFollowingR user :: Name User
user =
    Paths -> QueryString -> FetchCount -> Request k (Vector SimpleUser)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery ["users", Name User -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name User
user, "followers"] []

-- | All the users that the given user follows.
--
-- > usersFollowedBy "mike-burns"
usersFollowedBy :: Name User -> IO (Either Error (Vector SimpleUser))
usersFollowedBy :: Name User -> IO (Either Error (Vector SimpleUser))
usersFollowedBy user :: Name User
user =
    GenRequest 'MtJSON 'RO (Vector SimpleUser)
-> IO (Either Error (Vector SimpleUser))
forall (mt :: MediaType *) a.
ParseResponse mt a =>
GenRequest mt 'RO a -> IO (Either Error a)
executeRequest' (GenRequest 'MtJSON 'RO (Vector SimpleUser)
 -> IO (Either Error (Vector SimpleUser)))
-> GenRequest 'MtJSON 'RO (Vector SimpleUser)
-> IO (Either Error (Vector SimpleUser))
forall a b. (a -> b) -> a -> b
$ Name User
-> FetchCount -> GenRequest 'MtJSON 'RO (Vector SimpleUser)
forall (k :: RW).
Name User -> FetchCount -> Request k (Vector SimpleUser)
usersFollowedByR Name User
user FetchCount
FetchAll

-- | List users followed by another user.
-- See <https://developer.github.com/v3/users/followers/#list-users-followed-by-another-user>
usersFollowedByR :: Name User -> FetchCount -> Request k (Vector SimpleUser)
usersFollowedByR :: Name User -> FetchCount -> Request k (Vector SimpleUser)
usersFollowedByR user :: Name User
user =
    Paths -> QueryString -> FetchCount -> Request k (Vector SimpleUser)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery ["users", Name User -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name User
user, "following"] []