module TD.Query.SendBusinessMessage
  (SendBusinessMessage(..)
  , defaultSendBusinessMessage
  ) 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
import qualified TD.Data.InputMessageReplyTo as InputMessageReplyTo
import qualified TD.Data.ReplyMarkup as ReplyMarkup
import qualified TD.Data.InputMessageContent as InputMessageContent

-- | Sends a message on behalf of a business account; for bots only. Returns the message after it was sent. Returns 'TD.Data.BusinessMessage.BusinessMessage'
data SendBusinessMessage
  = SendBusinessMessage
    { SendBusinessMessage -> Maybe Text
business_connection_id :: Maybe T.Text                                  -- ^ Unique identifier of business connection on behalf of which to send the request
    , SendBusinessMessage -> Maybe Int
chat_id                :: Maybe Int                                     -- ^ Target chat
    , SendBusinessMessage -> Maybe InputMessageReplyTo
reply_to               :: Maybe InputMessageReplyTo.InputMessageReplyTo -- ^ Information about the message to be replied; pass null if none
    , SendBusinessMessage -> Maybe Bool
disable_notification   :: Maybe Bool                                    -- ^ Pass true to disable notification for the message
    , SendBusinessMessage -> Maybe Bool
protect_content        :: Maybe Bool                                    -- ^ Pass true if the content of the message must be protected from forwarding and saving
    , SendBusinessMessage -> Maybe Int
effect_id              :: Maybe Int                                     -- ^ Identifier of the effect to apply to the message
    , SendBusinessMessage -> Maybe ReplyMarkup
reply_markup           :: Maybe ReplyMarkup.ReplyMarkup                 -- ^ Markup for replying to the message; pass null if none
    , SendBusinessMessage -> Maybe InputMessageContent
input_message_content  :: Maybe InputMessageContent.InputMessageContent -- ^ The content of the message to be sent
    }
  deriving (SendBusinessMessage -> SendBusinessMessage -> Bool
(SendBusinessMessage -> SendBusinessMessage -> Bool)
-> (SendBusinessMessage -> SendBusinessMessage -> Bool)
-> Eq SendBusinessMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SendBusinessMessage -> SendBusinessMessage -> Bool
== :: SendBusinessMessage -> SendBusinessMessage -> Bool
$c/= :: SendBusinessMessage -> SendBusinessMessage -> Bool
/= :: SendBusinessMessage -> SendBusinessMessage -> Bool
Eq, Int -> SendBusinessMessage -> ShowS
[SendBusinessMessage] -> ShowS
SendBusinessMessage -> String
(Int -> SendBusinessMessage -> ShowS)
-> (SendBusinessMessage -> String)
-> ([SendBusinessMessage] -> ShowS)
-> Show SendBusinessMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SendBusinessMessage -> ShowS
showsPrec :: Int -> SendBusinessMessage -> ShowS
$cshow :: SendBusinessMessage -> String
show :: SendBusinessMessage -> String
$cshowList :: [SendBusinessMessage] -> ShowS
showList :: [SendBusinessMessage] -> ShowS
Show)

instance I.ShortShow SendBusinessMessage where
  shortShow :: SendBusinessMessage -> String
shortShow
    SendBusinessMessage
      { business_connection_id :: SendBusinessMessage -> Maybe Text
business_connection_id = Maybe Text
business_connection_id_
      , chat_id :: SendBusinessMessage -> Maybe Int
chat_id                = Maybe Int
chat_id_
      , reply_to :: SendBusinessMessage -> Maybe InputMessageReplyTo
reply_to               = Maybe InputMessageReplyTo
reply_to_
      , disable_notification :: SendBusinessMessage -> Maybe Bool
disable_notification   = Maybe Bool
disable_notification_
      , protect_content :: SendBusinessMessage -> Maybe Bool
protect_content        = Maybe Bool
protect_content_
      , effect_id :: SendBusinessMessage -> Maybe Int
effect_id              = Maybe Int
effect_id_
      , reply_markup :: SendBusinessMessage -> Maybe ReplyMarkup
reply_markup           = Maybe ReplyMarkup
reply_markup_
      , input_message_content :: SendBusinessMessage -> Maybe InputMessageContent
input_message_content  = Maybe InputMessageContent
input_message_content_
      }
        = String
"SendBusinessMessage"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"business_connection_id" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
business_connection_id_
          , String
"chat_id"                String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
          , String
"reply_to"               String -> Maybe InputMessageReplyTo -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputMessageReplyTo
reply_to_
          , String
"disable_notification"   String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
disable_notification_
          , String
"protect_content"        String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
protect_content_
          , String
"effect_id"              String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
effect_id_
          , String
"reply_markup"           String -> Maybe ReplyMarkup -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ReplyMarkup
reply_markup_
          , String
"input_message_content"  String -> Maybe InputMessageContent -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputMessageContent
input_message_content_
          ]

instance AT.ToJSON SendBusinessMessage where
  toJSON :: SendBusinessMessage -> Value
toJSON
    SendBusinessMessage
      { business_connection_id :: SendBusinessMessage -> Maybe Text
business_connection_id = Maybe Text
business_connection_id_
      , chat_id :: SendBusinessMessage -> Maybe Int
chat_id                = Maybe Int
chat_id_
      , reply_to :: SendBusinessMessage -> Maybe InputMessageReplyTo
reply_to               = Maybe InputMessageReplyTo
reply_to_
      , disable_notification :: SendBusinessMessage -> Maybe Bool
disable_notification   = Maybe Bool
disable_notification_
      , protect_content :: SendBusinessMessage -> Maybe Bool
protect_content        = Maybe Bool
protect_content_
      , effect_id :: SendBusinessMessage -> Maybe Int
effect_id              = Maybe Int
effect_id_
      , reply_markup :: SendBusinessMessage -> Maybe ReplyMarkup
reply_markup           = Maybe ReplyMarkup
reply_markup_
      , input_message_content :: SendBusinessMessage -> Maybe InputMessageContent
input_message_content  = Maybe InputMessageContent
input_message_content_
      }
        = [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
"sendBusinessMessage"
          , Key
"business_connection_id" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
business_connection_id_
          , 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
"reply_to"               Key -> Maybe InputMessageReplyTo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputMessageReplyTo
reply_to_
          , Key
"disable_notification"   Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
disable_notification_
          , Key
"protect_content"        Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
protect_content_
          , Key
"effect_id"              Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (Int -> Value) -> Maybe Int -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Value
I.writeInt64  Maybe Int
effect_id_
          , Key
"reply_markup"           Key -> Maybe ReplyMarkup -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ReplyMarkup
reply_markup_
          , Key
"input_message_content"  Key -> Maybe InputMessageContent -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputMessageContent
input_message_content_
          ]

defaultSendBusinessMessage :: SendBusinessMessage
defaultSendBusinessMessage :: SendBusinessMessage
defaultSendBusinessMessage =
  SendBusinessMessage
    { business_connection_id :: Maybe Text
business_connection_id = Maybe Text
forall a. Maybe a
Nothing
    , chat_id :: Maybe Int
chat_id                = Maybe Int
forall a. Maybe a
Nothing
    , reply_to :: Maybe InputMessageReplyTo
reply_to               = Maybe InputMessageReplyTo
forall a. Maybe a
Nothing
    , disable_notification :: Maybe Bool
disable_notification   = Maybe Bool
forall a. Maybe a
Nothing
    , protect_content :: Maybe Bool
protect_content        = Maybe Bool
forall a. Maybe a
Nothing
    , effect_id :: Maybe Int
effect_id              = Maybe Int
forall a. Maybe a
Nothing
    , reply_markup :: Maybe ReplyMarkup
reply_markup           = Maybe ReplyMarkup
forall a. Maybe a
Nothing
    , input_message_content :: Maybe InputMessageContent
input_message_content  = Maybe InputMessageContent
forall a. Maybe a
Nothing
    }