module TD.Query.CraftGift
  (CraftGift(..)
  ) 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

-- | Crafts a new gift from other gifts that will be permanently lost. Returns 'TD.Data.CraftGiftResult.CraftGiftResult'
data CraftGift
  = CraftGift
    { CraftGift -> Maybe [Text]
received_gift_ids :: Maybe [T.Text] -- ^ Identifier of the gifts to use for crafting. In the case of a successful craft, the resulting gift will have the number of the first gift. Consequently, unless getOption("can_craft_from_withdrawn_first_gift") is true, the first gift must not have been withdrawn to the TON blockchain as an NFT and must have an empty gift_address
    }
  deriving (CraftGift -> CraftGift -> Bool
(CraftGift -> CraftGift -> Bool)
-> (CraftGift -> CraftGift -> Bool) -> Eq CraftGift
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CraftGift -> CraftGift -> Bool
== :: CraftGift -> CraftGift -> Bool
$c/= :: CraftGift -> CraftGift -> Bool
/= :: CraftGift -> CraftGift -> Bool
Eq, Int -> CraftGift -> ShowS
[CraftGift] -> ShowS
CraftGift -> String
(Int -> CraftGift -> ShowS)
-> (CraftGift -> String)
-> ([CraftGift] -> ShowS)
-> Show CraftGift
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CraftGift -> ShowS
showsPrec :: Int -> CraftGift -> ShowS
$cshow :: CraftGift -> String
show :: CraftGift -> String
$cshowList :: [CraftGift] -> ShowS
showList :: [CraftGift] -> ShowS
Show)

instance I.ShortShow CraftGift where
  shortShow :: CraftGift -> String
shortShow
    CraftGift
      { received_gift_ids :: CraftGift -> Maybe [Text]
received_gift_ids = Maybe [Text]
received_gift_ids_
      }
        = String
"CraftGift"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"received_gift_ids" String -> Maybe [Text] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Text]
received_gift_ids_
          ]

instance AT.ToJSON CraftGift where
  toJSON :: CraftGift -> Value
toJSON
    CraftGift
      { received_gift_ids :: CraftGift -> Maybe [Text]
received_gift_ids = Maybe [Text]
received_gift_ids_
      }
        = [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
"craftGift"
          , Key
"received_gift_ids" 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_ids_
          ]