module TD.Query.SetGiftResalePrice
  (SetGiftResalePrice(..)
  , defaultSetGiftResalePrice
  ) 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
import qualified TD.Data.GiftResalePrice as GiftResalePrice

-- | Changes resale price of a unique gift owned by the current user. Returns 'TD.Data.Ok.Ok'
data SetGiftResalePrice
  = SetGiftResalePrice
    { SetGiftResalePrice -> Maybe Text
received_gift_id :: Maybe T.Text                          -- ^ Identifier of the unique gift
    , SetGiftResalePrice -> Maybe GiftResalePrice
price            :: Maybe GiftResalePrice.GiftResalePrice -- ^ The new price for the unique gift; pass null to disallow gift resale. The current user will receive getOption("gift_resale_star_earnings_per_mille") Telegram Stars for each 1000 Telegram Stars paid for the gift if the gift price is in Telegram Stars or getOption("gift_resale_ton_earnings_per_mille") Toncoins for each 1000 Toncoins paid for the gift if the gift price is in Toncoins
    }
  deriving (SetGiftResalePrice -> SetGiftResalePrice -> Bool
(SetGiftResalePrice -> SetGiftResalePrice -> Bool)
-> (SetGiftResalePrice -> SetGiftResalePrice -> Bool)
-> Eq SetGiftResalePrice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetGiftResalePrice -> SetGiftResalePrice -> Bool
== :: SetGiftResalePrice -> SetGiftResalePrice -> Bool
$c/= :: SetGiftResalePrice -> SetGiftResalePrice -> Bool
/= :: SetGiftResalePrice -> SetGiftResalePrice -> Bool
Eq, Int -> SetGiftResalePrice -> ShowS
[SetGiftResalePrice] -> ShowS
SetGiftResalePrice -> String
(Int -> SetGiftResalePrice -> ShowS)
-> (SetGiftResalePrice -> String)
-> ([SetGiftResalePrice] -> ShowS)
-> Show SetGiftResalePrice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetGiftResalePrice -> ShowS
showsPrec :: Int -> SetGiftResalePrice -> ShowS
$cshow :: SetGiftResalePrice -> String
show :: SetGiftResalePrice -> String
$cshowList :: [SetGiftResalePrice] -> ShowS
showList :: [SetGiftResalePrice] -> ShowS
Show)

instance I.ShortShow SetGiftResalePrice where
  shortShow :: SetGiftResalePrice -> String
shortShow
    SetGiftResalePrice
      { received_gift_id :: SetGiftResalePrice -> Maybe Text
received_gift_id = Maybe Text
received_gift_id_
      , price :: SetGiftResalePrice -> Maybe GiftResalePrice
price            = Maybe GiftResalePrice
price_
      }
        = String
"SetGiftResalePrice"
          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
"price"            String -> Maybe GiftResalePrice -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe GiftResalePrice
price_
          ]

instance AT.ToJSON SetGiftResalePrice where
  toJSON :: SetGiftResalePrice -> Value
toJSON
    SetGiftResalePrice
      { received_gift_id :: SetGiftResalePrice -> Maybe Text
received_gift_id = Maybe Text
received_gift_id_
      , price :: SetGiftResalePrice -> Maybe GiftResalePrice
price            = Maybe GiftResalePrice
price_
      }
        = [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
"setGiftResalePrice"
          , 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
"price"            Key -> Maybe GiftResalePrice -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe GiftResalePrice
price_
          ]

defaultSetGiftResalePrice :: SetGiftResalePrice
defaultSetGiftResalePrice :: SetGiftResalePrice
defaultSetGiftResalePrice =
  SetGiftResalePrice
    { received_gift_id :: Maybe Text
received_gift_id = Maybe Text
forall a. Maybe a
Nothing
    , price :: Maybe GiftResalePrice
price            = Maybe GiftResalePrice
forall a. Maybe a
Nothing
    }