module TD.Query.GetUserGift
  (GetUserGift(..)
  ) where

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

-- | Returns information about a gift received or sent by the current user. Returns 'TD.Data.UserGift.UserGift'
data GetUserGift
  = GetUserGift
    { GetUserGift -> Maybe Int
message_id :: Maybe Int -- ^ Identifier of the message with the gift
    }
  deriving (GetUserGift -> GetUserGift -> Bool
(GetUserGift -> GetUserGift -> Bool)
-> (GetUserGift -> GetUserGift -> Bool) -> Eq GetUserGift
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetUserGift -> GetUserGift -> Bool
== :: GetUserGift -> GetUserGift -> Bool
$c/= :: GetUserGift -> GetUserGift -> Bool
/= :: GetUserGift -> GetUserGift -> Bool
Eq, Int -> GetUserGift -> ShowS
[GetUserGift] -> ShowS
GetUserGift -> String
(Int -> GetUserGift -> ShowS)
-> (GetUserGift -> String)
-> ([GetUserGift] -> ShowS)
-> Show GetUserGift
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetUserGift -> ShowS
showsPrec :: Int -> GetUserGift -> ShowS
$cshow :: GetUserGift -> String
show :: GetUserGift -> String
$cshowList :: [GetUserGift] -> ShowS
showList :: [GetUserGift] -> ShowS
Show)

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

instance AT.ToJSON GetUserGift where
  toJSON :: GetUserGift -> Value
toJSON
    GetUserGift
      { message_id :: GetUserGift -> Maybe Int
message_id = Maybe Int
message_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
"getUserGift"
          , 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_
          ]