module TD.Data.ChatFolder
( ChatFolder(..)
, defaultChatFolder
) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.ChatFolderName as ChatFolderName
import qualified TD.Data.ChatFolderIcon as ChatFolderIcon
data ChatFolder
= ChatFolder
{ ChatFolder -> Maybe ChatFolderName
name :: Maybe ChatFolderName.ChatFolderName
, ChatFolder -> Maybe ChatFolderIcon
icon :: Maybe ChatFolderIcon.ChatFolderIcon
, ChatFolder -> Maybe Int
color_id :: Maybe Int
, ChatFolder -> Maybe Bool
is_shareable :: Maybe Bool
, ChatFolder -> Maybe [Int]
pinned_chat_ids :: Maybe [Int]
, ChatFolder -> Maybe [Int]
included_chat_ids :: Maybe [Int]
, ChatFolder -> Maybe [Int]
excluded_chat_ids :: Maybe [Int]
, ChatFolder -> Maybe Bool
exclude_muted :: Maybe Bool
, ChatFolder -> Maybe Bool
exclude_read :: Maybe Bool
, ChatFolder -> Maybe Bool
exclude_archived :: Maybe Bool
, ChatFolder -> Maybe Bool
include_contacts :: Maybe Bool
, ChatFolder -> Maybe Bool
include_non_contacts :: Maybe Bool
, ChatFolder -> Maybe Bool
include_bots :: Maybe Bool
, ChatFolder -> Maybe Bool
include_groups :: Maybe Bool
, ChatFolder -> Maybe Bool
include_channels :: Maybe Bool
}
deriving (ChatFolder -> ChatFolder -> Bool
(ChatFolder -> ChatFolder -> Bool)
-> (ChatFolder -> ChatFolder -> Bool) -> Eq ChatFolder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatFolder -> ChatFolder -> Bool
== :: ChatFolder -> ChatFolder -> Bool
$c/= :: ChatFolder -> ChatFolder -> Bool
/= :: ChatFolder -> ChatFolder -> Bool
Eq, Int -> ChatFolder -> ShowS
[ChatFolder] -> ShowS
ChatFolder -> String
(Int -> ChatFolder -> ShowS)
-> (ChatFolder -> String)
-> ([ChatFolder] -> ShowS)
-> Show ChatFolder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatFolder -> ShowS
showsPrec :: Int -> ChatFolder -> ShowS
$cshow :: ChatFolder -> String
show :: ChatFolder -> String
$cshowList :: [ChatFolder] -> ShowS
showList :: [ChatFolder] -> ShowS
Show)
instance I.ShortShow ChatFolder where
shortShow :: ChatFolder -> String
shortShow ChatFolder
{ name :: ChatFolder -> Maybe ChatFolderName
name = Maybe ChatFolderName
name_
, icon :: ChatFolder -> Maybe ChatFolderIcon
icon = Maybe ChatFolderIcon
icon_
, color_id :: ChatFolder -> Maybe Int
color_id = Maybe Int
color_id_
, is_shareable :: ChatFolder -> Maybe Bool
is_shareable = Maybe Bool
is_shareable_
, pinned_chat_ids :: ChatFolder -> Maybe [Int]
pinned_chat_ids = Maybe [Int]
pinned_chat_ids_
, included_chat_ids :: ChatFolder -> Maybe [Int]
included_chat_ids = Maybe [Int]
included_chat_ids_
, excluded_chat_ids :: ChatFolder -> Maybe [Int]
excluded_chat_ids = Maybe [Int]
excluded_chat_ids_
, exclude_muted :: ChatFolder -> Maybe Bool
exclude_muted = Maybe Bool
exclude_muted_
, exclude_read :: ChatFolder -> Maybe Bool
exclude_read = Maybe Bool
exclude_read_
, exclude_archived :: ChatFolder -> Maybe Bool
exclude_archived = Maybe Bool
exclude_archived_
, include_contacts :: ChatFolder -> Maybe Bool
include_contacts = Maybe Bool
include_contacts_
, include_non_contacts :: ChatFolder -> Maybe Bool
include_non_contacts = Maybe Bool
include_non_contacts_
, include_bots :: ChatFolder -> Maybe Bool
include_bots = Maybe Bool
include_bots_
, include_groups :: ChatFolder -> Maybe Bool
include_groups = Maybe Bool
include_groups_
, include_channels :: ChatFolder -> Maybe Bool
include_channels = Maybe Bool
include_channels_
}
= String
"ChatFolder"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"name" String -> Maybe ChatFolderName -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatFolderName
name_
, String
"icon" String -> Maybe ChatFolderIcon -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatFolderIcon
icon_
, String
"color_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
color_id_
, String
"is_shareable" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_shareable_
, String
"pinned_chat_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
pinned_chat_ids_
, String
"included_chat_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
included_chat_ids_
, String
"excluded_chat_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
excluded_chat_ids_
, String
"exclude_muted" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
exclude_muted_
, String
"exclude_read" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
exclude_read_
, String
"exclude_archived" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
exclude_archived_
, String
"include_contacts" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
include_contacts_
, String
"include_non_contacts" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
include_non_contacts_
, String
"include_bots" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
include_bots_
, String
"include_groups" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
include_groups_
, String
"include_channels" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
include_channels_
]
instance AT.FromJSON ChatFolder where
parseJSON :: Value -> Parser ChatFolder
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
"chatFolder" -> Value -> Parser ChatFolder
parseChatFolder Value
v
String
_ -> Parser ChatFolder
forall a. Monoid a => a
mempty
where
parseChatFolder :: A.Value -> AT.Parser ChatFolder
parseChatFolder :: Value -> Parser ChatFolder
parseChatFolder = String
-> (Object -> Parser ChatFolder) -> Value -> Parser ChatFolder
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatFolder" ((Object -> Parser ChatFolder) -> Value -> Parser ChatFolder)
-> (Object -> Parser ChatFolder) -> Value -> Parser ChatFolder
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe ChatFolderName
name_ <- Object
o Object -> Key -> Parser (Maybe ChatFolderName)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"name"
Maybe ChatFolderIcon
icon_ <- Object
o Object -> Key -> Parser (Maybe ChatFolderIcon)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"icon"
Maybe Int
color_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"color_id"
Maybe Bool
is_shareable_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_shareable"
Maybe [Int]
pinned_chat_ids_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"pinned_chat_ids"
Maybe [Int]
included_chat_ids_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"included_chat_ids"
Maybe [Int]
excluded_chat_ids_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"excluded_chat_ids"
Maybe Bool
exclude_muted_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"exclude_muted"
Maybe Bool
exclude_read_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"exclude_read"
Maybe Bool
exclude_archived_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"exclude_archived"
Maybe Bool
include_contacts_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"include_contacts"
Maybe Bool
include_non_contacts_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"include_non_contacts"
Maybe Bool
include_bots_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"include_bots"
Maybe Bool
include_groups_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"include_groups"
Maybe Bool
include_channels_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"include_channels"
ChatFolder -> Parser ChatFolder
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatFolder -> Parser ChatFolder)
-> ChatFolder -> Parser ChatFolder
forall a b. (a -> b) -> a -> b
$ ChatFolder
{ name :: Maybe ChatFolderName
name = Maybe ChatFolderName
name_
, icon :: Maybe ChatFolderIcon
icon = Maybe ChatFolderIcon
icon_
, color_id :: Maybe Int
color_id = Maybe Int
color_id_
, is_shareable :: Maybe Bool
is_shareable = Maybe Bool
is_shareable_
, pinned_chat_ids :: Maybe [Int]
pinned_chat_ids = Maybe [Int]
pinned_chat_ids_
, included_chat_ids :: Maybe [Int]
included_chat_ids = Maybe [Int]
included_chat_ids_
, excluded_chat_ids :: Maybe [Int]
excluded_chat_ids = Maybe [Int]
excluded_chat_ids_
, exclude_muted :: Maybe Bool
exclude_muted = Maybe Bool
exclude_muted_
, exclude_read :: Maybe Bool
exclude_read = Maybe Bool
exclude_read_
, exclude_archived :: Maybe Bool
exclude_archived = Maybe Bool
exclude_archived_
, include_contacts :: Maybe Bool
include_contacts = Maybe Bool
include_contacts_
, include_non_contacts :: Maybe Bool
include_non_contacts = Maybe Bool
include_non_contacts_
, include_bots :: Maybe Bool
include_bots = Maybe Bool
include_bots_
, include_groups :: Maybe Bool
include_groups = Maybe Bool
include_groups_
, include_channels :: Maybe Bool
include_channels = Maybe Bool
include_channels_
}
parseJSON Value
_ = Parser ChatFolder
forall a. Monoid a => a
mempty
instance AT.ToJSON ChatFolder where
toJSON :: ChatFolder -> Value
toJSON ChatFolder
{ name :: ChatFolder -> Maybe ChatFolderName
name = Maybe ChatFolderName
name_
, icon :: ChatFolder -> Maybe ChatFolderIcon
icon = Maybe ChatFolderIcon
icon_
, color_id :: ChatFolder -> Maybe Int
color_id = Maybe Int
color_id_
, is_shareable :: ChatFolder -> Maybe Bool
is_shareable = Maybe Bool
is_shareable_
, pinned_chat_ids :: ChatFolder -> Maybe [Int]
pinned_chat_ids = Maybe [Int]
pinned_chat_ids_
, included_chat_ids :: ChatFolder -> Maybe [Int]
included_chat_ids = Maybe [Int]
included_chat_ids_
, excluded_chat_ids :: ChatFolder -> Maybe [Int]
excluded_chat_ids = Maybe [Int]
excluded_chat_ids_
, exclude_muted :: ChatFolder -> Maybe Bool
exclude_muted = Maybe Bool
exclude_muted_
, exclude_read :: ChatFolder -> Maybe Bool
exclude_read = Maybe Bool
exclude_read_
, exclude_archived :: ChatFolder -> Maybe Bool
exclude_archived = Maybe Bool
exclude_archived_
, include_contacts :: ChatFolder -> Maybe Bool
include_contacts = Maybe Bool
include_contacts_
, include_non_contacts :: ChatFolder -> Maybe Bool
include_non_contacts = Maybe Bool
include_non_contacts_
, include_bots :: ChatFolder -> Maybe Bool
include_bots = Maybe Bool
include_bots_
, include_groups :: ChatFolder -> Maybe Bool
include_groups = Maybe Bool
include_groups_
, include_channels :: ChatFolder -> Maybe Bool
include_channels = Maybe Bool
include_channels_
}
= [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
"chatFolder"
, Key
"name" Key -> Maybe ChatFolderName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ChatFolderName
name_
, Key
"icon" Key -> Maybe ChatFolderIcon -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ChatFolderIcon
icon_
, Key
"color_id" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
color_id_
, Key
"is_shareable" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_shareable_
, Key
"pinned_chat_ids" Key -> Maybe [Int] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Int]
pinned_chat_ids_
, Key
"included_chat_ids" Key -> Maybe [Int] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Int]
included_chat_ids_
, Key
"excluded_chat_ids" Key -> Maybe [Int] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Int]
excluded_chat_ids_
, Key
"exclude_muted" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
exclude_muted_
, Key
"exclude_read" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
exclude_read_
, Key
"exclude_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
exclude_archived_
, Key
"include_contacts" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
include_contacts_
, Key
"include_non_contacts" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
include_non_contacts_
, Key
"include_bots" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
include_bots_
, Key
"include_groups" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
include_groups_
, Key
"include_channels" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
include_channels_
]
defaultChatFolder :: ChatFolder
defaultChatFolder :: ChatFolder
defaultChatFolder =
ChatFolder
{ name :: Maybe ChatFolderName
name = Maybe ChatFolderName
forall a. Maybe a
Nothing
, icon :: Maybe ChatFolderIcon
icon = Maybe ChatFolderIcon
forall a. Maybe a
Nothing
, color_id :: Maybe Int
color_id = Maybe Int
forall a. Maybe a
Nothing
, is_shareable :: Maybe Bool
is_shareable = Maybe Bool
forall a. Maybe a
Nothing
, pinned_chat_ids :: Maybe [Int]
pinned_chat_ids = Maybe [Int]
forall a. Maybe a
Nothing
, included_chat_ids :: Maybe [Int]
included_chat_ids = Maybe [Int]
forall a. Maybe a
Nothing
, excluded_chat_ids :: Maybe [Int]
excluded_chat_ids = Maybe [Int]
forall a. Maybe a
Nothing
, exclude_muted :: Maybe Bool
exclude_muted = Maybe Bool
forall a. Maybe a
Nothing
, exclude_read :: Maybe Bool
exclude_read = Maybe Bool
forall a. Maybe a
Nothing
, exclude_archived :: Maybe Bool
exclude_archived = Maybe Bool
forall a. Maybe a
Nothing
, include_contacts :: Maybe Bool
include_contacts = Maybe Bool
forall a. Maybe a
Nothing
, include_non_contacts :: Maybe Bool
include_non_contacts = Maybe Bool
forall a. Maybe a
Nothing
, include_bots :: Maybe Bool
include_bots = Maybe Bool
forall a. Maybe a
Nothing
, include_groups :: Maybe Bool
include_groups = Maybe Bool
forall a. Maybe a
Nothing
, include_channels :: Maybe Bool
include_channels = Maybe Bool
forall a. Maybe a
Nothing
}