module TD.Query.GetWebPageInstantView
  (GetWebPageInstantView(..)
  , defaultGetWebPageInstantView
  ) 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

-- | Returns an instant view version of a web page if available. Returns a 404 error if the web page has no instant view page. Returns 'TD.Data.WebPageInstantView.WebPageInstantView'
data GetWebPageInstantView
  = GetWebPageInstantView
    { GetWebPageInstantView -> Maybe Text
url        :: Maybe T.Text -- ^ The web page URL
    , GetWebPageInstantView -> Maybe Bool
force_full :: Maybe Bool   -- ^ Pass true to get full instant view for the web page
    }
  deriving (GetWebPageInstantView -> GetWebPageInstantView -> Bool
(GetWebPageInstantView -> GetWebPageInstantView -> Bool)
-> (GetWebPageInstantView -> GetWebPageInstantView -> Bool)
-> Eq GetWebPageInstantView
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetWebPageInstantView -> GetWebPageInstantView -> Bool
== :: GetWebPageInstantView -> GetWebPageInstantView -> Bool
$c/= :: GetWebPageInstantView -> GetWebPageInstantView -> Bool
/= :: GetWebPageInstantView -> GetWebPageInstantView -> Bool
Eq, Int -> GetWebPageInstantView -> ShowS
[GetWebPageInstantView] -> ShowS
GetWebPageInstantView -> String
(Int -> GetWebPageInstantView -> ShowS)
-> (GetWebPageInstantView -> String)
-> ([GetWebPageInstantView] -> ShowS)
-> Show GetWebPageInstantView
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetWebPageInstantView -> ShowS
showsPrec :: Int -> GetWebPageInstantView -> ShowS
$cshow :: GetWebPageInstantView -> String
show :: GetWebPageInstantView -> String
$cshowList :: [GetWebPageInstantView] -> ShowS
showList :: [GetWebPageInstantView] -> ShowS
Show)

instance I.ShortShow GetWebPageInstantView where
  shortShow :: GetWebPageInstantView -> String
shortShow
    GetWebPageInstantView
      { url :: GetWebPageInstantView -> Maybe Text
url        = Maybe Text
url_
      , force_full :: GetWebPageInstantView -> Maybe Bool
force_full = Maybe Bool
force_full_
      }
        = String
"GetWebPageInstantView"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"url"        String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
url_
          , String
"force_full" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
force_full_
          ]

instance AT.ToJSON GetWebPageInstantView where
  toJSON :: GetWebPageInstantView -> Value
toJSON
    GetWebPageInstantView
      { url :: GetWebPageInstantView -> Maybe Text
url        = Maybe Text
url_
      , force_full :: GetWebPageInstantView -> Maybe Bool
force_full = Maybe Bool
force_full_
      }
        = [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
"getWebPageInstantView"
          , Key
"url"        Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
url_
          , Key
"force_full" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
force_full_
          ]

defaultGetWebPageInstantView :: GetWebPageInstantView
defaultGetWebPageInstantView :: GetWebPageInstantView
defaultGetWebPageInstantView =
  GetWebPageInstantView
    { url :: Maybe Text
url        = Maybe Text
forall a. Maybe a
Nothing
    , force_full :: Maybe Bool
force_full = Maybe Bool
forall a. Maybe a
Nothing
    }