module TD.Query.WithdrawUpgradedGift
  (WithdrawUpgradedGift(..)
  , defaultWithdrawUpgradedGift
  ) where

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

-- | Withdraws an upgraded gift to the TON blockchain as an NFT directly to the TON wallet of the current user, which is created automatically if the user has no wallet yet; requires owner privileges for gifts owned by a chat. The user must have a valid temporary password; see createTemporaryPassword. The gift will be received by the wallet in a few seconds after the request succeeds. Returns 'TD.Data.Ok.Ok'
data WithdrawUpgradedGift
  = WithdrawUpgradedGift
    { WithdrawUpgradedGift -> Maybe Text
received_gift_id :: Maybe T.Text -- ^ Identifier of the gift
    , WithdrawUpgradedGift -> Maybe Bool
keep_on_profile  :: Maybe Bool   -- ^ Pass true to keep the gift displayed on the user's or the chat's profile page after withdrawal
    }
  deriving (WithdrawUpgradedGift -> WithdrawUpgradedGift -> Bool
(WithdrawUpgradedGift -> WithdrawUpgradedGift -> Bool)
-> (WithdrawUpgradedGift -> WithdrawUpgradedGift -> Bool)
-> Eq WithdrawUpgradedGift
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: WithdrawUpgradedGift -> WithdrawUpgradedGift -> Bool
== :: WithdrawUpgradedGift -> WithdrawUpgradedGift -> Bool
$c/= :: WithdrawUpgradedGift -> WithdrawUpgradedGift -> Bool
/= :: WithdrawUpgradedGift -> WithdrawUpgradedGift -> Bool
Eq, Int -> WithdrawUpgradedGift -> ShowS
[WithdrawUpgradedGift] -> ShowS
WithdrawUpgradedGift -> String
(Int -> WithdrawUpgradedGift -> ShowS)
-> (WithdrawUpgradedGift -> String)
-> ([WithdrawUpgradedGift] -> ShowS)
-> Show WithdrawUpgradedGift
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> WithdrawUpgradedGift -> ShowS
showsPrec :: Int -> WithdrawUpgradedGift -> ShowS
$cshow :: WithdrawUpgradedGift -> String
show :: WithdrawUpgradedGift -> String
$cshowList :: [WithdrawUpgradedGift] -> ShowS
showList :: [WithdrawUpgradedGift] -> ShowS
Show)

instance I.ShortShow WithdrawUpgradedGift where
  shortShow :: WithdrawUpgradedGift -> String
shortShow
    WithdrawUpgradedGift
      { received_gift_id :: WithdrawUpgradedGift -> Maybe Text
received_gift_id = Maybe Text
received_gift_id_
      , keep_on_profile :: WithdrawUpgradedGift -> Maybe Bool
keep_on_profile  = Maybe Bool
keep_on_profile_
      }
        = String
"WithdrawUpgradedGift"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"received_gift_id" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
received_gift_id_
          , String
"keep_on_profile"  String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
keep_on_profile_
          ]

instance AT.ToJSON WithdrawUpgradedGift where
  toJSON :: WithdrawUpgradedGift -> Value
toJSON
    WithdrawUpgradedGift
      { received_gift_id :: WithdrawUpgradedGift -> Maybe Text
received_gift_id = Maybe Text
received_gift_id_
      , keep_on_profile :: WithdrawUpgradedGift -> Maybe Bool
keep_on_profile  = Maybe Bool
keep_on_profile_
      }
        = [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
"withdrawUpgradedGift"
          , Key
"received_gift_id" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
received_gift_id_
          , Key
"keep_on_profile"  Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
keep_on_profile_
          ]

defaultWithdrawUpgradedGift :: WithdrawUpgradedGift
defaultWithdrawUpgradedGift :: WithdrawUpgradedGift
defaultWithdrawUpgradedGift =
  WithdrawUpgradedGift
    { received_gift_id :: Maybe Text
received_gift_id = Maybe Text
forall a. Maybe a
Nothing
    , keep_on_profile :: Maybe Bool
keep_on_profile  = Maybe Bool
forall a. Maybe a
Nothing
    }