module TD.Query.SendChatAction
  (SendChatAction(..)
  , defaultSendChatAction
  ) 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.ChatAction as ChatAction

-- | Sends a notification about user activity in a chat. Returns 'TD.Data.Ok.Ok'
data SendChatAction
  = SendChatAction
    { SendChatAction -> Maybe Int
chat_id                :: Maybe Int                   -- ^ Chat identifier
    , SendChatAction -> Maybe Int
message_thread_id      :: Maybe Int                   -- ^ If not 0, the message thread identifier in which the action was performed
    , SendChatAction -> Maybe Text
business_connection_id :: Maybe T.Text                -- ^ Unique identifier of business connection on behalf of which to send the request; for bots only
    , SendChatAction -> Maybe ChatAction
action                 :: Maybe ChatAction.ChatAction -- ^ The action description; pass null to cancel the currently active action
    }
  deriving (SendChatAction -> SendChatAction -> Bool
(SendChatAction -> SendChatAction -> Bool)
-> (SendChatAction -> SendChatAction -> Bool) -> Eq SendChatAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SendChatAction -> SendChatAction -> Bool
== :: SendChatAction -> SendChatAction -> Bool
$c/= :: SendChatAction -> SendChatAction -> Bool
/= :: SendChatAction -> SendChatAction -> Bool
Eq, Int -> SendChatAction -> ShowS
[SendChatAction] -> ShowS
SendChatAction -> String
(Int -> SendChatAction -> ShowS)
-> (SendChatAction -> String)
-> ([SendChatAction] -> ShowS)
-> Show SendChatAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SendChatAction -> ShowS
showsPrec :: Int -> SendChatAction -> ShowS
$cshow :: SendChatAction -> String
show :: SendChatAction -> String
$cshowList :: [SendChatAction] -> ShowS
showList :: [SendChatAction] -> ShowS
Show)

instance I.ShortShow SendChatAction where
  shortShow :: SendChatAction -> String
shortShow
    SendChatAction
      { chat_id :: SendChatAction -> Maybe Int
chat_id                = Maybe Int
chat_id_
      , message_thread_id :: SendChatAction -> Maybe Int
message_thread_id      = Maybe Int
message_thread_id_
      , business_connection_id :: SendChatAction -> Maybe Text
business_connection_id = Maybe Text
business_connection_id_
      , action :: SendChatAction -> Maybe ChatAction
action                 = Maybe ChatAction
action_
      }
        = String
"SendChatAction"
          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_
          , String
"message_thread_id"      String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
message_thread_id_
          , String
"business_connection_id" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
business_connection_id_
          , String
"action"                 String -> Maybe ChatAction -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatAction
action_
          ]

instance AT.ToJSON SendChatAction where
  toJSON :: SendChatAction -> Value
toJSON
    SendChatAction
      { chat_id :: SendChatAction -> Maybe Int
chat_id                = Maybe Int
chat_id_
      , message_thread_id :: SendChatAction -> Maybe Int
message_thread_id      = Maybe Int
message_thread_id_
      , business_connection_id :: SendChatAction -> Maybe Text
business_connection_id = Maybe Text
business_connection_id_
      , action :: SendChatAction -> Maybe ChatAction
action                 = Maybe ChatAction
action_
      }
        = [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
"sendChatAction"
          , 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
"message_thread_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
message_thread_id_
          , 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
"action"                 Key -> Maybe ChatAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ChatAction
action_
          ]

defaultSendChatAction :: SendChatAction
defaultSendChatAction :: SendChatAction
defaultSendChatAction =
  SendChatAction
    { chat_id :: Maybe Int
chat_id                = Maybe Int
forall a. Maybe a
Nothing
    , message_thread_id :: Maybe Int
message_thread_id      = Maybe Int
forall a. Maybe a
Nothing
    , business_connection_id :: Maybe Text
business_connection_id = Maybe Text
forall a. Maybe a
Nothing
    , action :: Maybe ChatAction
action                 = Maybe ChatAction
forall a. Maybe a
Nothing
    }