module TD.Query.MintGift
  (MintGift(..)
  , defaultMintGift
  ) 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

-- | Mints an upgraded gift as an NFT on the TON blockchain and sends the 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. Minting is irreversible. The NFT will be received by the wallet in a few seconds after the request succeeds. Returns 'TD.Data.Ok.Ok'
data MintGift
  = MintGift
    { MintGift -> Maybe Text
received_gift_id :: Maybe T.Text -- ^ Identifier of the gift
    , MintGift -> 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 minting
    }
  deriving (MintGift -> MintGift -> Bool
(MintGift -> MintGift -> Bool)
-> (MintGift -> MintGift -> Bool) -> Eq MintGift
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MintGift -> MintGift -> Bool
== :: MintGift -> MintGift -> Bool
$c/= :: MintGift -> MintGift -> Bool
/= :: MintGift -> MintGift -> Bool
Eq, Int -> MintGift -> ShowS
[MintGift] -> ShowS
MintGift -> String
(Int -> MintGift -> ShowS)
-> (MintGift -> String) -> ([MintGift] -> ShowS) -> Show MintGift
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MintGift -> ShowS
showsPrec :: Int -> MintGift -> ShowS
$cshow :: MintGift -> String
show :: MintGift -> String
$cshowList :: [MintGift] -> ShowS
showList :: [MintGift] -> ShowS
Show)

instance I.ShortShow MintGift where
  shortShow :: MintGift -> String
shortShow
    MintGift
      { received_gift_id :: MintGift -> Maybe Text
received_gift_id = Maybe Text
received_gift_id_
      , keep_on_profile :: MintGift -> Maybe Bool
keep_on_profile  = Maybe Bool
keep_on_profile_
      }
        = String
"MintGift"
          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 MintGift where
  toJSON :: MintGift -> Value
toJSON
    MintGift
      { received_gift_id :: MintGift -> Maybe Text
received_gift_id = Maybe Text
received_gift_id_
      , keep_on_profile :: MintGift -> 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
"mintGift"
          , 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_
          ]

defaultMintGift :: MintGift
defaultMintGift :: MintGift
defaultMintGift =
  MintGift
    { 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
    }