module TD.Data.MessageSource
(MessageSource(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data MessageSource
= MessageSourceChatHistory
| MessageSourceMessageThreadHistory
| MessageSourceForumTopicHistory
| MessageSourceHistoryPreview
| MessageSourceChatList
| MessageSourceSearch
| MessageSourceChatEventLog
| MessageSourceNotification
| MessageSourceScreenshot
| MessageSourceOther
deriving (MessageSource -> MessageSource -> Bool
(MessageSource -> MessageSource -> Bool)
-> (MessageSource -> MessageSource -> Bool) -> Eq MessageSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MessageSource -> MessageSource -> Bool
== :: MessageSource -> MessageSource -> Bool
$c/= :: MessageSource -> MessageSource -> Bool
/= :: MessageSource -> MessageSource -> Bool
Eq, Int -> MessageSource -> ShowS
[MessageSource] -> ShowS
MessageSource -> String
(Int -> MessageSource -> ShowS)
-> (MessageSource -> String)
-> ([MessageSource] -> ShowS)
-> Show MessageSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MessageSource -> ShowS
showsPrec :: Int -> MessageSource -> ShowS
$cshow :: MessageSource -> String
show :: MessageSource -> String
$cshowList :: [MessageSource] -> ShowS
showList :: [MessageSource] -> ShowS
Show)
instance I.ShortShow MessageSource where
shortShow :: MessageSource -> String
shortShow MessageSource
MessageSourceChatHistory
= String
"MessageSourceChatHistory"
shortShow MessageSource
MessageSourceMessageThreadHistory
= String
"MessageSourceMessageThreadHistory"
shortShow MessageSource
MessageSourceForumTopicHistory
= String
"MessageSourceForumTopicHistory"
shortShow MessageSource
MessageSourceHistoryPreview
= String
"MessageSourceHistoryPreview"
shortShow MessageSource
MessageSourceChatList
= String
"MessageSourceChatList"
shortShow MessageSource
MessageSourceSearch
= String
"MessageSourceSearch"
shortShow MessageSource
MessageSourceChatEventLog
= String
"MessageSourceChatEventLog"
shortShow MessageSource
MessageSourceNotification
= String
"MessageSourceNotification"
shortShow MessageSource
MessageSourceScreenshot
= String
"MessageSourceScreenshot"
shortShow MessageSource
MessageSourceOther
= String
"MessageSourceOther"
instance AT.FromJSON MessageSource where
parseJSON :: Value -> Parser MessageSource
parseJSON (AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"messageSourceChatHistory" -> MessageSource -> Parser MessageSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageSource
MessageSourceChatHistory
String
"messageSourceMessageThreadHistory" -> MessageSource -> Parser MessageSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageSource
MessageSourceMessageThreadHistory
String
"messageSourceForumTopicHistory" -> MessageSource -> Parser MessageSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageSource
MessageSourceForumTopicHistory
String
"messageSourceHistoryPreview" -> MessageSource -> Parser MessageSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageSource
MessageSourceHistoryPreview
String
"messageSourceChatList" -> MessageSource -> Parser MessageSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageSource
MessageSourceChatList
String
"messageSourceSearch" -> MessageSource -> Parser MessageSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageSource
MessageSourceSearch
String
"messageSourceChatEventLog" -> MessageSource -> Parser MessageSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageSource
MessageSourceChatEventLog
String
"messageSourceNotification" -> MessageSource -> Parser MessageSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageSource
MessageSourceNotification
String
"messageSourceScreenshot" -> MessageSource -> Parser MessageSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageSource
MessageSourceScreenshot
String
"messageSourceOther" -> MessageSource -> Parser MessageSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure MessageSource
MessageSourceOther
String
_ -> Parser MessageSource
forall a. Monoid a => a
mempty
parseJSON Value
_ = Parser MessageSource
forall a. Monoid a => a
mempty
instance AT.ToJSON MessageSource where
toJSON :: MessageSource -> Value
toJSON MessageSource
MessageSourceChatHistory
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"messageSourceChatHistory"
]
toJSON MessageSource
MessageSourceMessageThreadHistory
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"messageSourceMessageThreadHistory"
]
toJSON MessageSource
MessageSourceForumTopicHistory
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"messageSourceForumTopicHistory"
]
toJSON MessageSource
MessageSourceHistoryPreview
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"messageSourceHistoryPreview"
]
toJSON MessageSource
MessageSourceChatList
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"messageSourceChatList"
]
toJSON MessageSource
MessageSourceSearch
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"messageSourceSearch"
]
toJSON MessageSource
MessageSourceChatEventLog
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"messageSourceChatEventLog"
]
toJSON MessageSource
MessageSourceNotification
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"messageSourceNotification"
]
toJSON MessageSource
MessageSourceScreenshot
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"messageSourceScreenshot"
]
toJSON MessageSource
MessageSourceOther
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"messageSourceOther"
]