module TD.Query.GiftPremiumWithStars
  (GiftPremiumWithStars(..)
  , defaultGiftPremiumWithStars
  ) 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

-- | Allows to buy a Telegram Premium subscription for another user with payment in Telegram Stars; for bots only. Returns 'TD.Data.Ok.Ok'
data GiftPremiumWithStars
  = GiftPremiumWithStars
    { GiftPremiumWithStars -> Maybe Int
user_id     :: Maybe Int                         -- ^ Identifier of the user which will receive Telegram Premium
    , GiftPremiumWithStars -> Maybe Int
star_count  :: Maybe Int                         -- ^ The number of Telegram Stars to pay for subscription
    , GiftPremiumWithStars -> Maybe Int
month_count :: Maybe Int                         -- ^ Number of months the Telegram Premium subscription will be active for the user
    , GiftPremiumWithStars -> Maybe FormattedText
text        :: Maybe FormattedText.FormattedText -- ^ Text to show to the user receiving Telegram Premium; 0-getOption("gift_text_length_max") characters. Only Bold, Italic, Underline, Strikethrough, Spoiler, and CustomEmoji entities are allowed
    }
  deriving (GiftPremiumWithStars -> GiftPremiumWithStars -> Bool
(GiftPremiumWithStars -> GiftPremiumWithStars -> Bool)
-> (GiftPremiumWithStars -> GiftPremiumWithStars -> Bool)
-> Eq GiftPremiumWithStars
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GiftPremiumWithStars -> GiftPremiumWithStars -> Bool
== :: GiftPremiumWithStars -> GiftPremiumWithStars -> Bool
$c/= :: GiftPremiumWithStars -> GiftPremiumWithStars -> Bool
/= :: GiftPremiumWithStars -> GiftPremiumWithStars -> Bool
Eq, Int -> GiftPremiumWithStars -> ShowS
[GiftPremiumWithStars] -> ShowS
GiftPremiumWithStars -> String
(Int -> GiftPremiumWithStars -> ShowS)
-> (GiftPremiumWithStars -> String)
-> ([GiftPremiumWithStars] -> ShowS)
-> Show GiftPremiumWithStars
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GiftPremiumWithStars -> ShowS
showsPrec :: Int -> GiftPremiumWithStars -> ShowS
$cshow :: GiftPremiumWithStars -> String
show :: GiftPremiumWithStars -> String
$cshowList :: [GiftPremiumWithStars] -> ShowS
showList :: [GiftPremiumWithStars] -> ShowS
Show)

instance I.ShortShow GiftPremiumWithStars where
  shortShow :: GiftPremiumWithStars -> String
shortShow
    GiftPremiumWithStars
      { user_id :: GiftPremiumWithStars -> Maybe Int
user_id     = Maybe Int
user_id_
      , star_count :: GiftPremiumWithStars -> Maybe Int
star_count  = Maybe Int
star_count_
      , month_count :: GiftPremiumWithStars -> Maybe Int
month_count = Maybe Int
month_count_
      , text :: GiftPremiumWithStars -> Maybe FormattedText
text        = Maybe FormattedText
text_
      }
        = String
"GiftPremiumWithStars"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"user_id"     String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_id_
          , String
"star_count"  String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
star_count_
          , String
"month_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
month_count_
          , String
"text"        String -> Maybe FormattedText -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe FormattedText
text_
          ]

instance AT.ToJSON GiftPremiumWithStars where
  toJSON :: GiftPremiumWithStars -> Value
toJSON
    GiftPremiumWithStars
      { user_id :: GiftPremiumWithStars -> Maybe Int
user_id     = Maybe Int
user_id_
      , star_count :: GiftPremiumWithStars -> Maybe Int
star_count  = Maybe Int
star_count_
      , month_count :: GiftPremiumWithStars -> Maybe Int
month_count = Maybe Int
month_count_
      , text :: GiftPremiumWithStars -> Maybe FormattedText
text        = Maybe FormattedText
text_
      }
        = [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
"giftPremiumWithStars"
          , 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
"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
"month_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
month_count_
          , 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_
          ]

defaultGiftPremiumWithStars :: GiftPremiumWithStars
defaultGiftPremiumWithStars :: GiftPremiumWithStars
defaultGiftPremiumWithStars =
  GiftPremiumWithStars
    { user_id :: Maybe Int
user_id     = Maybe Int
forall a. Maybe a
Nothing
    , star_count :: Maybe Int
star_count  = Maybe Int
forall a. Maybe a
Nothing
    , month_count :: Maybe Int
month_count = Maybe Int
forall a. Maybe a
Nothing
    , text :: Maybe FormattedText
text        = Maybe FormattedText
forall a. Maybe a
Nothing
    }