module TD.Query.SendGiftPurchaseOffer
  (SendGiftPurchaseOffer(..)
  , defaultSendGiftPurchaseOffer
  ) 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.MessageSender as MessageSender
import qualified Data.Text as T
import qualified TD.Data.GiftResalePrice as GiftResalePrice

-- | Sends an offer to purchase an upgraded gift. Returns 'TD.Data.Ok.Ok'
data SendGiftPurchaseOffer
  = SendGiftPurchaseOffer
    { SendGiftPurchaseOffer -> Maybe MessageSender
owner_id                :: Maybe MessageSender.MessageSender     -- ^ Identifier of the user or the channel chat that currently owns the gift and will receive the offer
    , SendGiftPurchaseOffer -> Maybe Text
gift_name               :: Maybe T.Text                          -- ^ Name of the upgraded gift
    , SendGiftPurchaseOffer -> Maybe GiftResalePrice
price                   :: Maybe GiftResalePrice.GiftResalePrice -- ^ The price that the user agreed to pay for the gift
    , SendGiftPurchaseOffer -> Maybe Int
duration                :: Maybe Int                             -- ^ Duration of the offer, in seconds; must be one of 21600, 43200, 86400, 129600, 172800, or 259200. Can also be 120 if Telegram test environment is used
    ,  :: Maybe Int                             -- ^ The number of Telegram Stars the user agreed to pay additionally for sending of the offer message to the current gift owner; pass userFullInfo.outgoing_paid_message_star_count for users and 0 otherwise
    }
  deriving (SendGiftPurchaseOffer -> SendGiftPurchaseOffer -> Bool
(SendGiftPurchaseOffer -> SendGiftPurchaseOffer -> Bool)
-> (SendGiftPurchaseOffer -> SendGiftPurchaseOffer -> Bool)
-> Eq SendGiftPurchaseOffer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SendGiftPurchaseOffer -> SendGiftPurchaseOffer -> Bool
== :: SendGiftPurchaseOffer -> SendGiftPurchaseOffer -> Bool
$c/= :: SendGiftPurchaseOffer -> SendGiftPurchaseOffer -> Bool
/= :: SendGiftPurchaseOffer -> SendGiftPurchaseOffer -> Bool
Eq, Int -> SendGiftPurchaseOffer -> ShowS
[SendGiftPurchaseOffer] -> ShowS
SendGiftPurchaseOffer -> String
(Int -> SendGiftPurchaseOffer -> ShowS)
-> (SendGiftPurchaseOffer -> String)
-> ([SendGiftPurchaseOffer] -> ShowS)
-> Show SendGiftPurchaseOffer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SendGiftPurchaseOffer -> ShowS
showsPrec :: Int -> SendGiftPurchaseOffer -> ShowS
$cshow :: SendGiftPurchaseOffer -> String
show :: SendGiftPurchaseOffer -> String
$cshowList :: [SendGiftPurchaseOffer] -> ShowS
showList :: [SendGiftPurchaseOffer] -> ShowS
Show)

instance I.ShortShow SendGiftPurchaseOffer where
  shortShow :: SendGiftPurchaseOffer -> String
shortShow
    SendGiftPurchaseOffer
      { owner_id :: SendGiftPurchaseOffer -> Maybe MessageSender
owner_id                = Maybe MessageSender
owner_id_
      , gift_name :: SendGiftPurchaseOffer -> Maybe Text
gift_name               = Maybe Text
gift_name_
      , price :: SendGiftPurchaseOffer -> Maybe GiftResalePrice
price                   = Maybe GiftResalePrice
price_
      , duration :: SendGiftPurchaseOffer -> Maybe Int
duration                = Maybe Int
duration_
      , paid_message_star_count :: SendGiftPurchaseOffer -> Maybe Int
paid_message_star_count = Maybe Int
paid_message_star_count_
      }
        = String
"SendGiftPurchaseOffer"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"owner_id"                String -> Maybe MessageSender -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe MessageSender
owner_id_
          , String
"gift_name"               String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
gift_name_
          , String
"price"                   String -> Maybe GiftResalePrice -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe GiftResalePrice
price_
          , String
"duration"                String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
duration_
          , String
"paid_message_star_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
paid_message_star_count_
          ]

instance AT.ToJSON SendGiftPurchaseOffer where
  toJSON :: SendGiftPurchaseOffer -> Value
toJSON
    SendGiftPurchaseOffer
      { owner_id :: SendGiftPurchaseOffer -> Maybe MessageSender
owner_id                = Maybe MessageSender
owner_id_
      , gift_name :: SendGiftPurchaseOffer -> Maybe Text
gift_name               = Maybe Text
gift_name_
      , price :: SendGiftPurchaseOffer -> Maybe GiftResalePrice
price                   = Maybe GiftResalePrice
price_
      , duration :: SendGiftPurchaseOffer -> Maybe Int
duration                = Maybe Int
duration_
      , paid_message_star_count :: SendGiftPurchaseOffer -> Maybe Int
paid_message_star_count = Maybe Int
paid_message_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
"sendGiftPurchaseOffer"
          , 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
"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
"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
"duration"                Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
duration_
          , Key
"paid_message_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
paid_message_star_count_
          ]

defaultSendGiftPurchaseOffer :: SendGiftPurchaseOffer
defaultSendGiftPurchaseOffer :: SendGiftPurchaseOffer
defaultSendGiftPurchaseOffer =
  SendGiftPurchaseOffer
    { owner_id :: Maybe MessageSender
owner_id                = Maybe MessageSender
forall a. Maybe a
Nothing
    , gift_name :: Maybe Text
gift_name               = Maybe Text
forall a. Maybe a
Nothing
    , price :: Maybe GiftResalePrice
price                   = Maybe GiftResalePrice
forall a. Maybe a
Nothing
    , duration :: Maybe Int
duration                = Maybe Int
forall a. Maybe a
Nothing
    , paid_message_star_count :: Maybe Int
paid_message_star_count = Maybe Int
forall a. Maybe a
Nothing
    }