module TD.Data.FoundUsers
(FoundUsers(..)) 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 FoundUsers
= FoundUsers
{ FoundUsers -> Maybe [Int]
user_ids :: Maybe [Int]
, FoundUsers -> Maybe Text
next_offset :: Maybe T.Text
}
deriving (FoundUsers -> FoundUsers -> Bool
(FoundUsers -> FoundUsers -> Bool)
-> (FoundUsers -> FoundUsers -> Bool) -> Eq FoundUsers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FoundUsers -> FoundUsers -> Bool
== :: FoundUsers -> FoundUsers -> Bool
$c/= :: FoundUsers -> FoundUsers -> Bool
/= :: FoundUsers -> FoundUsers -> Bool
Eq, Int -> FoundUsers -> ShowS
[FoundUsers] -> ShowS
FoundUsers -> String
(Int -> FoundUsers -> ShowS)
-> (FoundUsers -> String)
-> ([FoundUsers] -> ShowS)
-> Show FoundUsers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FoundUsers -> ShowS
showsPrec :: Int -> FoundUsers -> ShowS
$cshow :: FoundUsers -> String
show :: FoundUsers -> String
$cshowList :: [FoundUsers] -> ShowS
showList :: [FoundUsers] -> ShowS
Show)
instance I.ShortShow FoundUsers where
shortShow :: FoundUsers -> String
shortShow FoundUsers
{ user_ids :: FoundUsers -> Maybe [Int]
user_ids = Maybe [Int]
user_ids_
, next_offset :: FoundUsers -> Maybe Text
next_offset = Maybe Text
next_offset_
}
= String
"FoundUsers"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"user_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
user_ids_
, String
"next_offset" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
next_offset_
]
instance AT.FromJSON FoundUsers where
parseJSON :: Value -> Parser FoundUsers
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
"foundUsers" -> Value -> Parser FoundUsers
parseFoundUsers Value
v
String
_ -> Parser FoundUsers
forall a. Monoid a => a
mempty
where
parseFoundUsers :: A.Value -> AT.Parser FoundUsers
parseFoundUsers :: Value -> Parser FoundUsers
parseFoundUsers = String
-> (Object -> Parser FoundUsers) -> Value -> Parser FoundUsers
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"FoundUsers" ((Object -> Parser FoundUsers) -> Value -> Parser FoundUsers)
-> (Object -> Parser FoundUsers) -> Value -> Parser FoundUsers
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [Int]
user_ids_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"user_ids"
Maybe Text
next_offset_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"next_offset"
FoundUsers -> Parser FoundUsers
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (FoundUsers -> Parser FoundUsers)
-> FoundUsers -> Parser FoundUsers
forall a b. (a -> b) -> a -> b
$ FoundUsers
{ user_ids :: Maybe [Int]
user_ids = Maybe [Int]
user_ids_
, next_offset :: Maybe Text
next_offset = Maybe Text
next_offset_
}
parseJSON Value
_ = Parser FoundUsers
forall a. Monoid a => a
mempty