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