module TD.Query.SendGift
(SendGift(..)
, defaultSendGift
) 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
data SendGift
= SendGift
{ SendGift -> Maybe Int
gift_id :: Maybe Int
, SendGift -> Maybe Int
user_id :: Maybe Int
, SendGift -> Maybe FormattedText
text :: Maybe FormattedText.FormattedText
, SendGift -> Maybe Bool
is_private :: Maybe Bool
, SendGift -> Maybe Bool
pay_for_upgrade :: Maybe Bool
}
deriving (SendGift -> SendGift -> Bool
(SendGift -> SendGift -> Bool)
-> (SendGift -> SendGift -> Bool) -> Eq SendGift
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SendGift -> SendGift -> Bool
== :: SendGift -> SendGift -> Bool
$c/= :: SendGift -> SendGift -> Bool
/= :: SendGift -> SendGift -> Bool
Eq, Int -> SendGift -> ShowS
[SendGift] -> ShowS
SendGift -> String
(Int -> SendGift -> ShowS)
-> (SendGift -> String) -> ([SendGift] -> ShowS) -> Show SendGift
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SendGift -> ShowS
showsPrec :: Int -> SendGift -> ShowS
$cshow :: SendGift -> String
show :: SendGift -> String
$cshowList :: [SendGift] -> ShowS
showList :: [SendGift] -> ShowS
Show)
instance I.ShortShow SendGift where
shortShow :: SendGift -> String
shortShow
SendGift
{ gift_id :: SendGift -> Maybe Int
gift_id = Maybe Int
gift_id_
, user_id :: SendGift -> Maybe Int
user_id = Maybe Int
user_id_
, text :: SendGift -> Maybe FormattedText
text = Maybe FormattedText
text_
, is_private :: SendGift -> Maybe Bool
is_private = Maybe Bool
is_private_
, pay_for_upgrade :: SendGift -> Maybe Bool
pay_for_upgrade = Maybe Bool
pay_for_upgrade_
}
= String
"SendGift"
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
"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_
, String
"pay_for_upgrade" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
pay_for_upgrade_
]
instance AT.ToJSON SendGift where
toJSON :: SendGift -> Value
toJSON
SendGift
{ gift_id :: SendGift -> Maybe Int
gift_id = Maybe Int
gift_id_
, user_id :: SendGift -> Maybe Int
user_id = Maybe Int
user_id_
, text :: SendGift -> Maybe FormattedText
text = Maybe FormattedText
text_
, is_private :: SendGift -> Maybe Bool
is_private = Maybe Bool
is_private_
, pay_for_upgrade :: SendGift -> Maybe Bool
pay_for_upgrade = Maybe Bool
pay_for_upgrade_
}
= [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
"sendGift"
, 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
"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_
, Key
"pay_for_upgrade" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
pay_for_upgrade_
]
defaultSendGift :: SendGift
defaultSendGift :: SendGift
defaultSendGift =
SendGift
{ gift_id :: Maybe Int
gift_id = 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
, pay_for_upgrade :: Maybe Bool
pay_for_upgrade = Maybe Bool
forall a. Maybe a
Nothing
}