module TD.Query.SetMessageReactions
  (SetMessageReactions(..)
  , defaultSetMessageReactions
  ) 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.ReactionType as ReactionType

-- | Sets reactions on a message; for bots only. Returns 'TD.Data.Ok.Ok'
data SetMessageReactions
  = SetMessageReactions
    { SetMessageReactions -> Maybe Int
chat_id        :: Maybe Int                         -- ^ Identifier of the chat to which the message belongs
    , SetMessageReactions -> Maybe Int
message_id     :: Maybe Int                         -- ^ Identifier of the message
    , SetMessageReactions -> Maybe [ReactionType]
reaction_types :: Maybe [ReactionType.ReactionType] -- ^ Types of the reaction to set; pass an empty list to remove the reactions
    , SetMessageReactions -> Maybe Bool
is_big         :: Maybe Bool                        -- ^ Pass true if the reactions are added with a big animation
    }
  deriving (SetMessageReactions -> SetMessageReactions -> Bool
(SetMessageReactions -> SetMessageReactions -> Bool)
-> (SetMessageReactions -> SetMessageReactions -> Bool)
-> Eq SetMessageReactions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetMessageReactions -> SetMessageReactions -> Bool
== :: SetMessageReactions -> SetMessageReactions -> Bool
$c/= :: SetMessageReactions -> SetMessageReactions -> Bool
/= :: SetMessageReactions -> SetMessageReactions -> Bool
Eq, Int -> SetMessageReactions -> ShowS
[SetMessageReactions] -> ShowS
SetMessageReactions -> String
(Int -> SetMessageReactions -> ShowS)
-> (SetMessageReactions -> String)
-> ([SetMessageReactions] -> ShowS)
-> Show SetMessageReactions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetMessageReactions -> ShowS
showsPrec :: Int -> SetMessageReactions -> ShowS
$cshow :: SetMessageReactions -> String
show :: SetMessageReactions -> String
$cshowList :: [SetMessageReactions] -> ShowS
showList :: [SetMessageReactions] -> ShowS
Show)

instance I.ShortShow SetMessageReactions where
  shortShow :: SetMessageReactions -> String
shortShow
    SetMessageReactions
      { chat_id :: SetMessageReactions -> Maybe Int
chat_id        = Maybe Int
chat_id_
      , message_id :: SetMessageReactions -> Maybe Int
message_id     = Maybe Int
message_id_
      , reaction_types :: SetMessageReactions -> Maybe [ReactionType]
reaction_types = Maybe [ReactionType]
reaction_types_
      , is_big :: SetMessageReactions -> Maybe Bool
is_big         = Maybe Bool
is_big_
      }
        = String
"SetMessageReactions"
          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_id"     String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
message_id_
          , String
"reaction_types" String -> Maybe [ReactionType] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [ReactionType]
reaction_types_
          , String
"is_big"         String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_big_
          ]

instance AT.ToJSON SetMessageReactions where
  toJSON :: SetMessageReactions -> Value
toJSON
    SetMessageReactions
      { chat_id :: SetMessageReactions -> Maybe Int
chat_id        = Maybe Int
chat_id_
      , message_id :: SetMessageReactions -> Maybe Int
message_id     = Maybe Int
message_id_
      , reaction_types :: SetMessageReactions -> Maybe [ReactionType]
reaction_types = Maybe [ReactionType]
reaction_types_
      , is_big :: SetMessageReactions -> Maybe Bool
is_big         = Maybe Bool
is_big_
      }
        = [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
"setMessageReactions"
          , 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_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_id_
          , Key
"reaction_types" Key -> Maybe [ReactionType] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [ReactionType]
reaction_types_
          , Key
"is_big"         Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_big_
          ]

defaultSetMessageReactions :: SetMessageReactions
defaultSetMessageReactions :: SetMessageReactions
defaultSetMessageReactions =
  SetMessageReactions
    { chat_id :: Maybe Int
chat_id        = Maybe Int
forall a. Maybe a
Nothing
    , message_id :: Maybe Int
message_id     = Maybe Int
forall a. Maybe a
Nothing
    , reaction_types :: Maybe [ReactionType]
reaction_types = Maybe [ReactionType]
forall a. Maybe a
Nothing
    , is_big :: Maybe Bool
is_big         = Maybe Bool
forall a. Maybe a
Nothing
    }