module TD.Query.GetChatArchivedStories
  (GetChatArchivedStories(..)
  , defaultGetChatArchivedStories
  ) where

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

-- | Returns the list of all stories posted by the given chat; requires can_edit_stories administrator right in the chat. The stories are returned in reverse chronological order (i.e., in order of decreasing story.id). For optimal performance, the number of returned stories is chosen by TDLib. Returns 'TD.Data.Stories.Stories'
data GetChatArchivedStories
  = GetChatArchivedStories
    { GetChatArchivedStories -> Maybe Int
chat_id       :: Maybe Int -- ^ Chat identifier
    , GetChatArchivedStories -> Maybe Int
from_story_id :: Maybe Int -- ^ Identifier of the story starting from which stories must be returned; use 0 to get results from the last story
    , GetChatArchivedStories -> Maybe Int
limit         :: Maybe Int -- ^ The maximum number of stories to be returned. For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit
    }
  deriving (GetChatArchivedStories -> GetChatArchivedStories -> Bool
(GetChatArchivedStories -> GetChatArchivedStories -> Bool)
-> (GetChatArchivedStories -> GetChatArchivedStories -> Bool)
-> Eq GetChatArchivedStories
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetChatArchivedStories -> GetChatArchivedStories -> Bool
== :: GetChatArchivedStories -> GetChatArchivedStories -> Bool
$c/= :: GetChatArchivedStories -> GetChatArchivedStories -> Bool
/= :: GetChatArchivedStories -> GetChatArchivedStories -> Bool
Eq, Int -> GetChatArchivedStories -> ShowS
[GetChatArchivedStories] -> ShowS
GetChatArchivedStories -> String
(Int -> GetChatArchivedStories -> ShowS)
-> (GetChatArchivedStories -> String)
-> ([GetChatArchivedStories] -> ShowS)
-> Show GetChatArchivedStories
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetChatArchivedStories -> ShowS
showsPrec :: Int -> GetChatArchivedStories -> ShowS
$cshow :: GetChatArchivedStories -> String
show :: GetChatArchivedStories -> String
$cshowList :: [GetChatArchivedStories] -> ShowS
showList :: [GetChatArchivedStories] -> ShowS
Show)

instance I.ShortShow GetChatArchivedStories where
  shortShow :: GetChatArchivedStories -> String
shortShow
    GetChatArchivedStories
      { chat_id :: GetChatArchivedStories -> Maybe Int
chat_id       = Maybe Int
chat_id_
      , from_story_id :: GetChatArchivedStories -> Maybe Int
from_story_id = Maybe Int
from_story_id_
      , limit :: GetChatArchivedStories -> Maybe Int
limit         = Maybe Int
limit_
      }
        = String
"GetChatArchivedStories"
          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
"from_story_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
from_story_id_
          , String
"limit"         String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

instance AT.ToJSON GetChatArchivedStories where
  toJSON :: GetChatArchivedStories -> Value
toJSON
    GetChatArchivedStories
      { chat_id :: GetChatArchivedStories -> Maybe Int
chat_id       = Maybe Int
chat_id_
      , from_story_id :: GetChatArchivedStories -> Maybe Int
from_story_id = Maybe Int
from_story_id_
      , limit :: GetChatArchivedStories -> Maybe Int
limit         = Maybe Int
limit_
      }
        = [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
"getChatArchivedStories"
          , 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
"from_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
from_story_id_
          , Key
"limit"         Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
limit_
          ]

defaultGetChatArchivedStories :: GetChatArchivedStories
defaultGetChatArchivedStories :: GetChatArchivedStories
defaultGetChatArchivedStories =
  GetChatArchivedStories
    { chat_id :: Maybe Int
chat_id       = Maybe Int
forall a. Maybe a
Nothing
    , from_story_id :: Maybe Int
from_story_id = Maybe Int
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit         = Maybe Int
forall a. Maybe a
Nothing
    }