module TD.Data.TelegramPaymentPurpose
(TelegramPaymentPurpose(..)) 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.FormattedText as FormattedText
import qualified TD.Data.GiveawayParameters as GiveawayParameters
data TelegramPaymentPurpose
= TelegramPaymentPurposePremiumGiftCodes
{ TelegramPaymentPurpose -> Maybe Int
boosted_chat_id :: Maybe Int
, TelegramPaymentPurpose -> Maybe Text
currency :: Maybe T.Text
, TelegramPaymentPurpose -> Maybe Int
amount :: Maybe Int
, TelegramPaymentPurpose -> Maybe [Int]
user_ids :: Maybe [Int]
, TelegramPaymentPurpose -> Maybe Int
month_count :: Maybe Int
, TelegramPaymentPurpose -> Maybe FormattedText
text :: Maybe FormattedText.FormattedText
}
| TelegramPaymentPurposePremiumGiveaway
{ TelegramPaymentPurpose -> Maybe GiveawayParameters
parameters :: Maybe GiveawayParameters.GiveawayParameters
, currency :: Maybe T.Text
, amount :: Maybe Int
, TelegramPaymentPurpose -> Maybe Int
winner_count :: Maybe Int
, month_count :: Maybe Int
}
| TelegramPaymentPurposeStars
{ currency :: Maybe T.Text
, amount :: Maybe Int
, TelegramPaymentPurpose -> Maybe Int
star_count :: Maybe Int
}
| TelegramPaymentPurposeGiftedStars
{ TelegramPaymentPurpose -> Maybe Int
user_id :: Maybe Int
, currency :: Maybe T.Text
, amount :: Maybe Int
, star_count :: Maybe Int
}
| TelegramPaymentPurposeStarGiveaway
{ parameters :: Maybe GiveawayParameters.GiveawayParameters
, currency :: Maybe T.Text
, amount :: Maybe Int
, winner_count :: Maybe Int
, star_count :: Maybe Int
}
| TelegramPaymentPurposeJoinChat
{ TelegramPaymentPurpose -> Maybe Text
invite_link :: Maybe T.Text
}
deriving (TelegramPaymentPurpose -> TelegramPaymentPurpose -> Bool
(TelegramPaymentPurpose -> TelegramPaymentPurpose -> Bool)
-> (TelegramPaymentPurpose -> TelegramPaymentPurpose -> Bool)
-> Eq TelegramPaymentPurpose
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TelegramPaymentPurpose -> TelegramPaymentPurpose -> Bool
== :: TelegramPaymentPurpose -> TelegramPaymentPurpose -> Bool
$c/= :: TelegramPaymentPurpose -> TelegramPaymentPurpose -> Bool
/= :: TelegramPaymentPurpose -> TelegramPaymentPurpose -> Bool
Eq, Int -> TelegramPaymentPurpose -> ShowS
[TelegramPaymentPurpose] -> ShowS
TelegramPaymentPurpose -> String
(Int -> TelegramPaymentPurpose -> ShowS)
-> (TelegramPaymentPurpose -> String)
-> ([TelegramPaymentPurpose] -> ShowS)
-> Show TelegramPaymentPurpose
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TelegramPaymentPurpose -> ShowS
showsPrec :: Int -> TelegramPaymentPurpose -> ShowS
$cshow :: TelegramPaymentPurpose -> String
show :: TelegramPaymentPurpose -> String
$cshowList :: [TelegramPaymentPurpose] -> ShowS
showList :: [TelegramPaymentPurpose] -> ShowS
Show)
instance I.ShortShow TelegramPaymentPurpose where
shortShow :: TelegramPaymentPurpose -> String
shortShow TelegramPaymentPurposePremiumGiftCodes
{ boosted_chat_id :: TelegramPaymentPurpose -> Maybe Int
boosted_chat_id = Maybe Int
boosted_chat_id_
, currency :: TelegramPaymentPurpose -> Maybe Text
currency = Maybe Text
currency_
, amount :: TelegramPaymentPurpose -> Maybe Int
amount = Maybe Int
amount_
, user_ids :: TelegramPaymentPurpose -> Maybe [Int]
user_ids = Maybe [Int]
user_ids_
, month_count :: TelegramPaymentPurpose -> Maybe Int
month_count = Maybe Int
month_count_
, text :: TelegramPaymentPurpose -> Maybe FormattedText
text = Maybe FormattedText
text_
}
= String
"TelegramPaymentPurposePremiumGiftCodes"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"boosted_chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
boosted_chat_id_
, String
"currency" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
currency_
, String
"amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
amount_
, String
"user_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
user_ids_
, 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_
]
shortShow TelegramPaymentPurposePremiumGiveaway
{ parameters :: TelegramPaymentPurpose -> Maybe GiveawayParameters
parameters = Maybe GiveawayParameters
parameters_
, currency :: TelegramPaymentPurpose -> Maybe Text
currency = Maybe Text
currency_
, amount :: TelegramPaymentPurpose -> Maybe Int
amount = Maybe Int
amount_
, winner_count :: TelegramPaymentPurpose -> Maybe Int
winner_count = Maybe Int
winner_count_
, month_count :: TelegramPaymentPurpose -> Maybe Int
month_count = Maybe Int
month_count_
}
= String
"TelegramPaymentPurposePremiumGiveaway"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"parameters" String -> Maybe GiveawayParameters -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe GiveawayParameters
parameters_
, String
"currency" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
currency_
, String
"amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
amount_
, String
"winner_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
winner_count_
, String
"month_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
month_count_
]
shortShow TelegramPaymentPurposeStars
{ currency :: TelegramPaymentPurpose -> Maybe Text
currency = Maybe Text
currency_
, amount :: TelegramPaymentPurpose -> Maybe Int
amount = Maybe Int
amount_
, star_count :: TelegramPaymentPurpose -> Maybe Int
star_count = Maybe Int
star_count_
}
= String
"TelegramPaymentPurposeStars"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"currency" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
currency_
, String
"amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
amount_
, String
"star_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
star_count_
]
shortShow TelegramPaymentPurposeGiftedStars
{ user_id :: TelegramPaymentPurpose -> Maybe Int
user_id = Maybe Int
user_id_
, currency :: TelegramPaymentPurpose -> Maybe Text
currency = Maybe Text
currency_
, amount :: TelegramPaymentPurpose -> Maybe Int
amount = Maybe Int
amount_
, star_count :: TelegramPaymentPurpose -> Maybe Int
star_count = Maybe Int
star_count_
}
= String
"TelegramPaymentPurposeGiftedStars"
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
"currency" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
currency_
, String
"amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
amount_
, String
"star_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
star_count_
]
shortShow TelegramPaymentPurposeStarGiveaway
{ parameters :: TelegramPaymentPurpose -> Maybe GiveawayParameters
parameters = Maybe GiveawayParameters
parameters_
, currency :: TelegramPaymentPurpose -> Maybe Text
currency = Maybe Text
currency_
, amount :: TelegramPaymentPurpose -> Maybe Int
amount = Maybe Int
amount_
, winner_count :: TelegramPaymentPurpose -> Maybe Int
winner_count = Maybe Int
winner_count_
, star_count :: TelegramPaymentPurpose -> Maybe Int
star_count = Maybe Int
star_count_
}
= String
"TelegramPaymentPurposeStarGiveaway"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"parameters" String -> Maybe GiveawayParameters -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe GiveawayParameters
parameters_
, String
"currency" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
currency_
, String
"amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
amount_
, String
"winner_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
winner_count_
, String
"star_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
star_count_
]
shortShow TelegramPaymentPurposeJoinChat
{ invite_link :: TelegramPaymentPurpose -> Maybe Text
invite_link = Maybe Text
invite_link_
}
= String
"TelegramPaymentPurposeJoinChat"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"invite_link" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
invite_link_
]
instance AT.FromJSON TelegramPaymentPurpose where
parseJSON :: Value -> Parser TelegramPaymentPurpose
parseJSON v :: Value
v@(AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"telegramPaymentPurposePremiumGiftCodes" -> Value -> Parser TelegramPaymentPurpose
parseTelegramPaymentPurposePremiumGiftCodes Value
v
String
"telegramPaymentPurposePremiumGiveaway" -> Value -> Parser TelegramPaymentPurpose
parseTelegramPaymentPurposePremiumGiveaway Value
v
String
"telegramPaymentPurposeStars" -> Value -> Parser TelegramPaymentPurpose
parseTelegramPaymentPurposeStars Value
v
String
"telegramPaymentPurposeGiftedStars" -> Value -> Parser TelegramPaymentPurpose
parseTelegramPaymentPurposeGiftedStars Value
v
String
"telegramPaymentPurposeStarGiveaway" -> Value -> Parser TelegramPaymentPurpose
parseTelegramPaymentPurposeStarGiveaway Value
v
String
"telegramPaymentPurposeJoinChat" -> Value -> Parser TelegramPaymentPurpose
parseTelegramPaymentPurposeJoinChat Value
v
String
_ -> Parser TelegramPaymentPurpose
forall a. Monoid a => a
mempty
where
parseTelegramPaymentPurposePremiumGiftCodes :: A.Value -> AT.Parser TelegramPaymentPurpose
parseTelegramPaymentPurposePremiumGiftCodes :: Value -> Parser TelegramPaymentPurpose
parseTelegramPaymentPurposePremiumGiftCodes = String
-> (Object -> Parser TelegramPaymentPurpose)
-> Value
-> Parser TelegramPaymentPurpose
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TelegramPaymentPurposePremiumGiftCodes" ((Object -> Parser TelegramPaymentPurpose)
-> Value -> Parser TelegramPaymentPurpose)
-> (Object -> Parser TelegramPaymentPurpose)
-> Value
-> Parser TelegramPaymentPurpose
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
boosted_chat_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"boosted_chat_id"
Maybe Text
currency_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"currency"
Maybe Int
amount_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"amount"
Maybe [Int]
user_ids_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"user_ids"
Maybe Int
month_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"month_count"
Maybe FormattedText
text_ <- Object
o Object -> Key -> Parser (Maybe FormattedText)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"text"
TelegramPaymentPurpose -> Parser TelegramPaymentPurpose
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TelegramPaymentPurpose -> Parser TelegramPaymentPurpose)
-> TelegramPaymentPurpose -> Parser TelegramPaymentPurpose
forall a b. (a -> b) -> a -> b
$ TelegramPaymentPurposePremiumGiftCodes
{ boosted_chat_id :: Maybe Int
boosted_chat_id = Maybe Int
boosted_chat_id_
, currency :: Maybe Text
currency = Maybe Text
currency_
, amount :: Maybe Int
amount = Maybe Int
amount_
, user_ids :: Maybe [Int]
user_ids = Maybe [Int]
user_ids_
, month_count :: Maybe Int
month_count = Maybe Int
month_count_
, text :: Maybe FormattedText
text = Maybe FormattedText
text_
}
parseTelegramPaymentPurposePremiumGiveaway :: A.Value -> AT.Parser TelegramPaymentPurpose
parseTelegramPaymentPurposePremiumGiveaway :: Value -> Parser TelegramPaymentPurpose
parseTelegramPaymentPurposePremiumGiveaway = String
-> (Object -> Parser TelegramPaymentPurpose)
-> Value
-> Parser TelegramPaymentPurpose
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TelegramPaymentPurposePremiumGiveaway" ((Object -> Parser TelegramPaymentPurpose)
-> Value -> Parser TelegramPaymentPurpose)
-> (Object -> Parser TelegramPaymentPurpose)
-> Value
-> Parser TelegramPaymentPurpose
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe GiveawayParameters
parameters_ <- Object
o Object -> Key -> Parser (Maybe GiveawayParameters)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"parameters"
Maybe Text
currency_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"currency"
Maybe Int
amount_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"amount"
Maybe Int
winner_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"winner_count"
Maybe Int
month_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"month_count"
TelegramPaymentPurpose -> Parser TelegramPaymentPurpose
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TelegramPaymentPurpose -> Parser TelegramPaymentPurpose)
-> TelegramPaymentPurpose -> Parser TelegramPaymentPurpose
forall a b. (a -> b) -> a -> b
$ TelegramPaymentPurposePremiumGiveaway
{ parameters :: Maybe GiveawayParameters
parameters = Maybe GiveawayParameters
parameters_
, currency :: Maybe Text
currency = Maybe Text
currency_
, amount :: Maybe Int
amount = Maybe Int
amount_
, winner_count :: Maybe Int
winner_count = Maybe Int
winner_count_
, month_count :: Maybe Int
month_count = Maybe Int
month_count_
}
parseTelegramPaymentPurposeStars :: A.Value -> AT.Parser TelegramPaymentPurpose
parseTelegramPaymentPurposeStars :: Value -> Parser TelegramPaymentPurpose
parseTelegramPaymentPurposeStars = String
-> (Object -> Parser TelegramPaymentPurpose)
-> Value
-> Parser TelegramPaymentPurpose
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TelegramPaymentPurposeStars" ((Object -> Parser TelegramPaymentPurpose)
-> Value -> Parser TelegramPaymentPurpose)
-> (Object -> Parser TelegramPaymentPurpose)
-> Value
-> Parser TelegramPaymentPurpose
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
currency_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"currency"
Maybe Int
amount_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"amount"
Maybe Int
star_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"star_count"
TelegramPaymentPurpose -> Parser TelegramPaymentPurpose
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TelegramPaymentPurpose -> Parser TelegramPaymentPurpose)
-> TelegramPaymentPurpose -> Parser TelegramPaymentPurpose
forall a b. (a -> b) -> a -> b
$ TelegramPaymentPurposeStars
{ currency :: Maybe Text
currency = Maybe Text
currency_
, amount :: Maybe Int
amount = Maybe Int
amount_
, star_count :: Maybe Int
star_count = Maybe Int
star_count_
}
parseTelegramPaymentPurposeGiftedStars :: A.Value -> AT.Parser TelegramPaymentPurpose
parseTelegramPaymentPurposeGiftedStars :: Value -> Parser TelegramPaymentPurpose
parseTelegramPaymentPurposeGiftedStars = String
-> (Object -> Parser TelegramPaymentPurpose)
-> Value
-> Parser TelegramPaymentPurpose
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TelegramPaymentPurposeGiftedStars" ((Object -> Parser TelegramPaymentPurpose)
-> Value -> Parser TelegramPaymentPurpose)
-> (Object -> Parser TelegramPaymentPurpose)
-> Value
-> Parser TelegramPaymentPurpose
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
user_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"user_id"
Maybe Text
currency_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"currency"
Maybe Int
amount_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"amount"
Maybe Int
star_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"star_count"
TelegramPaymentPurpose -> Parser TelegramPaymentPurpose
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TelegramPaymentPurpose -> Parser TelegramPaymentPurpose)
-> TelegramPaymentPurpose -> Parser TelegramPaymentPurpose
forall a b. (a -> b) -> a -> b
$ TelegramPaymentPurposeGiftedStars
{ user_id :: Maybe Int
user_id = Maybe Int
user_id_
, currency :: Maybe Text
currency = Maybe Text
currency_
, amount :: Maybe Int
amount = Maybe Int
amount_
, star_count :: Maybe Int
star_count = Maybe Int
star_count_
}
parseTelegramPaymentPurposeStarGiveaway :: A.Value -> AT.Parser TelegramPaymentPurpose
parseTelegramPaymentPurposeStarGiveaway :: Value -> Parser TelegramPaymentPurpose
parseTelegramPaymentPurposeStarGiveaway = String
-> (Object -> Parser TelegramPaymentPurpose)
-> Value
-> Parser TelegramPaymentPurpose
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TelegramPaymentPurposeStarGiveaway" ((Object -> Parser TelegramPaymentPurpose)
-> Value -> Parser TelegramPaymentPurpose)
-> (Object -> Parser TelegramPaymentPurpose)
-> Value
-> Parser TelegramPaymentPurpose
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe GiveawayParameters
parameters_ <- Object
o Object -> Key -> Parser (Maybe GiveawayParameters)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"parameters"
Maybe Text
currency_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"currency"
Maybe Int
amount_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"amount"
Maybe Int
winner_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"winner_count"
Maybe Int
star_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"star_count"
TelegramPaymentPurpose -> Parser TelegramPaymentPurpose
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TelegramPaymentPurpose -> Parser TelegramPaymentPurpose)
-> TelegramPaymentPurpose -> Parser TelegramPaymentPurpose
forall a b. (a -> b) -> a -> b
$ TelegramPaymentPurposeStarGiveaway
{ parameters :: Maybe GiveawayParameters
parameters = Maybe GiveawayParameters
parameters_
, currency :: Maybe Text
currency = Maybe Text
currency_
, amount :: Maybe Int
amount = Maybe Int
amount_
, winner_count :: Maybe Int
winner_count = Maybe Int
winner_count_
, star_count :: Maybe Int
star_count = Maybe Int
star_count_
}
parseTelegramPaymentPurposeJoinChat :: A.Value -> AT.Parser TelegramPaymentPurpose
parseTelegramPaymentPurposeJoinChat :: Value -> Parser TelegramPaymentPurpose
parseTelegramPaymentPurposeJoinChat = String
-> (Object -> Parser TelegramPaymentPurpose)
-> Value
-> Parser TelegramPaymentPurpose
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TelegramPaymentPurposeJoinChat" ((Object -> Parser TelegramPaymentPurpose)
-> Value -> Parser TelegramPaymentPurpose)
-> (Object -> Parser TelegramPaymentPurpose)
-> Value
-> Parser TelegramPaymentPurpose
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
invite_link_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"invite_link"
TelegramPaymentPurpose -> Parser TelegramPaymentPurpose
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TelegramPaymentPurpose -> Parser TelegramPaymentPurpose)
-> TelegramPaymentPurpose -> Parser TelegramPaymentPurpose
forall a b. (a -> b) -> a -> b
$ TelegramPaymentPurposeJoinChat
{ invite_link :: Maybe Text
invite_link = Maybe Text
invite_link_
}
parseJSON Value
_ = Parser TelegramPaymentPurpose
forall a. Monoid a => a
mempty
instance AT.ToJSON TelegramPaymentPurpose where
toJSON :: TelegramPaymentPurpose -> Value
toJSON TelegramPaymentPurposePremiumGiftCodes
{ boosted_chat_id :: TelegramPaymentPurpose -> Maybe Int
boosted_chat_id = Maybe Int
boosted_chat_id_
, currency :: TelegramPaymentPurpose -> Maybe Text
currency = Maybe Text
currency_
, amount :: TelegramPaymentPurpose -> Maybe Int
amount = Maybe Int
amount_
, user_ids :: TelegramPaymentPurpose -> Maybe [Int]
user_ids = Maybe [Int]
user_ids_
, month_count :: TelegramPaymentPurpose -> Maybe Int
month_count = Maybe Int
month_count_
, text :: TelegramPaymentPurpose -> 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
"telegramPaymentPurposePremiumGiftCodes"
, Key
"boosted_chat_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
boosted_chat_id_
, Key
"currency" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
currency_
, Key
"amount" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
amount_
, Key
"user_ids" 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_ids_
, 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_
]
toJSON TelegramPaymentPurposePremiumGiveaway
{ parameters :: TelegramPaymentPurpose -> Maybe GiveawayParameters
parameters = Maybe GiveawayParameters
parameters_
, currency :: TelegramPaymentPurpose -> Maybe Text
currency = Maybe Text
currency_
, amount :: TelegramPaymentPurpose -> Maybe Int
amount = Maybe Int
amount_
, winner_count :: TelegramPaymentPurpose -> Maybe Int
winner_count = Maybe Int
winner_count_
, month_count :: TelegramPaymentPurpose -> Maybe Int
month_count = Maybe Int
month_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
"telegramPaymentPurposePremiumGiveaway"
, Key
"parameters" Key -> Maybe GiveawayParameters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe GiveawayParameters
parameters_
, Key
"currency" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
currency_
, Key
"amount" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
amount_
, Key
"winner_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
winner_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_
]
toJSON TelegramPaymentPurposeStars
{ currency :: TelegramPaymentPurpose -> Maybe Text
currency = Maybe Text
currency_
, amount :: TelegramPaymentPurpose -> Maybe Int
amount = Maybe Int
amount_
, star_count :: TelegramPaymentPurpose -> Maybe Int
star_count = Maybe Int
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
"telegramPaymentPurposeStars"
, Key
"currency" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
currency_
, Key
"amount" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
amount_
, 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_
]
toJSON TelegramPaymentPurposeGiftedStars
{ user_id :: TelegramPaymentPurpose -> Maybe Int
user_id = Maybe Int
user_id_
, currency :: TelegramPaymentPurpose -> Maybe Text
currency = Maybe Text
currency_
, amount :: TelegramPaymentPurpose -> Maybe Int
amount = Maybe Int
amount_
, star_count :: TelegramPaymentPurpose -> Maybe Int
star_count = Maybe Int
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
"telegramPaymentPurposeGiftedStars"
, 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
"currency" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
currency_
, Key
"amount" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
amount_
, 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_
]
toJSON TelegramPaymentPurposeStarGiveaway
{ parameters :: TelegramPaymentPurpose -> Maybe GiveawayParameters
parameters = Maybe GiveawayParameters
parameters_
, currency :: TelegramPaymentPurpose -> Maybe Text
currency = Maybe Text
currency_
, amount :: TelegramPaymentPurpose -> Maybe Int
amount = Maybe Int
amount_
, winner_count :: TelegramPaymentPurpose -> Maybe Int
winner_count = Maybe Int
winner_count_
, star_count :: TelegramPaymentPurpose -> Maybe Int
star_count = Maybe Int
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
"telegramPaymentPurposeStarGiveaway"
, Key
"parameters" Key -> Maybe GiveawayParameters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe GiveawayParameters
parameters_
, Key
"currency" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
currency_
, Key
"amount" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
amount_
, Key
"winner_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
winner_count_
, 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_
]
toJSON TelegramPaymentPurposeJoinChat
{ invite_link :: TelegramPaymentPurpose -> Maybe Text
invite_link = Maybe Text
invite_link_
}
= [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
"telegramPaymentPurposeJoinChat"
, Key
"invite_link" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
invite_link_
]