module TD.Data.UpgradedGiftAttributeId
(UpgradedGiftAttributeId(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data UpgradedGiftAttributeId
= UpgradedGiftAttributeIdModel
{ UpgradedGiftAttributeId -> Maybe Int
sticker_id :: Maybe Int
}
| UpgradedGiftAttributeIdSymbol
{ sticker_id :: Maybe Int
}
| UpgradedGiftAttributeIdBackdrop
{ UpgradedGiftAttributeId -> Maybe Int
backdrop_id :: Maybe Int
}
deriving (UpgradedGiftAttributeId -> UpgradedGiftAttributeId -> Bool
(UpgradedGiftAttributeId -> UpgradedGiftAttributeId -> Bool)
-> (UpgradedGiftAttributeId -> UpgradedGiftAttributeId -> Bool)
-> Eq UpgradedGiftAttributeId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UpgradedGiftAttributeId -> UpgradedGiftAttributeId -> Bool
== :: UpgradedGiftAttributeId -> UpgradedGiftAttributeId -> Bool
$c/= :: UpgradedGiftAttributeId -> UpgradedGiftAttributeId -> Bool
/= :: UpgradedGiftAttributeId -> UpgradedGiftAttributeId -> Bool
Eq, Int -> UpgradedGiftAttributeId -> ShowS
[UpgradedGiftAttributeId] -> ShowS
UpgradedGiftAttributeId -> String
(Int -> UpgradedGiftAttributeId -> ShowS)
-> (UpgradedGiftAttributeId -> String)
-> ([UpgradedGiftAttributeId] -> ShowS)
-> Show UpgradedGiftAttributeId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UpgradedGiftAttributeId -> ShowS
showsPrec :: Int -> UpgradedGiftAttributeId -> ShowS
$cshow :: UpgradedGiftAttributeId -> String
show :: UpgradedGiftAttributeId -> String
$cshowList :: [UpgradedGiftAttributeId] -> ShowS
showList :: [UpgradedGiftAttributeId] -> ShowS
Show)
instance I.ShortShow UpgradedGiftAttributeId where
shortShow :: UpgradedGiftAttributeId -> String
shortShow UpgradedGiftAttributeIdModel
{ sticker_id :: UpgradedGiftAttributeId -> Maybe Int
sticker_id = Maybe Int
sticker_id_
}
= String
"UpgradedGiftAttributeIdModel"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"sticker_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
sticker_id_
]
shortShow UpgradedGiftAttributeIdSymbol
{ sticker_id :: UpgradedGiftAttributeId -> Maybe Int
sticker_id = Maybe Int
sticker_id_
}
= String
"UpgradedGiftAttributeIdSymbol"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"sticker_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
sticker_id_
]
shortShow UpgradedGiftAttributeIdBackdrop
{ backdrop_id :: UpgradedGiftAttributeId -> Maybe Int
backdrop_id = Maybe Int
backdrop_id_
}
= String
"UpgradedGiftAttributeIdBackdrop"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"backdrop_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
backdrop_id_
]
instance AT.FromJSON UpgradedGiftAttributeId where
parseJSON :: Value -> Parser UpgradedGiftAttributeId
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
"upgradedGiftAttributeIdModel" -> Value -> Parser UpgradedGiftAttributeId
parseUpgradedGiftAttributeIdModel Value
v
String
"upgradedGiftAttributeIdSymbol" -> Value -> Parser UpgradedGiftAttributeId
parseUpgradedGiftAttributeIdSymbol Value
v
String
"upgradedGiftAttributeIdBackdrop" -> Value -> Parser UpgradedGiftAttributeId
parseUpgradedGiftAttributeIdBackdrop Value
v
String
_ -> Parser UpgradedGiftAttributeId
forall a. Monoid a => a
mempty
where
parseUpgradedGiftAttributeIdModel :: A.Value -> AT.Parser UpgradedGiftAttributeId
parseUpgradedGiftAttributeIdModel :: Value -> Parser UpgradedGiftAttributeId
parseUpgradedGiftAttributeIdModel = String
-> (Object -> Parser UpgradedGiftAttributeId)
-> Value
-> Parser UpgradedGiftAttributeId
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"UpgradedGiftAttributeIdModel" ((Object -> Parser UpgradedGiftAttributeId)
-> Value -> Parser UpgradedGiftAttributeId)
-> (Object -> Parser UpgradedGiftAttributeId)
-> Value
-> Parser UpgradedGiftAttributeId
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
sticker_id_ <- (String -> Int) -> Maybe String -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
I.readInt64 (Maybe String -> Maybe Int)
-> Parser (Maybe String) -> Parser (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe String)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"sticker_id"
UpgradedGiftAttributeId -> Parser UpgradedGiftAttributeId
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (UpgradedGiftAttributeId -> Parser UpgradedGiftAttributeId)
-> UpgradedGiftAttributeId -> Parser UpgradedGiftAttributeId
forall a b. (a -> b) -> a -> b
$ UpgradedGiftAttributeIdModel
{ sticker_id :: Maybe Int
sticker_id = Maybe Int
sticker_id_
}
parseUpgradedGiftAttributeIdSymbol :: A.Value -> AT.Parser UpgradedGiftAttributeId
parseUpgradedGiftAttributeIdSymbol :: Value -> Parser UpgradedGiftAttributeId
parseUpgradedGiftAttributeIdSymbol = String
-> (Object -> Parser UpgradedGiftAttributeId)
-> Value
-> Parser UpgradedGiftAttributeId
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"UpgradedGiftAttributeIdSymbol" ((Object -> Parser UpgradedGiftAttributeId)
-> Value -> Parser UpgradedGiftAttributeId)
-> (Object -> Parser UpgradedGiftAttributeId)
-> Value
-> Parser UpgradedGiftAttributeId
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
sticker_id_ <- (String -> Int) -> Maybe String -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
I.readInt64 (Maybe String -> Maybe Int)
-> Parser (Maybe String) -> Parser (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe String)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"sticker_id"
UpgradedGiftAttributeId -> Parser UpgradedGiftAttributeId
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (UpgradedGiftAttributeId -> Parser UpgradedGiftAttributeId)
-> UpgradedGiftAttributeId -> Parser UpgradedGiftAttributeId
forall a b. (a -> b) -> a -> b
$ UpgradedGiftAttributeIdSymbol
{ sticker_id :: Maybe Int
sticker_id = Maybe Int
sticker_id_
}
parseUpgradedGiftAttributeIdBackdrop :: A.Value -> AT.Parser UpgradedGiftAttributeId
parseUpgradedGiftAttributeIdBackdrop :: Value -> Parser UpgradedGiftAttributeId
parseUpgradedGiftAttributeIdBackdrop = String
-> (Object -> Parser UpgradedGiftAttributeId)
-> Value
-> Parser UpgradedGiftAttributeId
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"UpgradedGiftAttributeIdBackdrop" ((Object -> Parser UpgradedGiftAttributeId)
-> Value -> Parser UpgradedGiftAttributeId)
-> (Object -> Parser UpgradedGiftAttributeId)
-> Value
-> Parser UpgradedGiftAttributeId
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
backdrop_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"backdrop_id"
UpgradedGiftAttributeId -> Parser UpgradedGiftAttributeId
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (UpgradedGiftAttributeId -> Parser UpgradedGiftAttributeId)
-> UpgradedGiftAttributeId -> Parser UpgradedGiftAttributeId
forall a b. (a -> b) -> a -> b
$ UpgradedGiftAttributeIdBackdrop
{ backdrop_id :: Maybe Int
backdrop_id = Maybe Int
backdrop_id_
}
parseJSON Value
_ = Parser UpgradedGiftAttributeId
forall a. Monoid a => a
mempty
instance AT.ToJSON UpgradedGiftAttributeId where
toJSON :: UpgradedGiftAttributeId -> Value
toJSON UpgradedGiftAttributeIdModel
{ sticker_id :: UpgradedGiftAttributeId -> Maybe Int
sticker_id = Maybe Int
sticker_id_
}
= [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
"upgradedGiftAttributeIdModel"
, Key
"sticker_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
sticker_id_
]
toJSON UpgradedGiftAttributeIdSymbol
{ sticker_id :: UpgradedGiftAttributeId -> Maybe Int
sticker_id = Maybe Int
sticker_id_
}
= [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
"upgradedGiftAttributeIdSymbol"
, Key
"sticker_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
sticker_id_
]
toJSON UpgradedGiftAttributeIdBackdrop
{ backdrop_id :: UpgradedGiftAttributeId -> Maybe Int
backdrop_id = Maybe Int
backdrop_id_
}
= [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
"upgradedGiftAttributeIdBackdrop"
, Key
"backdrop_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
backdrop_id_
]