module TD.Query.SendResoldGift
  (SendResoldGift(..)
  , defaultSendResoldGift
  ) 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.MessageSender as MessageSender
import qualified TD.Data.GiftResalePrice as GiftResalePrice
import qualified TD.Data.FormattedText as FormattedText

-- | Sends an upgraded gift that is available for resale to another user or channel chat; gifts already owned by the current user must be transferred using transferGift and can't be passed to the method. Returns 'TD.Data.GiftResaleResult.GiftResaleResult'
data SendResoldGift
  = SendResoldGift
    { SendResoldGift -> Maybe Text
gift_name  :: Maybe T.Text                          -- ^ Name of the upgraded gift to send
    , SendResoldGift -> Maybe MessageSender
owner_id   :: Maybe MessageSender.MessageSender     -- ^ Identifier of the user or the channel chat that will receive the gift
    , SendResoldGift -> Maybe GiftResalePrice
price      :: Maybe GiftResalePrice.GiftResalePrice -- ^ The price that the user agreed to pay for the gift
    , SendResoldGift -> Maybe FormattedText
text       :: Maybe FormattedText.FormattedText     -- ^ Text to show along with the gift; 0-getOption("gift_text_length_max") characters. Only Bold, Italic, Underline, Strikethrough, Spoiler, CustomEmoji, and DateTime entities are allowed. Must be empty if the receiver enabled paid messages and the price of the gift is less than the price of a paid message to the user
    , SendResoldGift -> Maybe Bool
is_private :: Maybe Bool                            -- ^ Pass true to show gift text and sender only to the gift receiver; otherwise, everyone will be able to see them
    }
  deriving (SendResoldGift -> SendResoldGift -> Bool
(SendResoldGift -> SendResoldGift -> Bool)
-> (SendResoldGift -> SendResoldGift -> Bool) -> Eq SendResoldGift
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SendResoldGift -> SendResoldGift -> Bool
== :: SendResoldGift -> SendResoldGift -> Bool
$c/= :: SendResoldGift -> SendResoldGift -> Bool
/= :: SendResoldGift -> SendResoldGift -> Bool
Eq, Int -> SendResoldGift -> ShowS
[SendResoldGift] -> ShowS
SendResoldGift -> String
(Int -> SendResoldGift -> ShowS)
-> (SendResoldGift -> String)
-> ([SendResoldGift] -> ShowS)
-> Show SendResoldGift
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SendResoldGift -> ShowS
showsPrec :: Int -> SendResoldGift -> ShowS
$cshow :: SendResoldGift -> String
show :: SendResoldGift -> String
$cshowList :: [SendResoldGift] -> ShowS
showList :: [SendResoldGift] -> ShowS
Show)

instance I.ShortShow SendResoldGift where
  shortShow :: SendResoldGift -> String
shortShow
    SendResoldGift
      { gift_name :: SendResoldGift -> Maybe Text
gift_name  = Maybe Text
gift_name_
      , owner_id :: SendResoldGift -> Maybe MessageSender
owner_id   = Maybe MessageSender
owner_id_
      , price :: SendResoldGift -> Maybe GiftResalePrice
price      = Maybe GiftResalePrice
price_
      , text :: SendResoldGift -> Maybe FormattedText
text       = Maybe FormattedText
text_
      , is_private :: SendResoldGift -> Maybe Bool
is_private = Maybe Bool
is_private_
      }
        = String
"SendResoldGift"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"gift_name"  String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
gift_name_
          , String
"owner_id"   String -> Maybe MessageSender -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe MessageSender
owner_id_
          , String
"price"      String -> Maybe GiftResalePrice -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe GiftResalePrice
price_
          , String
"text"       String -> Maybe FormattedText -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe FormattedText
text_
          , String
"is_private" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_private_
          ]

instance AT.ToJSON SendResoldGift where
  toJSON :: SendResoldGift -> Value
toJSON
    SendResoldGift
      { gift_name :: SendResoldGift -> Maybe Text
gift_name  = Maybe Text
gift_name_
      , owner_id :: SendResoldGift -> Maybe MessageSender
owner_id   = Maybe MessageSender
owner_id_
      , price :: SendResoldGift -> Maybe GiftResalePrice
price      = Maybe GiftResalePrice
price_
      , text :: SendResoldGift -> Maybe FormattedText
text       = Maybe FormattedText
text_
      , is_private :: SendResoldGift -> Maybe Bool
is_private = Maybe Bool
is_private_
      }
        = [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
"sendResoldGift"
          , Key
"gift_name"  Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
gift_name_
          , Key
"owner_id"   Key -> Maybe MessageSender -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe MessageSender
owner_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_
          , Key
"text"       Key -> Maybe FormattedText -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe FormattedText
text_
          , Key
"is_private" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_private_
          ]

defaultSendResoldGift :: SendResoldGift
defaultSendResoldGift :: SendResoldGift
defaultSendResoldGift =
  SendResoldGift
    { gift_name :: Maybe Text
gift_name  = Maybe Text
forall a. Maybe a
Nothing
    , owner_id :: Maybe MessageSender
owner_id   = Maybe MessageSender
forall a. Maybe a
Nothing
    , price :: Maybe GiftResalePrice
price      = Maybe GiftResalePrice
forall a. Maybe a
Nothing
    , text :: Maybe FormattedText
text       = Maybe FormattedText
forall a. Maybe a
Nothing
    , is_private :: Maybe Bool
is_private = Maybe Bool
forall a. Maybe a
Nothing
    }