module TD.Query.GetStoryStatistics
  (GetStoryStatistics(..)
  , defaultGetStoryStatistics
  ) where

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

-- | Returns detailed statistics about a story. Can be used only if story.can_get_statistics == true. Returns 'TD.Data.StoryStatistics.StoryStatistics'
data GetStoryStatistics
  = GetStoryStatistics
    { GetStoryStatistics -> Maybe Int
chat_id  :: Maybe Int  -- ^ Chat identifier
    , GetStoryStatistics -> Maybe Int
story_id :: Maybe Int  -- ^ Story identifier
    , GetStoryStatistics -> Maybe Bool
is_dark  :: Maybe Bool -- ^ Pass true if a dark theme is used by the application
    }
  deriving (GetStoryStatistics -> GetStoryStatistics -> Bool
(GetStoryStatistics -> GetStoryStatistics -> Bool)
-> (GetStoryStatistics -> GetStoryStatistics -> Bool)
-> Eq GetStoryStatistics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetStoryStatistics -> GetStoryStatistics -> Bool
== :: GetStoryStatistics -> GetStoryStatistics -> Bool
$c/= :: GetStoryStatistics -> GetStoryStatistics -> Bool
/= :: GetStoryStatistics -> GetStoryStatistics -> Bool
Eq, Int -> GetStoryStatistics -> ShowS
[GetStoryStatistics] -> ShowS
GetStoryStatistics -> String
(Int -> GetStoryStatistics -> ShowS)
-> (GetStoryStatistics -> String)
-> ([GetStoryStatistics] -> ShowS)
-> Show GetStoryStatistics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetStoryStatistics -> ShowS
showsPrec :: Int -> GetStoryStatistics -> ShowS
$cshow :: GetStoryStatistics -> String
show :: GetStoryStatistics -> String
$cshowList :: [GetStoryStatistics] -> ShowS
showList :: [GetStoryStatistics] -> ShowS
Show)

instance I.ShortShow GetStoryStatistics where
  shortShow :: GetStoryStatistics -> String
shortShow
    GetStoryStatistics
      { chat_id :: GetStoryStatistics -> Maybe Int
chat_id  = Maybe Int
chat_id_
      , story_id :: GetStoryStatistics -> Maybe Int
story_id = Maybe Int
story_id_
      , is_dark :: GetStoryStatistics -> Maybe Bool
is_dark  = Maybe Bool
is_dark_
      }
        = String
"GetStoryStatistics"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_id"  String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
          , String
"story_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
story_id_
          , String
"is_dark"  String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_dark_
          ]

instance AT.ToJSON GetStoryStatistics where
  toJSON :: GetStoryStatistics -> Value
toJSON
    GetStoryStatistics
      { chat_id :: GetStoryStatistics -> Maybe Int
chat_id  = Maybe Int
chat_id_
      , story_id :: GetStoryStatistics -> Maybe Int
story_id = Maybe Int
story_id_
      , is_dark :: GetStoryStatistics -> Maybe Bool
is_dark  = Maybe Bool
is_dark_
      }
        = [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
"getStoryStatistics"
          , Key
"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
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
"is_dark"  Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_dark_
          ]

defaultGetStoryStatistics :: GetStoryStatistics
defaultGetStoryStatistics :: GetStoryStatistics
defaultGetStoryStatistics =
  GetStoryStatistics
    { chat_id :: Maybe Int
chat_id  = Maybe Int
forall a. Maybe a
Nothing
    , story_id :: Maybe Int
story_id = Maybe Int
forall a. Maybe a
Nothing
    , is_dark :: Maybe Bool
is_dark  = Maybe Bool
forall a. Maybe a
Nothing
    }