module TD.Query.CanSendStory
  (CanSendStory(..)
  ) 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 send a story on behalf of a chat; requires can_post_stories right for supergroup and channel chats. Returns 'TD.Data.CanSendStoryResult.CanSendStoryResult'
data CanSendStory
  = CanSendStory
    { CanSendStory -> Maybe Int
chat_id :: Maybe Int -- ^ Chat identifier. Pass Saved Messages chat identifier when posting a story on behalf of the current user
    }
  deriving (CanSendStory -> CanSendStory -> Bool
(CanSendStory -> CanSendStory -> Bool)
-> (CanSendStory -> CanSendStory -> Bool) -> Eq CanSendStory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CanSendStory -> CanSendStory -> Bool
== :: CanSendStory -> CanSendStory -> Bool
$c/= :: CanSendStory -> CanSendStory -> Bool
/= :: CanSendStory -> CanSendStory -> Bool
Eq, Int -> CanSendStory -> ShowS
[CanSendStory] -> ShowS
CanSendStory -> String
(Int -> CanSendStory -> ShowS)
-> (CanSendStory -> String)
-> ([CanSendStory] -> ShowS)
-> Show CanSendStory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CanSendStory -> ShowS
showsPrec :: Int -> CanSendStory -> ShowS
$cshow :: CanSendStory -> String
show :: CanSendStory -> String
$cshowList :: [CanSendStory] -> ShowS
showList :: [CanSendStory] -> ShowS
Show)

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