module TD.Query.PlaceGiftAuctionBid
  (PlaceGiftAuctionBid(..)
  , defaultPlaceGiftAuctionBid
  ) 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.FormattedText as FormattedText

-- | Places a bid on an auction gift. Returns 'TD.Data.Ok.Ok'
data PlaceGiftAuctionBid
  = PlaceGiftAuctionBid
    { PlaceGiftAuctionBid -> Maybe Int
gift_id    :: Maybe Int                         -- ^ Identifier of the gift to place the bid on
    , PlaceGiftAuctionBid -> Maybe Int
star_count :: Maybe Int                         -- ^ The number of Telegram Stars to place in the bid
    , PlaceGiftAuctionBid -> Maybe Int
user_id    :: Maybe Int                         -- ^ Identifier of the user who will receive the gift
    , PlaceGiftAuctionBid -> 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, and CustomEmoji entities are allowed. Must be empty if the receiver enabled paid messages
    , PlaceGiftAuctionBid -> 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 (PlaceGiftAuctionBid -> PlaceGiftAuctionBid -> Bool
(PlaceGiftAuctionBid -> PlaceGiftAuctionBid -> Bool)
-> (PlaceGiftAuctionBid -> PlaceGiftAuctionBid -> Bool)
-> Eq PlaceGiftAuctionBid
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PlaceGiftAuctionBid -> PlaceGiftAuctionBid -> Bool
== :: PlaceGiftAuctionBid -> PlaceGiftAuctionBid -> Bool
$c/= :: PlaceGiftAuctionBid -> PlaceGiftAuctionBid -> Bool
/= :: PlaceGiftAuctionBid -> PlaceGiftAuctionBid -> Bool
Eq, Int -> PlaceGiftAuctionBid -> ShowS
[PlaceGiftAuctionBid] -> ShowS
PlaceGiftAuctionBid -> String
(Int -> PlaceGiftAuctionBid -> ShowS)
-> (PlaceGiftAuctionBid -> String)
-> ([PlaceGiftAuctionBid] -> ShowS)
-> Show PlaceGiftAuctionBid
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PlaceGiftAuctionBid -> ShowS
showsPrec :: Int -> PlaceGiftAuctionBid -> ShowS
$cshow :: PlaceGiftAuctionBid -> String
show :: PlaceGiftAuctionBid -> String
$cshowList :: [PlaceGiftAuctionBid] -> ShowS
showList :: [PlaceGiftAuctionBid] -> ShowS
Show)

instance I.ShortShow PlaceGiftAuctionBid where
  shortShow :: PlaceGiftAuctionBid -> String
shortShow
    PlaceGiftAuctionBid
      { gift_id :: PlaceGiftAuctionBid -> Maybe Int
gift_id    = Maybe Int
gift_id_
      , star_count :: PlaceGiftAuctionBid -> Maybe Int
star_count = Maybe Int
star_count_
      , user_id :: PlaceGiftAuctionBid -> Maybe Int
user_id    = Maybe Int
user_id_
      , text :: PlaceGiftAuctionBid -> Maybe FormattedText
text       = Maybe FormattedText
text_
      , is_private :: PlaceGiftAuctionBid -> Maybe Bool
is_private = Maybe Bool
is_private_
      }
        = String
"PlaceGiftAuctionBid"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"gift_id"    String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
gift_id_
          , String
"star_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
star_count_
          , String
"user_id"    String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_id_
          , 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 PlaceGiftAuctionBid where
  toJSON :: PlaceGiftAuctionBid -> Value
toJSON
    PlaceGiftAuctionBid
      { gift_id :: PlaceGiftAuctionBid -> Maybe Int
gift_id    = Maybe Int
gift_id_
      , star_count :: PlaceGiftAuctionBid -> Maybe Int
star_count = Maybe Int
star_count_
      , user_id :: PlaceGiftAuctionBid -> Maybe Int
user_id    = Maybe Int
user_id_
      , text :: PlaceGiftAuctionBid -> Maybe FormattedText
text       = Maybe FormattedText
text_
      , is_private :: PlaceGiftAuctionBid -> 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
"placeGiftAuctionBid"
          , Key
"gift_id"    Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (Int -> Value) -> Maybe Int -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Value
I.writeInt64  Maybe Int
gift_id_
          , Key
"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
star_count_
          , Key
"user_id"    Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
user_id_
          , 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_
          ]

defaultPlaceGiftAuctionBid :: PlaceGiftAuctionBid
defaultPlaceGiftAuctionBid :: PlaceGiftAuctionBid
defaultPlaceGiftAuctionBid =
  PlaceGiftAuctionBid
    { gift_id :: Maybe Int
gift_id    = Maybe Int
forall a. Maybe a
Nothing
    , star_count :: Maybe Int
star_count = Maybe Int
forall a. Maybe a
Nothing
    , user_id :: Maybe Int
user_id    = Maybe Int
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
    }