module TD.Query.AllowBotToSendMessages
  (AllowBotToSendMessages(..)
  ) where

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

-- | Allows the specified bot to send messages to the user. Returns 'TD.Data.Ok.Ok'
data AllowBotToSendMessages
  = AllowBotToSendMessages
    { AllowBotToSendMessages -> Maybe Int
bot_user_id :: Maybe Int -- ^ Identifier of the target bot
    }
  deriving (AllowBotToSendMessages -> AllowBotToSendMessages -> Bool
(AllowBotToSendMessages -> AllowBotToSendMessages -> Bool)
-> (AllowBotToSendMessages -> AllowBotToSendMessages -> Bool)
-> Eq AllowBotToSendMessages
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AllowBotToSendMessages -> AllowBotToSendMessages -> Bool
== :: AllowBotToSendMessages -> AllowBotToSendMessages -> Bool
$c/= :: AllowBotToSendMessages -> AllowBotToSendMessages -> Bool
/= :: AllowBotToSendMessages -> AllowBotToSendMessages -> Bool
Eq, Int -> AllowBotToSendMessages -> ShowS
[AllowBotToSendMessages] -> ShowS
AllowBotToSendMessages -> String
(Int -> AllowBotToSendMessages -> ShowS)
-> (AllowBotToSendMessages -> String)
-> ([AllowBotToSendMessages] -> ShowS)
-> Show AllowBotToSendMessages
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AllowBotToSendMessages -> ShowS
showsPrec :: Int -> AllowBotToSendMessages -> ShowS
$cshow :: AllowBotToSendMessages -> String
show :: AllowBotToSendMessages -> String
$cshowList :: [AllowBotToSendMessages] -> ShowS
showList :: [AllowBotToSendMessages] -> ShowS
Show)

instance I.ShortShow AllowBotToSendMessages where
  shortShow :: AllowBotToSendMessages -> String
shortShow
    AllowBotToSendMessages
      { bot_user_id :: AllowBotToSendMessages -> Maybe Int
bot_user_id = Maybe Int
bot_user_id_
      }
        = String
"AllowBotToSendMessages"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"bot_user_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
bot_user_id_
          ]

instance AT.ToJSON AllowBotToSendMessages where
  toJSON :: AllowBotToSendMessages -> Value
toJSON
    AllowBotToSendMessages
      { bot_user_id :: AllowBotToSendMessages -> Maybe Int
bot_user_id = Maybe Int
bot_user_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
"allowBotToSendMessages"
          , Key
"bot_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
bot_user_id_
          ]