module TD.Data.FoundPublicPosts
(FoundPublicPosts(..)) 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.Message as Message
import qualified Data.Text as T
import qualified TD.Data.PublicPostSearchLimits as PublicPostSearchLimits
data FoundPublicPosts
= FoundPublicPosts
{ FoundPublicPosts -> Maybe [Message]
messages :: Maybe [Message.Message]
, FoundPublicPosts -> Maybe Text
next_offset :: Maybe T.Text
, FoundPublicPosts -> Maybe PublicPostSearchLimits
search_limits :: Maybe PublicPostSearchLimits.PublicPostSearchLimits
, FoundPublicPosts -> Maybe Bool
are_limits_exceeded :: Maybe Bool
}
deriving (FoundPublicPosts -> FoundPublicPosts -> Bool
(FoundPublicPosts -> FoundPublicPosts -> Bool)
-> (FoundPublicPosts -> FoundPublicPosts -> Bool)
-> Eq FoundPublicPosts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FoundPublicPosts -> FoundPublicPosts -> Bool
== :: FoundPublicPosts -> FoundPublicPosts -> Bool
$c/= :: FoundPublicPosts -> FoundPublicPosts -> Bool
/= :: FoundPublicPosts -> FoundPublicPosts -> Bool
Eq, Int -> FoundPublicPosts -> ShowS
[FoundPublicPosts] -> ShowS
FoundPublicPosts -> String
(Int -> FoundPublicPosts -> ShowS)
-> (FoundPublicPosts -> String)
-> ([FoundPublicPosts] -> ShowS)
-> Show FoundPublicPosts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FoundPublicPosts -> ShowS
showsPrec :: Int -> FoundPublicPosts -> ShowS
$cshow :: FoundPublicPosts -> String
show :: FoundPublicPosts -> String
$cshowList :: [FoundPublicPosts] -> ShowS
showList :: [FoundPublicPosts] -> ShowS
Show)
instance I.ShortShow FoundPublicPosts where
shortShow :: FoundPublicPosts -> String
shortShow FoundPublicPosts
{ messages :: FoundPublicPosts -> Maybe [Message]
messages = Maybe [Message]
messages_
, next_offset :: FoundPublicPosts -> Maybe Text
next_offset = Maybe Text
next_offset_
, search_limits :: FoundPublicPosts -> Maybe PublicPostSearchLimits
search_limits = Maybe PublicPostSearchLimits
search_limits_
, are_limits_exceeded :: FoundPublicPosts -> Maybe Bool
are_limits_exceeded = Maybe Bool
are_limits_exceeded_
}
= String
"FoundPublicPosts"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"messages" String -> Maybe [Message] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Message]
messages_
, String
"next_offset" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
next_offset_
, String
"search_limits" String -> Maybe PublicPostSearchLimits -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe PublicPostSearchLimits
search_limits_
, String
"are_limits_exceeded" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
are_limits_exceeded_
]
instance AT.FromJSON FoundPublicPosts where
parseJSON :: Value -> Parser FoundPublicPosts
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
"foundPublicPosts" -> Value -> Parser FoundPublicPosts
parseFoundPublicPosts Value
v
String
_ -> Parser FoundPublicPosts
forall a. Monoid a => a
mempty
where
parseFoundPublicPosts :: A.Value -> AT.Parser FoundPublicPosts
parseFoundPublicPosts :: Value -> Parser FoundPublicPosts
parseFoundPublicPosts = String
-> (Object -> Parser FoundPublicPosts)
-> Value
-> Parser FoundPublicPosts
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"FoundPublicPosts" ((Object -> Parser FoundPublicPosts)
-> Value -> Parser FoundPublicPosts)
-> (Object -> Parser FoundPublicPosts)
-> Value
-> Parser FoundPublicPosts
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [Message]
messages_ <- Object
o Object -> Key -> Parser (Maybe [Message])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"messages"
Maybe Text
next_offset_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"next_offset"
Maybe PublicPostSearchLimits
search_limits_ <- Object
o Object -> Key -> Parser (Maybe PublicPostSearchLimits)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"search_limits"
Maybe Bool
are_limits_exceeded_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"are_limits_exceeded"
FoundPublicPosts -> Parser FoundPublicPosts
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (FoundPublicPosts -> Parser FoundPublicPosts)
-> FoundPublicPosts -> Parser FoundPublicPosts
forall a b. (a -> b) -> a -> b
$ FoundPublicPosts
{ messages :: Maybe [Message]
messages = Maybe [Message]
messages_
, next_offset :: Maybe Text
next_offset = Maybe Text
next_offset_
, search_limits :: Maybe PublicPostSearchLimits
search_limits = Maybe PublicPostSearchLimits
search_limits_
, are_limits_exceeded :: Maybe Bool
are_limits_exceeded = Maybe Bool
are_limits_exceeded_
}
parseJSON Value
_ = Parser FoundPublicPosts
forall a. Monoid a => a
mempty