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

-- | 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 Int
resale_star_count :: Maybe Int    -- ^ The new price for the unique gift; 0 or getOption("gift_resale_star_count_min")-getOption("gift_resale_star_count_max"). Pass 0 to disallow gift resale. The current user will receive getOption("gift_resale_earnings_per_mille") Telegram Stars for each 1000 Telegram Stars paid for the gift
    }
  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_
      , resale_star_count :: SetGiftResalePrice -> Maybe Int
resale_star_count = Maybe Int
resale_star_count_
      }
        = 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
"resale_star_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
resale_star_count_
          ]

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

defaultSetGiftResalePrice :: SetGiftResalePrice
defaultSetGiftResalePrice :: SetGiftResalePrice
defaultSetGiftResalePrice =
  SetGiftResalePrice
    { received_gift_id :: Maybe Text
received_gift_id  = Maybe Text
forall a. Maybe a
Nothing
    , resale_star_count :: Maybe Int
resale_star_count = Maybe Int
forall a. Maybe a
Nothing
    }