module Web.Twitter.Conduit.Types
( TWToken (..)
, TWInfo (..)
, twitterOAuth
, setCredential
) where
import Data.Default
import Data.Typeable (Typeable)
import Web.Authenticate.OAuth
import Network.HTTP.Conduit
data TWToken = TWToken
{ twOAuth :: OAuth
, twCredential :: Credential
} deriving (Show, Read, Eq, Typeable)
instance Default TWToken where
def = TWToken twitterOAuth (Credential [])
data TWInfo = TWInfo
{ twToken :: TWToken
, twProxy :: Maybe Proxy
} deriving (Show, Read, Eq, Typeable)
instance Default TWInfo where
def = TWInfo
{ twToken = def
, twProxy = Nothing
}
twitterOAuth :: OAuth
twitterOAuth =
def { oauthServerName = "twitter"
, oauthRequestUri = "https://api.twitter.com/oauth/request_token"
, oauthAccessTokenUri = "https://api.twitter.com/oauth/access_token"
, oauthAuthorizeUri = "https://api.twitter.com/oauth/authorize"
, oauthConsumerKey = error "You MUST specify oauthConsumerKey parameter."
, oauthConsumerSecret = error "You MUST specify oauthConsumerSecret parameter."
, oauthSignatureMethod = HMACSHA1
, oauthCallback = Nothing
}
setCredential :: OAuth -> Credential -> TWInfo -> TWInfo
setCredential oa cred env
= TWInfo
{ twToken = TWToken oa cred
, twProxy = twProxy env
}