{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
module Web.Tweet.Types where
import Data.Default
import GHC.Generics
import Lens.Micro
import Web.Authenticate.OAuth
data Tweet = Tweet
{ _status :: String
, _handles :: [String]
, _replyID :: Maybe Int
} deriving (Generic, Default)
data TweetEntity = TweetEntity
{ _text :: String
, _name :: String
, _screenName :: String
, _tweetId :: Int
, _withheld :: [String]
, _quoted :: Maybe TweetEntity
, _retweets :: Int
, _favorites :: Int
} deriving (Generic, Default, Eq, Show)
type Timeline = [TweetEntity]
type Config = (OAuth, Credential)
status :: Lens' Tweet String
status f tweet@Tweet { _status = str } = fmap (\str' -> tweet { _status = str'}) (f str)
handles :: Lens' Tweet [String]
handles f tweet@Tweet { _handles = hs } = fmap (\hs' -> tweet { _handles = hs'}) (f hs)
replyID :: Lens' Tweet (Maybe Int)
replyID f tweet@Tweet { _replyID = reply } = fmap (\reply' -> tweet { _replyID = reply'}) (f reply)
text :: Lens' TweetEntity String
text f tweet@TweetEntity { _text = txt } = fmap (\txt' -> tweet { _text = txt'}) (f txt)
name :: Lens' TweetEntity String
name f tweet@TweetEntity { _name = nam } = fmap (\nam' -> tweet { _name = nam'}) (f nam)
screenName :: Lens' TweetEntity String
screenName f tweet@TweetEntity { _screenName = scr } = fmap (\scr' -> tweet { _screenName = scr'}) (f scr)
tweetId :: Lens' TweetEntity Int
tweetId f tweet@TweetEntity { _tweetId = tw } = fmap (\tw' -> tweet { _tweetId = tw'}) (f tw)
quoted :: Lens' TweetEntity (Maybe TweetEntity)
quoted f tweet@TweetEntity { _quoted = q } = fmap (\q' -> tweet { _quoted = q'}) (f q)
retweets :: Lens' TweetEntity Int
retweets f tweet@TweetEntity { _retweets = rts } = fmap (\rts' -> tweet { _retweets = rts'}) (f rts)
favorites :: Lens' TweetEntity Int
favorites f tweet@TweetEntity { _favorites = fav } = fmap (\fav' -> tweet { _favorites = fav'}) (f fav)