module TD.Data.ChatFolderIcon
( ChatFolderIcon(..)
, defaultChatFolderIcon
) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.Text as T
data ChatFolderIcon
= ChatFolderIcon
{ ChatFolderIcon -> Maybe Text
name :: Maybe T.Text
}
deriving (ChatFolderIcon -> ChatFolderIcon -> Bool
(ChatFolderIcon -> ChatFolderIcon -> Bool)
-> (ChatFolderIcon -> ChatFolderIcon -> Bool) -> Eq ChatFolderIcon
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatFolderIcon -> ChatFolderIcon -> Bool
== :: ChatFolderIcon -> ChatFolderIcon -> Bool
$c/= :: ChatFolderIcon -> ChatFolderIcon -> Bool
/= :: ChatFolderIcon -> ChatFolderIcon -> Bool
Eq, Int -> ChatFolderIcon -> ShowS
[ChatFolderIcon] -> ShowS
ChatFolderIcon -> String
(Int -> ChatFolderIcon -> ShowS)
-> (ChatFolderIcon -> String)
-> ([ChatFolderIcon] -> ShowS)
-> Show ChatFolderIcon
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatFolderIcon -> ShowS
showsPrec :: Int -> ChatFolderIcon -> ShowS
$cshow :: ChatFolderIcon -> String
show :: ChatFolderIcon -> String
$cshowList :: [ChatFolderIcon] -> ShowS
showList :: [ChatFolderIcon] -> ShowS
Show)
instance I.ShortShow ChatFolderIcon where
shortShow :: ChatFolderIcon -> String
shortShow ChatFolderIcon
{ name :: ChatFolderIcon -> Maybe Text
name = Maybe Text
name_
}
= String
"ChatFolderIcon"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"name" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
]
instance AT.FromJSON ChatFolderIcon where
parseJSON :: Value -> Parser ChatFolderIcon
parseJSON v :: Value
v@(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
"chatFolderIcon" -> Value -> Parser ChatFolderIcon
parseChatFolderIcon Value
v
String
_ -> Parser ChatFolderIcon
forall a. Monoid a => a
mempty
where
parseChatFolderIcon :: A.Value -> AT.Parser ChatFolderIcon
parseChatFolderIcon :: Value -> Parser ChatFolderIcon
parseChatFolderIcon = String
-> (Object -> Parser ChatFolderIcon)
-> Value
-> Parser ChatFolderIcon
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatFolderIcon" ((Object -> Parser ChatFolderIcon)
-> Value -> Parser ChatFolderIcon)
-> (Object -> Parser ChatFolderIcon)
-> Value
-> Parser ChatFolderIcon
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
name_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"name"
ChatFolderIcon -> Parser ChatFolderIcon
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatFolderIcon -> Parser ChatFolderIcon)
-> ChatFolderIcon -> Parser ChatFolderIcon
forall a b. (a -> b) -> a -> b
$ ChatFolderIcon
{ name :: Maybe Text
name = Maybe Text
name_
}
parseJSON Value
_ = Parser ChatFolderIcon
forall a. Monoid a => a
mempty
instance AT.ToJSON ChatFolderIcon where
toJSON :: ChatFolderIcon -> Value
toJSON ChatFolderIcon
{ name :: ChatFolderIcon -> Maybe Text
name = Maybe Text
name_
}
= [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
"chatFolderIcon"
, Key
"name" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
name_
]
defaultChatFolderIcon :: ChatFolderIcon
defaultChatFolderIcon :: ChatFolderIcon
defaultChatFolderIcon =
ChatFolderIcon
{ name :: Maybe Text
name = Maybe Text
forall a. Maybe a
Nothing
}