module TD.Data.SupergroupMembersFilter
(SupergroupMembersFilter(..)) 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 SupergroupMembersFilter
= SupergroupMembersFilterRecent
| SupergroupMembersFilterContacts
{ SupergroupMembersFilter -> Maybe Text
query :: Maybe T.Text
}
| SupergroupMembersFilterAdministrators
| SupergroupMembersFilterSearch
{ query :: Maybe T.Text
}
| SupergroupMembersFilterRestricted
{ query :: Maybe T.Text
}
| SupergroupMembersFilterBanned
{ query :: Maybe T.Text
}
| SupergroupMembersFilterMention
{ query :: Maybe T.Text
, SupergroupMembersFilter -> Maybe Int
message_thread_id :: Maybe Int
}
| SupergroupMembersFilterBots
deriving (SupergroupMembersFilter -> SupergroupMembersFilter -> Bool
(SupergroupMembersFilter -> SupergroupMembersFilter -> Bool)
-> (SupergroupMembersFilter -> SupergroupMembersFilter -> Bool)
-> Eq SupergroupMembersFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SupergroupMembersFilter -> SupergroupMembersFilter -> Bool
== :: SupergroupMembersFilter -> SupergroupMembersFilter -> Bool
$c/= :: SupergroupMembersFilter -> SupergroupMembersFilter -> Bool
/= :: SupergroupMembersFilter -> SupergroupMembersFilter -> Bool
Eq, Int -> SupergroupMembersFilter -> ShowS
[SupergroupMembersFilter] -> ShowS
SupergroupMembersFilter -> String
(Int -> SupergroupMembersFilter -> ShowS)
-> (SupergroupMembersFilter -> String)
-> ([SupergroupMembersFilter] -> ShowS)
-> Show SupergroupMembersFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SupergroupMembersFilter -> ShowS
showsPrec :: Int -> SupergroupMembersFilter -> ShowS
$cshow :: SupergroupMembersFilter -> String
show :: SupergroupMembersFilter -> String
$cshowList :: [SupergroupMembersFilter] -> ShowS
showList :: [SupergroupMembersFilter] -> ShowS
Show)
instance I.ShortShow SupergroupMembersFilter where
shortShow :: SupergroupMembersFilter -> String
shortShow SupergroupMembersFilter
SupergroupMembersFilterRecent
= String
"SupergroupMembersFilterRecent"
shortShow SupergroupMembersFilterContacts
{ query :: SupergroupMembersFilter -> Maybe Text
query = Maybe Text
query_
}
= String
"SupergroupMembersFilterContacts"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"query" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
query_
]
shortShow SupergroupMembersFilter
SupergroupMembersFilterAdministrators
= String
"SupergroupMembersFilterAdministrators"
shortShow SupergroupMembersFilterSearch
{ query :: SupergroupMembersFilter -> Maybe Text
query = Maybe Text
query_
}
= String
"SupergroupMembersFilterSearch"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"query" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
query_
]
shortShow SupergroupMembersFilterRestricted
{ query :: SupergroupMembersFilter -> Maybe Text
query = Maybe Text
query_
}
= String
"SupergroupMembersFilterRestricted"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"query" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
query_
]
shortShow SupergroupMembersFilterBanned
{ query :: SupergroupMembersFilter -> Maybe Text
query = Maybe Text
query_
}
= String
"SupergroupMembersFilterBanned"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"query" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
query_
]
shortShow SupergroupMembersFilterMention
{ query :: SupergroupMembersFilter -> Maybe Text
query = Maybe Text
query_
, message_thread_id :: SupergroupMembersFilter -> Maybe Int
message_thread_id = Maybe Int
message_thread_id_
}
= String
"SupergroupMembersFilterMention"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"query" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
query_
, String
"message_thread_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
message_thread_id_
]
shortShow SupergroupMembersFilter
SupergroupMembersFilterBots
= String
"SupergroupMembersFilterBots"
instance AT.FromJSON SupergroupMembersFilter where
parseJSON :: Value -> Parser SupergroupMembersFilter
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
"supergroupMembersFilterRecent" -> SupergroupMembersFilter -> Parser SupergroupMembersFilter
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SupergroupMembersFilter
SupergroupMembersFilterRecent
String
"supergroupMembersFilterContacts" -> Value -> Parser SupergroupMembersFilter
parseSupergroupMembersFilterContacts Value
v
String
"supergroupMembersFilterAdministrators" -> SupergroupMembersFilter -> Parser SupergroupMembersFilter
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SupergroupMembersFilter
SupergroupMembersFilterAdministrators
String
"supergroupMembersFilterSearch" -> Value -> Parser SupergroupMembersFilter
parseSupergroupMembersFilterSearch Value
v
String
"supergroupMembersFilterRestricted" -> Value -> Parser SupergroupMembersFilter
parseSupergroupMembersFilterRestricted Value
v
String
"supergroupMembersFilterBanned" -> Value -> Parser SupergroupMembersFilter
parseSupergroupMembersFilterBanned Value
v
String
"supergroupMembersFilterMention" -> Value -> Parser SupergroupMembersFilter
parseSupergroupMembersFilterMention Value
v
String
"supergroupMembersFilterBots" -> SupergroupMembersFilter -> Parser SupergroupMembersFilter
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SupergroupMembersFilter
SupergroupMembersFilterBots
String
_ -> Parser SupergroupMembersFilter
forall a. Monoid a => a
mempty
where
parseSupergroupMembersFilterContacts :: A.Value -> AT.Parser SupergroupMembersFilter
parseSupergroupMembersFilterContacts :: Value -> Parser SupergroupMembersFilter
parseSupergroupMembersFilterContacts = String
-> (Object -> Parser SupergroupMembersFilter)
-> Value
-> Parser SupergroupMembersFilter
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"SupergroupMembersFilterContacts" ((Object -> Parser SupergroupMembersFilter)
-> Value -> Parser SupergroupMembersFilter)
-> (Object -> Parser SupergroupMembersFilter)
-> Value
-> Parser SupergroupMembersFilter
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
query_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"query"
SupergroupMembersFilter -> Parser SupergroupMembersFilter
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SupergroupMembersFilter -> Parser SupergroupMembersFilter)
-> SupergroupMembersFilter -> Parser SupergroupMembersFilter
forall a b. (a -> b) -> a -> b
$ SupergroupMembersFilterContacts
{ query :: Maybe Text
query = Maybe Text
query_
}
parseSupergroupMembersFilterSearch :: A.Value -> AT.Parser SupergroupMembersFilter
parseSupergroupMembersFilterSearch :: Value -> Parser SupergroupMembersFilter
parseSupergroupMembersFilterSearch = String
-> (Object -> Parser SupergroupMembersFilter)
-> Value
-> Parser SupergroupMembersFilter
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"SupergroupMembersFilterSearch" ((Object -> Parser SupergroupMembersFilter)
-> Value -> Parser SupergroupMembersFilter)
-> (Object -> Parser SupergroupMembersFilter)
-> Value
-> Parser SupergroupMembersFilter
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
query_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"query"
SupergroupMembersFilter -> Parser SupergroupMembersFilter
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SupergroupMembersFilter -> Parser SupergroupMembersFilter)
-> SupergroupMembersFilter -> Parser SupergroupMembersFilter
forall a b. (a -> b) -> a -> b
$ SupergroupMembersFilterSearch
{ query :: Maybe Text
query = Maybe Text
query_
}
parseSupergroupMembersFilterRestricted :: A.Value -> AT.Parser SupergroupMembersFilter
parseSupergroupMembersFilterRestricted :: Value -> Parser SupergroupMembersFilter
parseSupergroupMembersFilterRestricted = String
-> (Object -> Parser SupergroupMembersFilter)
-> Value
-> Parser SupergroupMembersFilter
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"SupergroupMembersFilterRestricted" ((Object -> Parser SupergroupMembersFilter)
-> Value -> Parser SupergroupMembersFilter)
-> (Object -> Parser SupergroupMembersFilter)
-> Value
-> Parser SupergroupMembersFilter
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
query_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"query"
SupergroupMembersFilter -> Parser SupergroupMembersFilter
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SupergroupMembersFilter -> Parser SupergroupMembersFilter)
-> SupergroupMembersFilter -> Parser SupergroupMembersFilter
forall a b. (a -> b) -> a -> b
$ SupergroupMembersFilterRestricted
{ query :: Maybe Text
query = Maybe Text
query_
}
parseSupergroupMembersFilterBanned :: A.Value -> AT.Parser SupergroupMembersFilter
parseSupergroupMembersFilterBanned :: Value -> Parser SupergroupMembersFilter
parseSupergroupMembersFilterBanned = String
-> (Object -> Parser SupergroupMembersFilter)
-> Value
-> Parser SupergroupMembersFilter
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"SupergroupMembersFilterBanned" ((Object -> Parser SupergroupMembersFilter)
-> Value -> Parser SupergroupMembersFilter)
-> (Object -> Parser SupergroupMembersFilter)
-> Value
-> Parser SupergroupMembersFilter
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
query_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"query"
SupergroupMembersFilter -> Parser SupergroupMembersFilter
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SupergroupMembersFilter -> Parser SupergroupMembersFilter)
-> SupergroupMembersFilter -> Parser SupergroupMembersFilter
forall a b. (a -> b) -> a -> b
$ SupergroupMembersFilterBanned
{ query :: Maybe Text
query = Maybe Text
query_
}
parseSupergroupMembersFilterMention :: A.Value -> AT.Parser SupergroupMembersFilter
parseSupergroupMembersFilterMention :: Value -> Parser SupergroupMembersFilter
parseSupergroupMembersFilterMention = String
-> (Object -> Parser SupergroupMembersFilter)
-> Value
-> Parser SupergroupMembersFilter
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"SupergroupMembersFilterMention" ((Object -> Parser SupergroupMembersFilter)
-> Value -> Parser SupergroupMembersFilter)
-> (Object -> Parser SupergroupMembersFilter)
-> Value
-> Parser SupergroupMembersFilter
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
query_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"query"
Maybe Int
message_thread_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"message_thread_id"
SupergroupMembersFilter -> Parser SupergroupMembersFilter
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SupergroupMembersFilter -> Parser SupergroupMembersFilter)
-> SupergroupMembersFilter -> Parser SupergroupMembersFilter
forall a b. (a -> b) -> a -> b
$ SupergroupMembersFilterMention
{ query :: Maybe Text
query = Maybe Text
query_
, message_thread_id :: Maybe Int
message_thread_id = Maybe Int
message_thread_id_
}
parseJSON Value
_ = Parser SupergroupMembersFilter
forall a. Monoid a => a
mempty
instance AT.ToJSON SupergroupMembersFilter where
toJSON :: SupergroupMembersFilter -> Value
toJSON SupergroupMembersFilter
SupergroupMembersFilterRecent
= [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
"supergroupMembersFilterRecent"
]
toJSON SupergroupMembersFilterContacts
{ query :: SupergroupMembersFilter -> Maybe Text
query = Maybe Text
query_
}
= [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
"supergroupMembersFilterContacts"
, Key
"query" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
query_
]
toJSON SupergroupMembersFilter
SupergroupMembersFilterAdministrators
= [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
"supergroupMembersFilterAdministrators"
]
toJSON SupergroupMembersFilterSearch
{ query :: SupergroupMembersFilter -> Maybe Text
query = Maybe Text
query_
}
= [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
"supergroupMembersFilterSearch"
, Key
"query" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
query_
]
toJSON SupergroupMembersFilterRestricted
{ query :: SupergroupMembersFilter -> Maybe Text
query = Maybe Text
query_
}
= [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
"supergroupMembersFilterRestricted"
, Key
"query" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
query_
]
toJSON SupergroupMembersFilterBanned
{ query :: SupergroupMembersFilter -> Maybe Text
query = Maybe Text
query_
}
= [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
"supergroupMembersFilterBanned"
, Key
"query" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
query_
]
toJSON SupergroupMembersFilterMention
{ query :: SupergroupMembersFilter -> Maybe Text
query = Maybe Text
query_
, message_thread_id :: SupergroupMembersFilter -> Maybe Int
message_thread_id = Maybe Int
message_thread_id_
}
= [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
"supergroupMembersFilterMention"
, Key
"query" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
query_
, Key
"message_thread_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
message_thread_id_
]
toJSON SupergroupMembersFilter
SupergroupMembersFilterBots
= [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
"supergroupMembersFilterBots"
]