module TD.Query.GetStoryPublicForwards
  (GetStoryPublicForwards(..)
  , defaultGetStoryPublicForwards
  ) 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 forwards of a story as a message to public chats and reposts by public channels. Can be used only if the story is posted on behalf of the current user or story.can_get_statistics == true. For optimal performance, the number of returned messages and stories is chosen by TDLib. Returns 'TD.Data.PublicForwards.PublicForwards'
data GetStoryPublicForwards
  = GetStoryPublicForwards
    { GetStoryPublicForwards -> Maybe Int
story_sender_chat_id :: Maybe Int    -- ^ The identifier of the sender of the story
    , GetStoryPublicForwards -> Maybe Int
story_id             :: Maybe Int    -- ^ The identifier of the story
    , GetStoryPublicForwards -> Maybe Text
offset               :: Maybe T.Text -- ^ Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results
    , GetStoryPublicForwards -> Maybe Int
limit                :: Maybe Int    -- ^ The maximum number of messages and stories to be returned; must be positive and can't be greater than 100. For optimal performance, the number of returned objects is chosen by TDLib and can be smaller than the specified limit
    }
  deriving (GetStoryPublicForwards -> GetStoryPublicForwards -> Bool
(GetStoryPublicForwards -> GetStoryPublicForwards -> Bool)
-> (GetStoryPublicForwards -> GetStoryPublicForwards -> Bool)
-> Eq GetStoryPublicForwards
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetStoryPublicForwards -> GetStoryPublicForwards -> Bool
== :: GetStoryPublicForwards -> GetStoryPublicForwards -> Bool
$c/= :: GetStoryPublicForwards -> GetStoryPublicForwards -> Bool
/= :: GetStoryPublicForwards -> GetStoryPublicForwards -> Bool
Eq, Int -> GetStoryPublicForwards -> ShowS
[GetStoryPublicForwards] -> ShowS
GetStoryPublicForwards -> String
(Int -> GetStoryPublicForwards -> ShowS)
-> (GetStoryPublicForwards -> String)
-> ([GetStoryPublicForwards] -> ShowS)
-> Show GetStoryPublicForwards
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetStoryPublicForwards -> ShowS
showsPrec :: Int -> GetStoryPublicForwards -> ShowS
$cshow :: GetStoryPublicForwards -> String
show :: GetStoryPublicForwards -> String
$cshowList :: [GetStoryPublicForwards] -> ShowS
showList :: [GetStoryPublicForwards] -> ShowS
Show)

instance I.ShortShow GetStoryPublicForwards where
  shortShow :: GetStoryPublicForwards -> String
shortShow
    GetStoryPublicForwards
      { story_sender_chat_id :: GetStoryPublicForwards -> Maybe Int
story_sender_chat_id = Maybe Int
story_sender_chat_id_
      , story_id :: GetStoryPublicForwards -> Maybe Int
story_id             = Maybe Int
story_id_
      , offset :: GetStoryPublicForwards -> Maybe Text
offset               = Maybe Text
offset_
      , limit :: GetStoryPublicForwards -> Maybe Int
limit                = Maybe Int
limit_
      }
        = String
"GetStoryPublicForwards"
          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
"offset"               String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
offset_
          , String
"limit"                String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

instance AT.ToJSON GetStoryPublicForwards where
  toJSON :: GetStoryPublicForwards -> Value
toJSON
    GetStoryPublicForwards
      { story_sender_chat_id :: GetStoryPublicForwards -> Maybe Int
story_sender_chat_id = Maybe Int
story_sender_chat_id_
      , story_id :: GetStoryPublicForwards -> Maybe Int
story_id             = Maybe Int
story_id_
      , offset :: GetStoryPublicForwards -> Maybe Text
offset               = Maybe Text
offset_
      , limit :: GetStoryPublicForwards -> 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
"getStoryPublicForwards"
          , 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
"offset"               Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
offset_
          , 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_
          ]

defaultGetStoryPublicForwards :: GetStoryPublicForwards
defaultGetStoryPublicForwards :: GetStoryPublicForwards
defaultGetStoryPublicForwards =
  GetStoryPublicForwards
    { 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
    , offset :: Maybe Text
offset               = Maybe Text
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit                = Maybe Int
forall a. Maybe a
Nothing
    }