    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE FlexibleContexts #-}
    {-# LANGUAGE OverloadedStrings #-}

    module Facebook.Object.User
      ( User(..)
      , Gender(..)
      , getUser
      , searchUsers
      , getUserCheckins
      , Friend(..)
      , getUserFriends
      ) where

    import Control.Monad (mzero)
    import Data.Aeson ((.:), (.:?))
    import Data.Text (Text)
    import Data.Typeable (Typeable)

    import qualified Control.Monad.Trans.Resource as R
    import qualified Data.Aeson as A

    import Facebook.Types
    import Facebook.Monad
    import Facebook.Graph
    import Facebook.Pager
    import Facebook.Object.Checkin

    -- | A Facebook user profile (see
    -- <https://developers.facebook.com/docs/reference/api/user/>).
    --
    -- /NOTE:/ We still don't support all fields supported by
    -- Facebook. Please fill an issue if you need access to any other
    -- fields.
    data User = User
      { User -> UserId
    userId :: UserId
      , User -> Maybe Text
    userName :: Maybe Text
      , User -> Maybe Text
    userFirstName :: Maybe Text
      , User -> Maybe Text
    userMiddleName :: Maybe Text
      , User -> Maybe Text
    userLastName :: Maybe Text
      , User -> Maybe Gender
    userGender :: Maybe Gender
      , User -> Maybe Text
    userLocale :: Maybe Text
      , User -> Maybe Text
    userUsername :: Maybe Text
      , User -> Maybe Bool
    userVerified :: Maybe Bool
      , User -> Maybe Text
    userEmail :: Maybe Text
      , User -> Maybe Place
    userLocation :: Maybe Place
      } deriving (User -> User -> Bool
    (User -> User -> Bool) -> (User -> User -> Bool) -> Eq User
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: User -> User -> Bool
    == :: User -> User -> Bool
    $c/= :: User -> User -> Bool
    /= :: User -> User -> Bool
    Eq, Eq User
    Eq User =>
    (User -> User -> Ordering)
    -> (User -> User -> Bool)
    -> (User -> User -> Bool)
    -> (User -> User -> Bool)
    -> (User -> User -> Bool)
    -> (User -> User -> User)
    -> (User -> User -> User)
    -> Ord User
    User -> User -> Bool
    User -> User -> Ordering
    User -> User -> User
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: User -> User -> Ordering
    compare :: User -> User -> Ordering
    $c< :: User -> User -> Bool
    < :: User -> User -> Bool
    $c<= :: User -> User -> Bool
    <= :: User -> User -> Bool
    $c> :: User -> User -> Bool
    > :: User -> User -> Bool
    $c>= :: User -> User -> Bool
    >= :: User -> User -> Bool
    $cmax :: User -> User -> User
    max :: User -> User -> User
    $cmin :: User -> User -> User
    min :: User -> User -> User
    Ord, Int -> User -> ShowS
    [User] -> ShowS
    User -> String
    (Int -> User -> ShowS)
    -> (User -> String) -> ([User] -> ShowS) -> Show User
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> User -> ShowS
    showsPrec :: Int -> User -> ShowS
    $cshow :: User -> String
    show :: User -> String
    $cshowList :: [User] -> ShowS
    showList :: [User] -> ShowS
    Show, ReadPrec [User]
    ReadPrec User
    Int -> ReadS User
    ReadS [User]
    (Int -> ReadS User)
    -> ReadS [User] -> ReadPrec User -> ReadPrec [User] -> Read User
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS User
    readsPrec :: Int -> ReadS User
    $creadList :: ReadS [User]
    readList :: ReadS [User]
    $creadPrec :: ReadPrec User
    readPrec :: ReadPrec User
    $creadListPrec :: ReadPrec [User]
    readListPrec :: ReadPrec [User]
    Read, Typeable)

    instance A.FromJSON User where
      parseJSON :: Value -> Parser User
    parseJSON (A.Object Object
    v) =
        UserId
    -> Maybe Text
    -> Maybe Text
    -> Maybe Text
    -> Maybe Text
    -> Maybe Gender
    -> Maybe Text
    -> Maybe Text
    -> Maybe Bool
    -> Maybe Text
    -> Maybe Place
    -> User
    User (UserId
     -> Maybe Text
     -> Maybe Text
     -> Maybe Text
     -> Maybe Text
     -> Maybe Gender
     -> Maybe Text
     -> Maybe Text
     -> Maybe Bool
     -> Maybe Text
     -> Maybe Place
     -> User)
    -> Parser UserId
    -> Parser
         (Maybe Text
          -> Maybe Text
          -> Maybe Text
          -> Maybe Text
          -> Maybe Gender
          -> Maybe Text
          -> Maybe Text
          -> Maybe Bool
          -> Maybe Text
          -> Maybe Place
          -> User)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Object
    v Object -> Key -> Parser UserId
    forall a. FromJSON a => Object -> Key -> Parser a
    .: Key
    "id" Parser
      (Maybe Text
       -> Maybe Text
       -> Maybe Text
       -> Maybe Text
       -> Maybe Gender
       -> Maybe Text
       -> Maybe Text
       -> Maybe Bool
       -> Maybe Text
       -> Maybe Place
       -> User)
    -> Parser (Maybe Text)
    -> Parser
         (Maybe Text
          -> Maybe Text
          -> Maybe Text
          -> Maybe Gender
          -> Maybe Text
          -> Maybe Text
          -> Maybe Bool
          -> Maybe Text
          -> Maybe Place
          -> User)
    forall a b. Parser (a -> b) -> Parser a -> Parser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Object
    v Object -> Key -> Parser (Maybe Text)
    forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
    .:? Key
    "name" Parser
      (Maybe Text
       -> Maybe Text
       -> Maybe Text
       -> Maybe Gender
       -> Maybe Text
       -> Maybe Text
       -> Maybe Bool
       -> Maybe Text
       -> Maybe Place
       -> User)
    -> Parser (Maybe Text)
    -> Parser
         (Maybe Text
          -> Maybe Text
          -> Maybe Gender
          -> Maybe Text
          -> Maybe Text
          -> Maybe Bool
          -> Maybe Text
          -> Maybe Place
          -> User)
    forall a b. Parser (a -> b) -> Parser a -> Parser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Object
    v Object -> Key -> Parser (Maybe Text)
    forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
    .:? Key
    "first_name" Parser
      (Maybe Text
       -> Maybe Text
       -> Maybe Gender
       -> Maybe Text
       -> Maybe Text
       -> Maybe Bool
       -> Maybe Text
       -> Maybe Place
       -> User)
    -> Parser (Maybe Text)
    -> Parser
         (Maybe Text
          -> Maybe Gender
          -> Maybe Text
          -> Maybe Text
          -> Maybe Bool
          -> Maybe Text
          -> Maybe Place
          -> User)
    forall a b. Parser (a -> b) -> Parser a -> Parser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*>
        Object
    v Object -> Key -> Parser (Maybe Text)
    forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
    .:? Key
    "middle_name" Parser
      (Maybe Text
       -> Maybe Gender
       -> Maybe Text
       -> Maybe Text
       -> Maybe Bool
       -> Maybe Text
       -> Maybe Place
       -> User)
    -> Parser (Maybe Text)
    -> Parser
         (Maybe Gender
          -> Maybe Text
          -> Maybe Text
          -> Maybe Bool
          -> Maybe Text
          -> Maybe Place
          -> User)
    forall a b. Parser (a -> b) -> Parser a -> Parser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*>
        Object
    v Object -> Key -> Parser (Maybe Text)
    forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
    .:? Key
    "last_name" Parser
      (Maybe Gender
       -> Maybe Text
       -> Maybe Text
       -> Maybe Bool
       -> Maybe Text
       -> Maybe Place
       -> User)
    -> Parser (Maybe Gender)
    -> Parser
         (Maybe Text
          -> Maybe Text -> Maybe Bool -> Maybe Text -> Maybe Place -> User)
    forall a b. Parser (a -> b) -> Parser a -> Parser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*>
        Object
    v Object -> Key -> Parser (Maybe Gender)
    forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
    .:? Key
    "gender" Parser
      (Maybe Text
       -> Maybe Text -> Maybe Bool -> Maybe Text -> Maybe Place -> User)
    -> Parser (Maybe Text)
    -> Parser
         (Maybe Text -> Maybe Bool -> Maybe Text -> Maybe Place -> User)
    forall a b. Parser (a -> b) -> Parser a -> Parser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*>
        Object
    v Object -> Key -> Parser (Maybe Text)
    forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
    .:? Key
    "locale" Parser
      (Maybe Text -> Maybe Bool -> Maybe Text -> Maybe Place -> User)
    -> Parser (Maybe Text)
    -> Parser (Maybe Bool -> Maybe Text -> Maybe Place -> User)
    forall a b. Parser (a -> b) -> Parser a -> Parser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*>
        Object
    v Object -> Key -> Parser (Maybe Text)
    forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
    .:? Key
    "username" Parser (Maybe Bool -> Maybe Text -> Maybe Place -> User)
    -> Parser (Maybe Bool)
    -> Parser (Maybe Text -> Maybe Place -> User)
    forall a b. Parser (a -> b) -> Parser a -> Parser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*>
        Object
    v Object -> Key -> Parser (Maybe Bool)
    forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
    .:? Key
    "verified" Parser (Maybe Text -> Maybe Place -> User)
    -> Parser (Maybe Text) -> Parser (Maybe Place -> User)
    forall a b. Parser (a -> b) -> Parser a -> Parser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*>
        Object
    v Object -> Key -> Parser (Maybe Text)
    forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
    .:? Key
    "email" Parser (Maybe Place -> User) -> Parser (Maybe Place) -> Parser User
    forall a b. Parser (a -> b) -> Parser a -> Parser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*>
        Object
    v Object -> Key -> Parser (Maybe Place)
    forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
    .:? Key
    "location"
      parseJSON Value
    _ = Parser User
    forall a. Parser a
    forall (m :: * -> *) a. MonadPlus m => m a
    mzero

    -- | An user's gender.
    data Gender
      = Male
      | Female
      deriving (Gender -> Gender -> Bool
    (Gender -> Gender -> Bool)
    -> (Gender -> Gender -> Bool) -> Eq Gender
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Gender -> Gender -> Bool
    == :: Gender -> Gender -> Bool
    $c/= :: Gender -> Gender -> Bool
    /= :: Gender -> Gender -> Bool
    Eq, Eq Gender
    Eq Gender =>
    (Gender -> Gender -> Ordering)
    -> (Gender -> Gender -> Bool)
    -> (Gender -> Gender -> Bool)
    -> (Gender -> Gender -> Bool)
    -> (Gender -> Gender -> Bool)
    -> (Gender -> Gender -> Gender)
    -> (Gender -> Gender -> Gender)
    -> Ord Gender
    Gender -> Gender -> Bool
    Gender -> Gender -> Ordering
    Gender -> Gender -> Gender
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Gender -> Gender -> Ordering
    compare :: Gender -> Gender -> Ordering
    $c< :: Gender -> Gender -> Bool
    < :: Gender -> Gender -> Bool
    $c<= :: Gender -> Gender -> Bool
    <= :: Gender -> Gender -> Bool
    $c> :: Gender -> Gender -> Bool
    > :: Gender -> Gender -> Bool
    $c>= :: Gender -> Gender -> Bool
    >= :: Gender -> Gender -> Bool
    $cmax :: Gender -> Gender -> Gender
    max :: Gender -> Gender -> Gender
    $cmin :: Gender -> Gender -> Gender
    min :: Gender -> Gender -> Gender
    Ord, Int -> Gender -> ShowS
    [Gender] -> ShowS
    Gender -> String
    (Int -> Gender -> ShowS)
    -> (Gender -> String) -> ([Gender] -> ShowS) -> Show Gender
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Gender -> ShowS
    showsPrec :: Int -> Gender -> ShowS
    $cshow :: Gender -> String
    show :: Gender -> String
    $cshowList :: [Gender] -> ShowS
    showList :: [Gender] -> ShowS
    Show, ReadPrec [Gender]
    ReadPrec Gender
    Int -> ReadS Gender
    ReadS [Gender]
    (Int -> ReadS Gender)
    -> ReadS [Gender]
    -> ReadPrec Gender
    -> ReadPrec [Gender]
    -> Read Gender
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Gender
    readsPrec :: Int -> ReadS Gender
    $creadList :: ReadS [Gender]
    readList :: ReadS [Gender]
    $creadPrec :: ReadPrec Gender
    readPrec :: ReadPrec Gender
    $creadListPrec :: ReadPrec [Gender]
    readListPrec :: ReadPrec [Gender]
    Read, Int -> Gender
    Gender -> Int
    Gender -> [Gender]
    Gender -> Gender
    Gender -> Gender -> [Gender]
    Gender -> Gender -> Gender -> [Gender]
    (Gender -> Gender)
    -> (Gender -> Gender)
    -> (Int -> Gender)
    -> (Gender -> Int)
    -> (Gender -> [Gender])
    -> (Gender -> Gender -> [Gender])
    -> (Gender -> Gender -> [Gender])
    -> (Gender -> Gender -> Gender -> [Gender])
    -> Enum Gender
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: Gender -> Gender
    succ :: Gender -> Gender
    $cpred :: Gender -> Gender
    pred :: Gender -> Gender
    $ctoEnum :: Int -> Gender
    toEnum :: Int -> Gender
    $cfromEnum :: Gender -> Int
    fromEnum :: Gender -> Int
    $cenumFrom :: Gender -> [Gender]
    enumFrom :: Gender -> [Gender]
    $cenumFromThen :: Gender -> Gender -> [Gender]
    enumFromThen :: Gender -> Gender -> [Gender]
    $cenumFromTo :: Gender -> Gender -> [Gender]
    enumFromTo :: Gender -> Gender -> [Gender]
    $cenumFromThenTo :: Gender -> Gender -> Gender -> [Gender]
    enumFromThenTo :: Gender -> Gender -> Gender -> [Gender]
    Enum, Typeable)

    instance A.FromJSON Gender where
      parseJSON :: Value -> Parser Gender
    parseJSON (A.String Text
    "male") = Gender -> Parser Gender
    forall a. a -> Parser a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Gender
    Male
      parseJSON (A.String Text
    "female") = Gender -> Parser Gender
    forall a. a -> Parser a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Gender
    Female
      parseJSON Value
    _ = Parser Gender
    forall a. Parser a
    forall (m :: * -> *) a. MonadPlus m => m a
    mzero

    instance A.ToJSON Gender where
      toJSON :: Gender -> Value
    toJSON = Text -> Value
    forall a. ToJSON a => a -> Value
    A.toJSON (Text -> Value) -> (Gender -> Text) -> Gender -> Value
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Gender -> Text
    toText
        where
          toText :: Gender -> Text
          toText :: Gender -> Text
    toText Gender
    Male = Text
    "male"
          toText Gender
    Female = Text
    "female"

    -- | Get an user using his user ID.  The user access token is
    -- optional, but when provided more information can be returned
    -- back by Facebook.  The user ID may be @\"me\"@, in which
    -- case you must provide an user access token and information
    -- about the token's owner is given.
    getUser
      :: (R.MonadResource m, R.MonadUnliftIO m, R.MonadThrow m)
      => UserId -- ^ User ID or @\"me\"@.
      -> [Argument] -- ^ Arguments to be passed to Facebook.
      -> Maybe UserAccessToken -- ^ Optional user access token.
      -> FacebookT anyAuth m User
    getUser :: forall (m :: * -> *) anyAuth.
    (MonadResource m, MonadUnliftIO m, MonadThrow m) =>
    UserId
    -> [Argument] -> Maybe UserAccessToken -> FacebookT anyAuth m User
    getUser UserId
    id_ [Argument]
    query Maybe UserAccessToken
    mtoken = Text
    -> [Argument] -> Maybe UserAccessToken -> FacebookT anyAuth m User
    forall (m :: * -> *) a anyKind anyAuth.
    (MonadResource m, MonadUnliftIO m, MonadThrow m, FromJSON a) =>
    Text
    -> [Argument]
    -> Maybe (AccessToken anyKind)
    -> FacebookT anyAuth m a
    getObject (Text
    "/" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> UserId -> Text
    idCode UserId
    id_) [Argument]
    query Maybe UserAccessToken
    mtoken

    -- | Search users by keyword.
    searchUsers
      :: (R.MonadResource m, R.MonadUnliftIO m, R.MonadThrow m)
      => Text
      -> [Argument]
      -> Maybe UserAccessToken
      -> FacebookT anyAuth m (Pager User)
    searchUsers :: forall (m :: * -> *) anyAuth.
    (MonadResource m, MonadUnliftIO m, MonadThrow m) =>
    Text
    -> [Argument]
    -> Maybe UserAccessToken
    -> FacebookT anyAuth m (Pager User)
    searchUsers = Text
    -> Text
    -> [Argument]
    -> Maybe UserAccessToken
    -> FacebookT anyAuth m (Pager User)
    forall (m :: * -> *) a anyAuth.
    (MonadResource m, MonadUnliftIO m, MonadThrow m, FromJSON a) =>
    Text
    -> Text
    -> [Argument]
    -> Maybe UserAccessToken
    -> FacebookT anyAuth m (Pager a)
    searchObjects Text
    "user"

    -- | Get a list of check-ins made by a given user.
    getUserCheckins
      :: (R.MonadResource m, R.MonadUnliftIO m, R.MonadThrow m)
      => UserId -- ^ User ID or @\"me\"@.
      -> [Argument] -- ^ Arguments to be passed to Facebook.
      -> UserAccessToken -- ^ User access token.
      -> FacebookT anyAuth m (Pager Checkin)
    getUserCheckins :: forall (m :: * -> *) anyAuth.
    (MonadResource m, MonadUnliftIO m, MonadThrow m) =>
    UserId
    -> [Argument]
    -> UserAccessToken
    -> FacebookT anyAuth m (Pager Checkin)
    getUserCheckins UserId
    id_ [Argument]
    query UserAccessToken
    token =
      Text
    -> [Argument]
    -> Maybe UserAccessToken
    -> FacebookT anyAuth m (Pager Checkin)
    forall (m :: * -> *) a anyKind anyAuth.
    (MonadResource m, MonadUnliftIO m, MonadThrow m, FromJSON a) =>
    Text
    -> [Argument]
    -> Maybe (AccessToken anyKind)
    -> FacebookT anyAuth m a
    getObject (Text
    "/" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> UserId -> Text
    idCode UserId
    id_ Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    "/checkins") [Argument]
    query (UserAccessToken -> Maybe UserAccessToken
    forall a. a -> Maybe a
    Just UserAccessToken
    token)

    -- | A friend connection of a 'User'.
    data Friend = Friend
      { Friend -> UserId
    friendId :: UserId
      , Friend -> Text
    friendName :: Text
      } deriving (Friend -> Friend -> Bool
    (Friend -> Friend -> Bool)
    -> (Friend -> Friend -> Bool) -> Eq Friend
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Friend -> Friend -> Bool
    == :: Friend -> Friend -> Bool
    $c/= :: Friend -> Friend -> Bool
    /= :: Friend -> Friend -> Bool
    Eq, Eq Friend
    Eq Friend =>
    (Friend -> Friend -> Ordering)
    -> (Friend -> Friend -> Bool)
    -> (Friend -> Friend -> Bool)
    -> (Friend -> Friend -> Bool)
    -> (Friend -> Friend -> Bool)
    -> (Friend -> Friend -> Friend)
    -> (Friend -> Friend -> Friend)
    -> Ord Friend
    Friend -> Friend -> Bool
    Friend -> Friend -> Ordering
    Friend -> Friend -> Friend
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Friend -> Friend -> Ordering
    compare :: Friend -> Friend -> Ordering
    $c< :: Friend -> Friend -> Bool
    < :: Friend -> Friend -> Bool
    $c<= :: Friend -> Friend -> Bool
    <= :: Friend -> Friend -> Bool
    $c> :: Friend -> Friend -> Bool
    > :: Friend -> Friend -> Bool
    $c>= :: Friend -> Friend -> Bool
    >= :: Friend -> Friend -> Bool
    $cmax :: Friend -> Friend -> Friend
    max :: Friend -> Friend -> Friend
    $cmin :: Friend -> Friend -> Friend
    min :: Friend -> Friend -> Friend
    Ord, Int -> Friend -> ShowS
    [Friend] -> ShowS
    Friend -> String
    (Int -> Friend -> ShowS)
    -> (Friend -> String) -> ([Friend] -> ShowS) -> Show Friend
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Friend -> ShowS
    showsPrec :: Int -> Friend -> ShowS
    $cshow :: Friend -> String
    show :: Friend -> String
    $cshowList :: [Friend] -> ShowS
    showList :: [Friend] -> ShowS
    Show, ReadPrec [Friend]
    ReadPrec Friend
    Int -> ReadS Friend
    ReadS [Friend]
    (Int -> ReadS Friend)
    -> ReadS [Friend]
    -> ReadPrec Friend
    -> ReadPrec [Friend]
    -> Read Friend
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Friend
    readsPrec :: Int -> ReadS Friend
    $creadList :: ReadS [Friend]
    readList :: ReadS [Friend]
    $creadPrec :: ReadPrec Friend
    readPrec :: ReadPrec Friend
    $creadListPrec :: ReadPrec [Friend]
    readListPrec :: ReadPrec [Friend]
    Read, Typeable)

    instance A.FromJSON Friend where
      parseJSON :: Value -> Parser Friend
    parseJSON (A.Object Object
    v) = UserId -> Text -> Friend
    Friend (UserId -> Text -> Friend)
    -> Parser UserId -> Parser (Text -> Friend)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Object
    v Object -> Key -> Parser UserId
    forall a. FromJSON a => Object -> Key -> Parser a
    .: Key
    "id" Parser (Text -> Friend) -> Parser Text -> Parser Friend
    forall a b. Parser (a -> b) -> Parser a -> Parser b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Object
    v Object -> Key -> Parser Text
    forall a. FromJSON a => Object -> Key -> Parser a
    .: Key
    "name"
      parseJSON Value
    _ = Parser Friend
    forall a. Parser a
    forall (m :: * -> *) a. MonadPlus m => m a
    mzero

    -- | Get the list of friends of the given user.
    getUserFriends
      :: (R.MonadResource m, R.MonadUnliftIO m, R.MonadThrow m)
      => UserId -- ^ User ID or @\"me\"@.
      -> [Argument] -- ^ Arguments to be passed to Facebook.
      -> UserAccessToken -- ^ User access token.
      -> FacebookT anyAuth m (Pager Friend)
    getUserFriends :: forall (m :: * -> *) anyAuth.
    (MonadResource m, MonadUnliftIO m, MonadThrow m) =>
    UserId
    -> [Argument]
    -> UserAccessToken
    -> FacebookT anyAuth m (Pager Friend)
    getUserFriends UserId
    id_ [Argument]
    query UserAccessToken
    token =
      Text
    -> [Argument]
    -> Maybe UserAccessToken
    -> FacebookT anyAuth m (Pager Friend)
    forall (m :: * -> *) a anyKind anyAuth.
    (MonadResource m, MonadUnliftIO m, MonadThrow m, FromJSON a) =>
    Text
    -> [Argument]
    -> Maybe (AccessToken anyKind)
    -> FacebookT anyAuth m a
    getObject (Text
    "/" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> UserId -> Text
    idCode UserId
    id_ Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    "/friends") [Argument]
    query (UserAccessToken -> Maybe UserAccessToken
    forall a. a -> Maybe a
    Just UserAccessToken
    token)