module TD.Data.WebPageInstantView
(WebPageInstantView(..)) 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.PageBlock as PageBlock
import qualified TD.Data.InternalLinkType as InternalLinkType
data WebPageInstantView
= WebPageInstantView
{ WebPageInstantView -> Maybe [PageBlock]
page_blocks :: Maybe [PageBlock.PageBlock]
, WebPageInstantView -> Maybe Int
view_count :: Maybe Int
, WebPageInstantView -> Maybe Int
version :: Maybe Int
, WebPageInstantView -> Maybe Bool
is_rtl :: Maybe Bool
, WebPageInstantView -> Maybe Bool
is_full :: Maybe Bool
, WebPageInstantView -> Maybe InternalLinkType
feedback_link :: Maybe InternalLinkType.InternalLinkType
}
deriving (WebPageInstantView -> WebPageInstantView -> Bool
(WebPageInstantView -> WebPageInstantView -> Bool)
-> (WebPageInstantView -> WebPageInstantView -> Bool)
-> Eq WebPageInstantView
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: WebPageInstantView -> WebPageInstantView -> Bool
== :: WebPageInstantView -> WebPageInstantView -> Bool
$c/= :: WebPageInstantView -> WebPageInstantView -> Bool
/= :: WebPageInstantView -> WebPageInstantView -> Bool
Eq, Int -> WebPageInstantView -> ShowS
[WebPageInstantView] -> ShowS
WebPageInstantView -> String
(Int -> WebPageInstantView -> ShowS)
-> (WebPageInstantView -> String)
-> ([WebPageInstantView] -> ShowS)
-> Show WebPageInstantView
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> WebPageInstantView -> ShowS
showsPrec :: Int -> WebPageInstantView -> ShowS
$cshow :: WebPageInstantView -> String
show :: WebPageInstantView -> String
$cshowList :: [WebPageInstantView] -> ShowS
showList :: [WebPageInstantView] -> ShowS
Show)
instance I.ShortShow WebPageInstantView where
shortShow :: WebPageInstantView -> String
shortShow WebPageInstantView
{ page_blocks :: WebPageInstantView -> Maybe [PageBlock]
page_blocks = Maybe [PageBlock]
page_blocks_
, view_count :: WebPageInstantView -> Maybe Int
view_count = Maybe Int
view_count_
, version :: WebPageInstantView -> Maybe Int
version = Maybe Int
version_
, is_rtl :: WebPageInstantView -> Maybe Bool
is_rtl = Maybe Bool
is_rtl_
, is_full :: WebPageInstantView -> Maybe Bool
is_full = Maybe Bool
is_full_
, feedback_link :: WebPageInstantView -> Maybe InternalLinkType
feedback_link = Maybe InternalLinkType
feedback_link_
}
= String
"WebPageInstantView"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"page_blocks" String -> Maybe [PageBlock] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [PageBlock]
page_blocks_
, String
"view_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
view_count_
, String
"version" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
version_
, String
"is_rtl" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_rtl_
, String
"is_full" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_full_
, String
"feedback_link" String -> Maybe InternalLinkType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InternalLinkType
feedback_link_
]
instance AT.FromJSON WebPageInstantView where
parseJSON :: Value -> Parser WebPageInstantView
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
"webPageInstantView" -> Value -> Parser WebPageInstantView
parseWebPageInstantView Value
v
String
_ -> Parser WebPageInstantView
forall a. Monoid a => a
mempty
where
parseWebPageInstantView :: A.Value -> AT.Parser WebPageInstantView
parseWebPageInstantView :: Value -> Parser WebPageInstantView
parseWebPageInstantView = String
-> (Object -> Parser WebPageInstantView)
-> Value
-> Parser WebPageInstantView
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"WebPageInstantView" ((Object -> Parser WebPageInstantView)
-> Value -> Parser WebPageInstantView)
-> (Object -> Parser WebPageInstantView)
-> Value
-> Parser WebPageInstantView
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [PageBlock]
page_blocks_ <- Object
o Object -> Key -> Parser (Maybe [PageBlock])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"page_blocks"
Maybe Int
view_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"view_count"
Maybe Int
version_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"version"
Maybe Bool
is_rtl_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_rtl"
Maybe Bool
is_full_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_full"
Maybe InternalLinkType
feedback_link_ <- Object
o Object -> Key -> Parser (Maybe InternalLinkType)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"feedback_link"
WebPageInstantView -> Parser WebPageInstantView
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (WebPageInstantView -> Parser WebPageInstantView)
-> WebPageInstantView -> Parser WebPageInstantView
forall a b. (a -> b) -> a -> b
$ WebPageInstantView
{ page_blocks :: Maybe [PageBlock]
page_blocks = Maybe [PageBlock]
page_blocks_
, view_count :: Maybe Int
view_count = Maybe Int
view_count_
, version :: Maybe Int
version = Maybe Int
version_
, is_rtl :: Maybe Bool
is_rtl = Maybe Bool
is_rtl_
, is_full :: Maybe Bool
is_full = Maybe Bool
is_full_
, feedback_link :: Maybe InternalLinkType
feedback_link = Maybe InternalLinkType
feedback_link_
}
parseJSON Value
_ = Parser WebPageInstantView
forall a. Monoid a => a
mempty