module TD.Query.GetStory
  (GetStory(..)
  , defaultGetStory
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

-- | Returns a story. Returns 'TD.Data.Story.Story'
data GetStory
  = GetStory
    { GetStory -> Maybe Int
story_sender_chat_id :: Maybe Int  -- ^ Identifier of the chat that posted the story
    , GetStory -> Maybe Int
story_id             :: Maybe Int  -- ^ Story identifier
    , GetStory -> Maybe Bool
only_local           :: Maybe Bool -- ^ Pass true to get only locally available information without sending network requests
    }
  deriving (GetStory -> GetStory -> Bool
(GetStory -> GetStory -> Bool)
-> (GetStory -> GetStory -> Bool) -> Eq GetStory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetStory -> GetStory -> Bool
== :: GetStory -> GetStory -> Bool
$c/= :: GetStory -> GetStory -> Bool
/= :: GetStory -> GetStory -> Bool
Eq, Int -> GetStory -> ShowS
[GetStory] -> ShowS
GetStory -> String
(Int -> GetStory -> ShowS)
-> (GetStory -> String) -> ([GetStory] -> ShowS) -> Show GetStory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetStory -> ShowS
showsPrec :: Int -> GetStory -> ShowS
$cshow :: GetStory -> String
show :: GetStory -> String
$cshowList :: [GetStory] -> ShowS
showList :: [GetStory] -> ShowS
Show)

instance I.ShortShow GetStory where
  shortShow :: GetStory -> String
shortShow
    GetStory
      { story_sender_chat_id :: GetStory -> Maybe Int
story_sender_chat_id = Maybe Int
story_sender_chat_id_
      , story_id :: GetStory -> Maybe Int
story_id             = Maybe Int
story_id_
      , only_local :: GetStory -> Maybe Bool
only_local           = Maybe Bool
only_local_
      }
        = String
"GetStory"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"story_sender_chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
story_sender_chat_id_
          , String
"story_id"             String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
story_id_
          , String
"only_local"           String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
only_local_
          ]

instance AT.ToJSON GetStory where
  toJSON :: GetStory -> Value
toJSON
    GetStory
      { story_sender_chat_id :: GetStory -> Maybe Int
story_sender_chat_id = Maybe Int
story_sender_chat_id_
      , story_id :: GetStory -> Maybe Int
story_id             = Maybe Int
story_id_
      , only_local :: GetStory -> Maybe Bool
only_local           = Maybe Bool
only_local_
      }
        = [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
"getStory"
          , Key
"story_sender_chat_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
story_sender_chat_id_
          , Key
"story_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
story_id_
          , Key
"only_local"           Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
only_local_
          ]

defaultGetStory :: GetStory
defaultGetStory :: GetStory
defaultGetStory =
  GetStory
    { story_sender_chat_id :: Maybe Int
story_sender_chat_id = Maybe Int
forall a. Maybe a
Nothing
    , story_id :: Maybe Int
story_id             = Maybe Int
forall a. Maybe a
Nothing
    , only_local :: Maybe Bool
only_local           = Maybe Bool
forall a. Maybe a
Nothing
    }