module TD.Query.SetDefaultReactionType
  (SetDefaultReactionType(..)
  ) 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 type of default reaction for the current user. Returns 'TD.Data.Ok.Ok'
data SetDefaultReactionType
  = SetDefaultReactionType
    { SetDefaultReactionType -> Maybe ReactionType
reaction_type :: Maybe ReactionType.ReactionType -- ^ New type of the default reaction. The paid reaction can't be set as default
    }
  deriving (SetDefaultReactionType -> SetDefaultReactionType -> Bool
(SetDefaultReactionType -> SetDefaultReactionType -> Bool)
-> (SetDefaultReactionType -> SetDefaultReactionType -> Bool)
-> Eq SetDefaultReactionType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetDefaultReactionType -> SetDefaultReactionType -> Bool
== :: SetDefaultReactionType -> SetDefaultReactionType -> Bool
$c/= :: SetDefaultReactionType -> SetDefaultReactionType -> Bool
/= :: SetDefaultReactionType -> SetDefaultReactionType -> Bool
Eq, Int -> SetDefaultReactionType -> ShowS
[SetDefaultReactionType] -> ShowS
SetDefaultReactionType -> String
(Int -> SetDefaultReactionType -> ShowS)
-> (SetDefaultReactionType -> String)
-> ([SetDefaultReactionType] -> ShowS)
-> Show SetDefaultReactionType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetDefaultReactionType -> ShowS
showsPrec :: Int -> SetDefaultReactionType -> ShowS
$cshow :: SetDefaultReactionType -> String
show :: SetDefaultReactionType -> String
$cshowList :: [SetDefaultReactionType] -> ShowS
showList :: [SetDefaultReactionType] -> ShowS
Show)

instance I.ShortShow SetDefaultReactionType where
  shortShow :: SetDefaultReactionType -> String
shortShow
    SetDefaultReactionType
      { reaction_type :: SetDefaultReactionType -> Maybe ReactionType
reaction_type = Maybe ReactionType
reaction_type_
      }
        = String
"SetDefaultReactionType"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"reaction_type" String -> Maybe ReactionType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ReactionType
reaction_type_
          ]

instance AT.ToJSON SetDefaultReactionType where
  toJSON :: SetDefaultReactionType -> Value
toJSON
    SetDefaultReactionType
      { reaction_type :: SetDefaultReactionType -> Maybe ReactionType
reaction_type = Maybe ReactionType
reaction_type_
      }
        = [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
"setDefaultReactionType"
          , 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_
          ]