module TD.Query.SellGift
  (SellGift(..)
  , defaultSellGift
  ) where

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

-- | Sells a gift received by the current user for Telegram Stars. Returns 'TD.Data.Ok.Ok'
data SellGift
  = SellGift
    { SellGift -> Maybe Int
sender_user_id :: Maybe Int -- ^ Identifier of the user that sent the gift
    , SellGift -> Maybe Int
message_id     :: Maybe Int -- ^ Identifier of the message with the gift in the chat with the user
    }
  deriving (SellGift -> SellGift -> Bool
(SellGift -> SellGift -> Bool)
-> (SellGift -> SellGift -> Bool) -> Eq SellGift
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SellGift -> SellGift -> Bool
== :: SellGift -> SellGift -> Bool
$c/= :: SellGift -> SellGift -> Bool
/= :: SellGift -> SellGift -> Bool
Eq, Int -> SellGift -> ShowS
[SellGift] -> ShowS
SellGift -> String
(Int -> SellGift -> ShowS)
-> (SellGift -> String) -> ([SellGift] -> ShowS) -> Show SellGift
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SellGift -> ShowS
showsPrec :: Int -> SellGift -> ShowS
$cshow :: SellGift -> String
show :: SellGift -> String
$cshowList :: [SellGift] -> ShowS
showList :: [SellGift] -> ShowS
Show)

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

instance AT.ToJSON SellGift where
  toJSON :: SellGift -> Value
toJSON
    SellGift
      { sender_user_id :: SellGift -> Maybe Int
sender_user_id = Maybe Int
sender_user_id_
      , message_id :: SellGift -> 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
"sellGift"
          , Key
"sender_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
sender_user_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_
          ]

defaultSellGift :: SellGift
defaultSellGift :: SellGift
defaultSellGift =
  SellGift
    { sender_user_id :: Maybe Int
sender_user_id = Maybe Int
forall a. Maybe a
Nothing
    , message_id :: Maybe Int
message_id     = Maybe Int
forall a. Maybe a
Nothing
    }