module TD.Query.SetTonWalletCardStickers
  (SetTonWalletCardStickers(..)
  , defaultSetTonWalletCardStickers
  ) where

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

-- | Changes the list of stickers on the TON wallet card of the current user; can be used only if getOption("can_use_ton_wallet"). The whole list of stickers is replaced. The request can take up to 20 seconds to complete, so it must be called only on explicit user action. Stickers are removed automatically if the corresponding NFT leaves the wallet or the wallet is replaced. Returns the updated card. Returns 'TD.Data.TonWalletCard.TonWalletCard'
data SetTonWalletCardStickers
  = SetTonWalletCardStickers
    { SetTonWalletCardStickers -> Maybe [InputTonWalletCardSticker]
stickers               :: Maybe [InputTonWalletCardSticker.InputTonWalletCardSticker] -- ^ The new list of stickers; pass an empty list to remove all stickers. Up to 10 stickers can be added. Each NFT can be used only once
    , SetTonWalletCardStickers -> Maybe Text
background_nft_address :: Maybe T.Text                                                -- ^ Address of the NFT from the new list of stickers, whose colors will be used for the card background; pass an empty string to use the default background. The NFT must correspond to an upgraded gift with can_be_ton_wallet_card_background == true
    }
  deriving (SetTonWalletCardStickers -> SetTonWalletCardStickers -> Bool
(SetTonWalletCardStickers -> SetTonWalletCardStickers -> Bool)
-> (SetTonWalletCardStickers -> SetTonWalletCardStickers -> Bool)
-> Eq SetTonWalletCardStickers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetTonWalletCardStickers -> SetTonWalletCardStickers -> Bool
== :: SetTonWalletCardStickers -> SetTonWalletCardStickers -> Bool
$c/= :: SetTonWalletCardStickers -> SetTonWalletCardStickers -> Bool
/= :: SetTonWalletCardStickers -> SetTonWalletCardStickers -> Bool
Eq, Int -> SetTonWalletCardStickers -> ShowS
[SetTonWalletCardStickers] -> ShowS
SetTonWalletCardStickers -> String
(Int -> SetTonWalletCardStickers -> ShowS)
-> (SetTonWalletCardStickers -> String)
-> ([SetTonWalletCardStickers] -> ShowS)
-> Show SetTonWalletCardStickers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetTonWalletCardStickers -> ShowS
showsPrec :: Int -> SetTonWalletCardStickers -> ShowS
$cshow :: SetTonWalletCardStickers -> String
show :: SetTonWalletCardStickers -> String
$cshowList :: [SetTonWalletCardStickers] -> ShowS
showList :: [SetTonWalletCardStickers] -> ShowS
Show)

instance I.ShortShow SetTonWalletCardStickers where
  shortShow :: SetTonWalletCardStickers -> String
shortShow
    SetTonWalletCardStickers
      { stickers :: SetTonWalletCardStickers -> Maybe [InputTonWalletCardSticker]
stickers               = Maybe [InputTonWalletCardSticker]
stickers_
      , background_nft_address :: SetTonWalletCardStickers -> Maybe Text
background_nft_address = Maybe Text
background_nft_address_
      }
        = String
"SetTonWalletCardStickers"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"stickers"               String -> Maybe [InputTonWalletCardSticker] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [InputTonWalletCardSticker]
stickers_
          , String
"background_nft_address" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
background_nft_address_
          ]

instance AT.ToJSON SetTonWalletCardStickers where
  toJSON :: SetTonWalletCardStickers -> Value
toJSON
    SetTonWalletCardStickers
      { stickers :: SetTonWalletCardStickers -> Maybe [InputTonWalletCardSticker]
stickers               = Maybe [InputTonWalletCardSticker]
stickers_
      , background_nft_address :: SetTonWalletCardStickers -> Maybe Text
background_nft_address = Maybe Text
background_nft_address_
      }
        = [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
"setTonWalletCardStickers"
          , Key
"stickers"               Key -> Maybe [InputTonWalletCardSticker] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [InputTonWalletCardSticker]
stickers_
          , Key
"background_nft_address" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
background_nft_address_
          ]

defaultSetTonWalletCardStickers :: SetTonWalletCardStickers
defaultSetTonWalletCardStickers :: SetTonWalletCardStickers
defaultSetTonWalletCardStickers =
  SetTonWalletCardStickers
    { stickers :: Maybe [InputTonWalletCardSticker]
stickers               = Maybe [InputTonWalletCardSticker]
forall a. Maybe a
Nothing
    , background_nft_address :: Maybe Text
background_nft_address = Maybe Text
forall a. Maybe a
Nothing
    }