module TD.Query.SetStoryReaction
  (SetStoryReaction(..)
  , defaultSetStoryReaction
  ) 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

-- | Changes chosen reaction on a story that has already been sent. Returns 'TD.Data.Ok.Ok'
data SetStoryReaction
  = SetStoryReaction
    { SetStoryReaction -> Maybe Int
story_sender_chat_id    :: Maybe Int                       -- ^ The identifier of the sender of the story
    , SetStoryReaction -> Maybe Int
story_id                :: Maybe Int                       -- ^ The identifier of the story
    , SetStoryReaction -> Maybe ReactionType
reaction_type           :: Maybe ReactionType.ReactionType -- ^ Type of the reaction to set; pass null to remove the reaction. Custom emoji reactions can be used only by Telegram Premium users. Paid reactions can't be set
    , SetStoryReaction -> Maybe Bool
update_recent_reactions :: Maybe Bool                      -- ^ Pass true if the reaction needs to be added to recent reactions
    }
  deriving (SetStoryReaction -> SetStoryReaction -> Bool
(SetStoryReaction -> SetStoryReaction -> Bool)
-> (SetStoryReaction -> SetStoryReaction -> Bool)
-> Eq SetStoryReaction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetStoryReaction -> SetStoryReaction -> Bool
== :: SetStoryReaction -> SetStoryReaction -> Bool
$c/= :: SetStoryReaction -> SetStoryReaction -> Bool
/= :: SetStoryReaction -> SetStoryReaction -> Bool
Eq, Int -> SetStoryReaction -> ShowS
[SetStoryReaction] -> ShowS
SetStoryReaction -> String
(Int -> SetStoryReaction -> ShowS)
-> (SetStoryReaction -> String)
-> ([SetStoryReaction] -> ShowS)
-> Show SetStoryReaction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetStoryReaction -> ShowS
showsPrec :: Int -> SetStoryReaction -> ShowS
$cshow :: SetStoryReaction -> String
show :: SetStoryReaction -> String
$cshowList :: [SetStoryReaction] -> ShowS
showList :: [SetStoryReaction] -> ShowS
Show)

instance I.ShortShow SetStoryReaction where
  shortShow :: SetStoryReaction -> String
shortShow
    SetStoryReaction
      { story_sender_chat_id :: SetStoryReaction -> Maybe Int
story_sender_chat_id    = Maybe Int
story_sender_chat_id_
      , story_id :: SetStoryReaction -> Maybe Int
story_id                = Maybe Int
story_id_
      , reaction_type :: SetStoryReaction -> Maybe ReactionType
reaction_type           = Maybe ReactionType
reaction_type_
      , update_recent_reactions :: SetStoryReaction -> Maybe Bool
update_recent_reactions = Maybe Bool
update_recent_reactions_
      }
        = String
"SetStoryReaction"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"story_sender_chat_id"    String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
story_sender_chat_id_
          , String
"story_id"                String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
story_id_
          , String
"reaction_type"           String -> Maybe ReactionType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ReactionType
reaction_type_
          , String
"update_recent_reactions" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
update_recent_reactions_
          ]

instance AT.ToJSON SetStoryReaction where
  toJSON :: SetStoryReaction -> Value
toJSON
    SetStoryReaction
      { story_sender_chat_id :: SetStoryReaction -> Maybe Int
story_sender_chat_id    = Maybe Int
story_sender_chat_id_
      , story_id :: SetStoryReaction -> Maybe Int
story_id                = Maybe Int
story_id_
      , reaction_type :: SetStoryReaction -> Maybe ReactionType
reaction_type           = Maybe ReactionType
reaction_type_
      , update_recent_reactions :: SetStoryReaction -> Maybe Bool
update_recent_reactions = Maybe Bool
update_recent_reactions_
      }
        = [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
"setStoryReaction"
          , Key
"story_sender_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
story_sender_chat_id_
          , Key
"story_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
story_id_
          , Key
"reaction_type"           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_type_
          , Key
"update_recent_reactions" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
update_recent_reactions_
          ]

defaultSetStoryReaction :: SetStoryReaction
defaultSetStoryReaction :: SetStoryReaction
defaultSetStoryReaction =
  SetStoryReaction
    { story_sender_chat_id :: Maybe Int
story_sender_chat_id    = Maybe Int
forall a. Maybe a
Nothing
    , story_id :: Maybe Int
story_id                = Maybe Int
forall a. Maybe a
Nothing
    , reaction_type :: Maybe ReactionType
reaction_type           = Maybe ReactionType
forall a. Maybe a
Nothing
    , update_recent_reactions :: Maybe Bool
update_recent_reactions = Maybe Bool
forall a. Maybe a
Nothing
    }