module TD.Query.GetChatPostedToChatPageStories
  (GetChatPostedToChatPageStories(..)
  , defaultGetChatPostedToChatPageStories
  ) 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 stories that posted by the given chat to its chat page. If from_story_id == 0, then pinned stories are returned first. Then, 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 GetChatPostedToChatPageStories
  = GetChatPostedToChatPageStories
    { GetChatPostedToChatPageStories -> Maybe Int
chat_id       :: Maybe Int -- ^ Chat identifier
    , GetChatPostedToChatPageStories -> Maybe Int
from_story_id :: Maybe Int -- ^ Identifier of the story starting from which stories must be returned; use 0 to get results from pinned and the newest story
    , GetChatPostedToChatPageStories -> 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 (GetChatPostedToChatPageStories
-> GetChatPostedToChatPageStories -> Bool
(GetChatPostedToChatPageStories
 -> GetChatPostedToChatPageStories -> Bool)
-> (GetChatPostedToChatPageStories
    -> GetChatPostedToChatPageStories -> Bool)
-> Eq GetChatPostedToChatPageStories
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetChatPostedToChatPageStories
-> GetChatPostedToChatPageStories -> Bool
== :: GetChatPostedToChatPageStories
-> GetChatPostedToChatPageStories -> Bool
$c/= :: GetChatPostedToChatPageStories
-> GetChatPostedToChatPageStories -> Bool
/= :: GetChatPostedToChatPageStories
-> GetChatPostedToChatPageStories -> Bool
Eq, Int -> GetChatPostedToChatPageStories -> ShowS
[GetChatPostedToChatPageStories] -> ShowS
GetChatPostedToChatPageStories -> String
(Int -> GetChatPostedToChatPageStories -> ShowS)
-> (GetChatPostedToChatPageStories -> String)
-> ([GetChatPostedToChatPageStories] -> ShowS)
-> Show GetChatPostedToChatPageStories
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetChatPostedToChatPageStories -> ShowS
showsPrec :: Int -> GetChatPostedToChatPageStories -> ShowS
$cshow :: GetChatPostedToChatPageStories -> String
show :: GetChatPostedToChatPageStories -> String
$cshowList :: [GetChatPostedToChatPageStories] -> ShowS
showList :: [GetChatPostedToChatPageStories] -> ShowS
Show)

instance I.ShortShow GetChatPostedToChatPageStories where
  shortShow :: GetChatPostedToChatPageStories -> String
shortShow
    GetChatPostedToChatPageStories
      { chat_id :: GetChatPostedToChatPageStories -> Maybe Int
chat_id       = Maybe Int
chat_id_
      , from_story_id :: GetChatPostedToChatPageStories -> Maybe Int
from_story_id = Maybe Int
from_story_id_
      , limit :: GetChatPostedToChatPageStories -> Maybe Int
limit         = Maybe Int
limit_
      }
        = String
"GetChatPostedToChatPageStories"
          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 GetChatPostedToChatPageStories where
  toJSON :: GetChatPostedToChatPageStories -> Value
toJSON
    GetChatPostedToChatPageStories
      { chat_id :: GetChatPostedToChatPageStories -> Maybe Int
chat_id       = Maybe Int
chat_id_
      , from_story_id :: GetChatPostedToChatPageStories -> Maybe Int
from_story_id = Maybe Int
from_story_id_
      , limit :: GetChatPostedToChatPageStories -> 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
"getChatPostedToChatPageStories"
          , 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_
          ]

defaultGetChatPostedToChatPageStories :: GetChatPostedToChatPageStories
defaultGetChatPostedToChatPageStories :: GetChatPostedToChatPageStories
defaultGetChatPostedToChatPageStories =
  GetChatPostedToChatPageStories
    { 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
    }