module TD.Query.SavePreparedInlineMessage
  (SavePreparedInlineMessage(..)
  , defaultSavePreparedInlineMessage
  ) where

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

-- | Saves an inline message to be sent by the given user; for bots only. Returns 'TD.Data.PreparedInlineMessageId.PreparedInlineMessageId'
data SavePreparedInlineMessage
  = SavePreparedInlineMessage
    { SavePreparedInlineMessage -> Maybe Int
user_id    :: Maybe Int                                           -- ^ Identifier of the user
    , SavePreparedInlineMessage -> Maybe InputInlineQueryResult
result     :: Maybe InputInlineQueryResult.InputInlineQueryResult -- ^ The description of the message
    , SavePreparedInlineMessage -> Maybe TargetChatTypes
chat_types :: Maybe TargetChatTypes.TargetChatTypes               -- ^ Types of the chats to which the message can be sent
    }
  deriving (SavePreparedInlineMessage -> SavePreparedInlineMessage -> Bool
(SavePreparedInlineMessage -> SavePreparedInlineMessage -> Bool)
-> (SavePreparedInlineMessage -> SavePreparedInlineMessage -> Bool)
-> Eq SavePreparedInlineMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SavePreparedInlineMessage -> SavePreparedInlineMessage -> Bool
== :: SavePreparedInlineMessage -> SavePreparedInlineMessage -> Bool
$c/= :: SavePreparedInlineMessage -> SavePreparedInlineMessage -> Bool
/= :: SavePreparedInlineMessage -> SavePreparedInlineMessage -> Bool
Eq, Int -> SavePreparedInlineMessage -> ShowS
[SavePreparedInlineMessage] -> ShowS
SavePreparedInlineMessage -> String
(Int -> SavePreparedInlineMessage -> ShowS)
-> (SavePreparedInlineMessage -> String)
-> ([SavePreparedInlineMessage] -> ShowS)
-> Show SavePreparedInlineMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SavePreparedInlineMessage -> ShowS
showsPrec :: Int -> SavePreparedInlineMessage -> ShowS
$cshow :: SavePreparedInlineMessage -> String
show :: SavePreparedInlineMessage -> String
$cshowList :: [SavePreparedInlineMessage] -> ShowS
showList :: [SavePreparedInlineMessage] -> ShowS
Show)

instance I.ShortShow SavePreparedInlineMessage where
  shortShow :: SavePreparedInlineMessage -> String
shortShow
    SavePreparedInlineMessage
      { user_id :: SavePreparedInlineMessage -> Maybe Int
user_id    = Maybe Int
user_id_
      , result :: SavePreparedInlineMessage -> Maybe InputInlineQueryResult
result     = Maybe InputInlineQueryResult
result_
      , chat_types :: SavePreparedInlineMessage -> Maybe TargetChatTypes
chat_types = Maybe TargetChatTypes
chat_types_
      }
        = String
"SavePreparedInlineMessage"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"user_id"    String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_id_
          , String
"result"     String -> Maybe InputInlineQueryResult -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputInlineQueryResult
result_
          , String
"chat_types" String -> Maybe TargetChatTypes -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe TargetChatTypes
chat_types_
          ]

instance AT.ToJSON SavePreparedInlineMessage where
  toJSON :: SavePreparedInlineMessage -> Value
toJSON
    SavePreparedInlineMessage
      { user_id :: SavePreparedInlineMessage -> Maybe Int
user_id    = Maybe Int
user_id_
      , result :: SavePreparedInlineMessage -> Maybe InputInlineQueryResult
result     = Maybe InputInlineQueryResult
result_
      , chat_types :: SavePreparedInlineMessage -> Maybe TargetChatTypes
chat_types = Maybe TargetChatTypes
chat_types_
      }
        = [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
"savePreparedInlineMessage"
          , Key
"user_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
user_id_
          , Key
"result"     Key -> Maybe InputInlineQueryResult -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputInlineQueryResult
result_
          , Key
"chat_types" Key -> Maybe TargetChatTypes -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe TargetChatTypes
chat_types_
          ]

defaultSavePreparedInlineMessage :: SavePreparedInlineMessage
defaultSavePreparedInlineMessage :: SavePreparedInlineMessage
defaultSavePreparedInlineMessage =
  SavePreparedInlineMessage
    { user_id :: Maybe Int
user_id    = Maybe Int
forall a. Maybe a
Nothing
    , result :: Maybe InputInlineQueryResult
result     = Maybe InputInlineQueryResult
forall a. Maybe a
Nothing
    , chat_types :: Maybe TargetChatTypes
chat_types = Maybe TargetChatTypes
forall a. Maybe a
Nothing
    }