module TD.Query.SetUserEmojiStatus
  (SetUserEmojiStatus(..)
  , defaultSetUserEmojiStatus
  ) 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.EmojiStatus as EmojiStatus

-- | Changes the emoji status of a user; for bots only. Returns 'TD.Data.Ok.Ok'
data SetUserEmojiStatus
  = SetUserEmojiStatus
    { SetUserEmojiStatus -> Maybe Int
user_id      :: Maybe Int                     -- ^ Identifier of the user
    , SetUserEmojiStatus -> Maybe EmojiStatus
emoji_status :: Maybe EmojiStatus.EmojiStatus -- ^ New emoji status; pass null to switch to the default badge
    }
  deriving (SetUserEmojiStatus -> SetUserEmojiStatus -> Bool
(SetUserEmojiStatus -> SetUserEmojiStatus -> Bool)
-> (SetUserEmojiStatus -> SetUserEmojiStatus -> Bool)
-> Eq SetUserEmojiStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetUserEmojiStatus -> SetUserEmojiStatus -> Bool
== :: SetUserEmojiStatus -> SetUserEmojiStatus -> Bool
$c/= :: SetUserEmojiStatus -> SetUserEmojiStatus -> Bool
/= :: SetUserEmojiStatus -> SetUserEmojiStatus -> Bool
Eq, Int -> SetUserEmojiStatus -> ShowS
[SetUserEmojiStatus] -> ShowS
SetUserEmojiStatus -> String
(Int -> SetUserEmojiStatus -> ShowS)
-> (SetUserEmojiStatus -> String)
-> ([SetUserEmojiStatus] -> ShowS)
-> Show SetUserEmojiStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetUserEmojiStatus -> ShowS
showsPrec :: Int -> SetUserEmojiStatus -> ShowS
$cshow :: SetUserEmojiStatus -> String
show :: SetUserEmojiStatus -> String
$cshowList :: [SetUserEmojiStatus] -> ShowS
showList :: [SetUserEmojiStatus] -> ShowS
Show)

instance I.ShortShow SetUserEmojiStatus where
  shortShow :: SetUserEmojiStatus -> String
shortShow
    SetUserEmojiStatus
      { user_id :: SetUserEmojiStatus -> Maybe Int
user_id      = Maybe Int
user_id_
      , emoji_status :: SetUserEmojiStatus -> Maybe EmojiStatus
emoji_status = Maybe EmojiStatus
emoji_status_
      }
        = String
"SetUserEmojiStatus"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"user_id"      String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_id_
          , String
"emoji_status" String -> Maybe EmojiStatus -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe EmojiStatus
emoji_status_
          ]

instance AT.ToJSON SetUserEmojiStatus where
  toJSON :: SetUserEmojiStatus -> Value
toJSON
    SetUserEmojiStatus
      { user_id :: SetUserEmojiStatus -> Maybe Int
user_id      = Maybe Int
user_id_
      , emoji_status :: SetUserEmojiStatus -> Maybe EmojiStatus
emoji_status = Maybe EmojiStatus
emoji_status_
      }
        = [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
"setUserEmojiStatus"
          , Key
"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
user_id_
          , Key
"emoji_status" Key -> Maybe EmojiStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe EmojiStatus
emoji_status_
          ]

defaultSetUserEmojiStatus :: SetUserEmojiStatus
defaultSetUserEmojiStatus :: SetUserEmojiStatus
defaultSetUserEmojiStatus =
  SetUserEmojiStatus
    { user_id :: Maybe Int
user_id      = Maybe Int
forall a. Maybe a
Nothing
    , emoji_status :: Maybe EmojiStatus
emoji_status = Maybe EmojiStatus
forall a. Maybe a
Nothing
    }