module TD.Data.FirebaseDeviceVerificationParameters
(FirebaseDeviceVerificationParameters(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.ByteString as BS
import qualified Data.Text as T
data FirebaseDeviceVerificationParameters
=
{ FirebaseDeviceVerificationParameters -> Maybe ByteString
nonce :: Maybe BS.ByteString
}
| FirebaseDeviceVerificationParametersPlayIntegrity
{ FirebaseDeviceVerificationParameters -> Maybe Text
_nonce :: Maybe T.Text
, FirebaseDeviceVerificationParameters -> Maybe Int
cloud_project_number :: Maybe Int
}
deriving (FirebaseDeviceVerificationParameters
-> FirebaseDeviceVerificationParameters -> Bool
(FirebaseDeviceVerificationParameters
-> FirebaseDeviceVerificationParameters -> Bool)
-> (FirebaseDeviceVerificationParameters
-> FirebaseDeviceVerificationParameters -> Bool)
-> Eq FirebaseDeviceVerificationParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FirebaseDeviceVerificationParameters
-> FirebaseDeviceVerificationParameters -> Bool
== :: FirebaseDeviceVerificationParameters
-> FirebaseDeviceVerificationParameters -> Bool
$c/= :: FirebaseDeviceVerificationParameters
-> FirebaseDeviceVerificationParameters -> Bool
/= :: FirebaseDeviceVerificationParameters
-> FirebaseDeviceVerificationParameters -> Bool
Eq, Int -> FirebaseDeviceVerificationParameters -> ShowS
[FirebaseDeviceVerificationParameters] -> ShowS
FirebaseDeviceVerificationParameters -> String
(Int -> FirebaseDeviceVerificationParameters -> ShowS)
-> (FirebaseDeviceVerificationParameters -> String)
-> ([FirebaseDeviceVerificationParameters] -> ShowS)
-> Show FirebaseDeviceVerificationParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FirebaseDeviceVerificationParameters -> ShowS
showsPrec :: Int -> FirebaseDeviceVerificationParameters -> ShowS
$cshow :: FirebaseDeviceVerificationParameters -> String
show :: FirebaseDeviceVerificationParameters -> String
$cshowList :: [FirebaseDeviceVerificationParameters] -> ShowS
showList :: [FirebaseDeviceVerificationParameters] -> ShowS
Show)
instance I.ShortShow FirebaseDeviceVerificationParameters where
shortShow :: FirebaseDeviceVerificationParameters -> String
shortShow FirebaseDeviceVerificationParametersSafetyNet
{ nonce :: FirebaseDeviceVerificationParameters -> Maybe ByteString
nonce = Maybe ByteString
nonce_
}
= String
"FirebaseDeviceVerificationParametersSafetyNet"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"nonce" String -> Maybe ByteString -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ByteString
nonce_
]
shortShow FirebaseDeviceVerificationParametersPlayIntegrity
{ _nonce :: FirebaseDeviceVerificationParameters -> Maybe Text
_nonce = Maybe Text
_nonce_
, cloud_project_number :: FirebaseDeviceVerificationParameters -> Maybe Int
cloud_project_number = Maybe Int
cloud_project_number_
}
= String
"FirebaseDeviceVerificationParametersPlayIntegrity"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"_nonce" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
_nonce_
, String
"cloud_project_number" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
cloud_project_number_
]
instance AT.FromJSON FirebaseDeviceVerificationParameters where
parseJSON :: Value -> Parser FirebaseDeviceVerificationParameters
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
"firebaseDeviceVerificationParametersSafetyNet" -> Value -> Parser FirebaseDeviceVerificationParameters
parseFirebaseDeviceVerificationParametersSafetyNet Value
v
String
"firebaseDeviceVerificationParametersPlayIntegrity" -> Value -> Parser FirebaseDeviceVerificationParameters
parseFirebaseDeviceVerificationParametersPlayIntegrity Value
v
String
_ -> Parser FirebaseDeviceVerificationParameters
forall a. Monoid a => a
mempty
where
parseFirebaseDeviceVerificationParametersSafetyNet :: A.Value -> AT.Parser FirebaseDeviceVerificationParameters
parseFirebaseDeviceVerificationParametersSafetyNet :: Value -> Parser FirebaseDeviceVerificationParameters
parseFirebaseDeviceVerificationParametersSafetyNet = String
-> (Object -> Parser FirebaseDeviceVerificationParameters)
-> Value
-> Parser FirebaseDeviceVerificationParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"FirebaseDeviceVerificationParametersSafetyNet" ((Object -> Parser FirebaseDeviceVerificationParameters)
-> Value -> Parser FirebaseDeviceVerificationParameters)
-> (Object -> Parser FirebaseDeviceVerificationParameters)
-> Value
-> Parser FirebaseDeviceVerificationParameters
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe ByteString
nonce_ <- (String -> ByteString) -> Maybe String -> Maybe ByteString
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> ByteString
I.readBytes (Maybe String -> Maybe ByteString)
-> Parser (Maybe String) -> Parser (Maybe ByteString)
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
"nonce"
FirebaseDeviceVerificationParameters
-> Parser FirebaseDeviceVerificationParameters
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (FirebaseDeviceVerificationParameters
-> Parser FirebaseDeviceVerificationParameters)
-> FirebaseDeviceVerificationParameters
-> Parser FirebaseDeviceVerificationParameters
forall a b. (a -> b) -> a -> b
$ FirebaseDeviceVerificationParametersSafetyNet
{ nonce :: Maybe ByteString
nonce = Maybe ByteString
nonce_
}
parseFirebaseDeviceVerificationParametersPlayIntegrity :: A.Value -> AT.Parser FirebaseDeviceVerificationParameters
parseFirebaseDeviceVerificationParametersPlayIntegrity :: Value -> Parser FirebaseDeviceVerificationParameters
parseFirebaseDeviceVerificationParametersPlayIntegrity = String
-> (Object -> Parser FirebaseDeviceVerificationParameters)
-> Value
-> Parser FirebaseDeviceVerificationParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"FirebaseDeviceVerificationParametersPlayIntegrity" ((Object -> Parser FirebaseDeviceVerificationParameters)
-> Value -> Parser FirebaseDeviceVerificationParameters)
-> (Object -> Parser FirebaseDeviceVerificationParameters)
-> Value
-> Parser FirebaseDeviceVerificationParameters
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
_nonce_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"nonce"
Maybe Int
cloud_project_number_ <- (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
"cloud_project_number"
FirebaseDeviceVerificationParameters
-> Parser FirebaseDeviceVerificationParameters
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (FirebaseDeviceVerificationParameters
-> Parser FirebaseDeviceVerificationParameters)
-> FirebaseDeviceVerificationParameters
-> Parser FirebaseDeviceVerificationParameters
forall a b. (a -> b) -> a -> b
$ FirebaseDeviceVerificationParametersPlayIntegrity
{ _nonce :: Maybe Text
_nonce = Maybe Text
_nonce_
, cloud_project_number :: Maybe Int
cloud_project_number = Maybe Int
cloud_project_number_
}
parseJSON Value
_ = Parser FirebaseDeviceVerificationParameters
forall a. Monoid a => a
mempty