module TD.Query.CanPostStory
  (CanPostStory(..)
  ) where

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

-- | Checks whether the current user can post a story on behalf of a chat; requires can_post_stories administrator right for supergroup and channel chats. Returns 'TD.Data.CanPostStoryResult.CanPostStoryResult'
data CanPostStory
  = CanPostStory
    { CanPostStory -> Maybe Int
chat_id :: Maybe Int -- ^ Chat identifier. Pass Saved Messages chat identifier when posting a story on behalf of the current user
    }
  deriving (CanPostStory -> CanPostStory -> Bool
(CanPostStory -> CanPostStory -> Bool)
-> (CanPostStory -> CanPostStory -> Bool) -> Eq CanPostStory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CanPostStory -> CanPostStory -> Bool
== :: CanPostStory -> CanPostStory -> Bool
$c/= :: CanPostStory -> CanPostStory -> Bool
/= :: CanPostStory -> CanPostStory -> Bool
Eq, Int -> CanPostStory -> ShowS
[CanPostStory] -> ShowS
CanPostStory -> String
(Int -> CanPostStory -> ShowS)
-> (CanPostStory -> String)
-> ([CanPostStory] -> ShowS)
-> Show CanPostStory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CanPostStory -> ShowS
showsPrec :: Int -> CanPostStory -> ShowS
$cshow :: CanPostStory -> String
show :: CanPostStory -> String
$cshowList :: [CanPostStory] -> ShowS
showList :: [CanPostStory] -> ShowS
Show)

instance I.ShortShow CanPostStory where
  shortShow :: CanPostStory -> String
shortShow
    CanPostStory
      { chat_id :: CanPostStory -> Maybe Int
chat_id = Maybe Int
chat_id_
      }
        = String
"CanPostStory"
          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_
          ]

instance AT.ToJSON CanPostStory where
  toJSON :: CanPostStory -> Value
toJSON
    CanPostStory
      { chat_id :: CanPostStory -> Maybe Int
chat_id = Maybe Int
chat_id_
      }
        = [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
"canPostStory"
          , 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_
          ]