module Facebook.Types
( Credentials(..)
, AccessToken(..)
, UserAccessToken
, AppAccessToken
, AccessTokenData
, UserId
, accessTokenData
, accessTokenExpires
, accessTokenUserId
, UserKind
, AppKind
, Argument
, (<>)
) where
import Data.ByteString (ByteString)
import Data.Monoid (Monoid, mappend)
import Data.Time (UTCTime)
import Data.Typeable (Typeable, Typeable1)
import Network.HTTP.Types (Ascii)
data Credentials =
Credentials { appName :: Ascii
, appId :: Ascii
, appSecret :: Ascii
}
deriving (Eq, Ord, Show, Typeable)
data AccessToken kind where
UserAccessToken :: UserId -> AccessTokenData -> UTCTime -> AccessToken UserKind
AppAccessToken :: AccessTokenData -> AccessToken AppKind
type UserAccessToken = AccessToken UserKind
type AppAccessToken = AccessToken AppKind
deriving instance Eq (AccessToken kind)
deriving instance Ord (AccessToken kind)
deriving instance Show (AccessToken kind)
deriving instance Typeable1 AccessToken
type AccessTokenData = Ascii
type UserId = Ascii
accessTokenData :: AccessToken anyKind -> AccessTokenData
accessTokenData (UserAccessToken _ d _) = d
accessTokenData (AppAccessToken d) = d
accessTokenExpires :: AccessToken anyKind -> Maybe UTCTime
accessTokenExpires (UserAccessToken _ _ expt) = Just expt
accessTokenExpires (AppAccessToken _) = Nothing
accessTokenUserId :: UserAccessToken -> UserId
accessTokenUserId (UserAccessToken uid _ _) = uid
data UserKind deriving (Typeable)
data AppKind deriving (Typeable)
type Argument = (ByteString, ByteString)
(<>) :: Monoid a => a -> a -> a
(<>) = mappend