module TD.Query.CloseGiftAuction
  (CloseGiftAuction(..)
  ) where

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

-- | Informs TDLib that a gift auction was closed by the user. Returns 'TD.Data.Ok.Ok'
data CloseGiftAuction
  = CloseGiftAuction
    { CloseGiftAuction -> Maybe Int
gift_id :: Maybe Int -- ^ Identifier of the gift, which auction was closed
    }
  deriving (CloseGiftAuction -> CloseGiftAuction -> Bool
(CloseGiftAuction -> CloseGiftAuction -> Bool)
-> (CloseGiftAuction -> CloseGiftAuction -> Bool)
-> Eq CloseGiftAuction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CloseGiftAuction -> CloseGiftAuction -> Bool
== :: CloseGiftAuction -> CloseGiftAuction -> Bool
$c/= :: CloseGiftAuction -> CloseGiftAuction -> Bool
/= :: CloseGiftAuction -> CloseGiftAuction -> Bool
Eq, Int -> CloseGiftAuction -> ShowS
[CloseGiftAuction] -> ShowS
CloseGiftAuction -> String
(Int -> CloseGiftAuction -> ShowS)
-> (CloseGiftAuction -> String)
-> ([CloseGiftAuction] -> ShowS)
-> Show CloseGiftAuction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CloseGiftAuction -> ShowS
showsPrec :: Int -> CloseGiftAuction -> ShowS
$cshow :: CloseGiftAuction -> String
show :: CloseGiftAuction -> String
$cshowList :: [CloseGiftAuction] -> ShowS
showList :: [CloseGiftAuction] -> ShowS
Show)

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

instance AT.ToJSON CloseGiftAuction where
  toJSON :: CloseGiftAuction -> Value
toJSON
    CloseGiftAuction
      { gift_id :: CloseGiftAuction -> Maybe Int
gift_id = Maybe Int
gift_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
"closeGiftAuction"
          , Key
"gift_id" Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (Int -> Value) -> Maybe Int -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Value
I.writeInt64  Maybe Int
gift_id_
          ]