module TD.Data.FirebaseAuthenticationSettings
(FirebaseAuthenticationSettings(..)) 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
data FirebaseAuthenticationSettings
= FirebaseAuthenticationSettingsAndroid
| FirebaseAuthenticationSettingsIos
{ FirebaseAuthenticationSettings -> Maybe Text
device_token :: Maybe T.Text
, FirebaseAuthenticationSettings -> Maybe Bool
is_app_sandbox :: Maybe Bool
}
deriving (FirebaseAuthenticationSettings
-> FirebaseAuthenticationSettings -> Bool
(FirebaseAuthenticationSettings
-> FirebaseAuthenticationSettings -> Bool)
-> (FirebaseAuthenticationSettings
-> FirebaseAuthenticationSettings -> Bool)
-> Eq FirebaseAuthenticationSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FirebaseAuthenticationSettings
-> FirebaseAuthenticationSettings -> Bool
== :: FirebaseAuthenticationSettings
-> FirebaseAuthenticationSettings -> Bool
$c/= :: FirebaseAuthenticationSettings
-> FirebaseAuthenticationSettings -> Bool
/= :: FirebaseAuthenticationSettings
-> FirebaseAuthenticationSettings -> Bool
Eq, Int -> FirebaseAuthenticationSettings -> ShowS
[FirebaseAuthenticationSettings] -> ShowS
FirebaseAuthenticationSettings -> String
(Int -> FirebaseAuthenticationSettings -> ShowS)
-> (FirebaseAuthenticationSettings -> String)
-> ([FirebaseAuthenticationSettings] -> ShowS)
-> Show FirebaseAuthenticationSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FirebaseAuthenticationSettings -> ShowS
showsPrec :: Int -> FirebaseAuthenticationSettings -> ShowS
$cshow :: FirebaseAuthenticationSettings -> String
show :: FirebaseAuthenticationSettings -> String
$cshowList :: [FirebaseAuthenticationSettings] -> ShowS
showList :: [FirebaseAuthenticationSettings] -> ShowS
Show)
instance I.ShortShow FirebaseAuthenticationSettings where
shortShow :: FirebaseAuthenticationSettings -> String
shortShow FirebaseAuthenticationSettings
FirebaseAuthenticationSettingsAndroid
= String
"FirebaseAuthenticationSettingsAndroid"
shortShow FirebaseAuthenticationSettingsIos
{ device_token :: FirebaseAuthenticationSettings -> Maybe Text
device_token = Maybe Text
device_token_
, is_app_sandbox :: FirebaseAuthenticationSettings -> Maybe Bool
is_app_sandbox = Maybe Bool
is_app_sandbox_
}
= String
"FirebaseAuthenticationSettingsIos"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"device_token" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
device_token_
, String
"is_app_sandbox" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_app_sandbox_
]
instance AT.FromJSON FirebaseAuthenticationSettings where
parseJSON :: Value -> Parser FirebaseAuthenticationSettings
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
"firebaseAuthenticationSettingsAndroid" -> FirebaseAuthenticationSettings
-> Parser FirebaseAuthenticationSettings
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FirebaseAuthenticationSettings
FirebaseAuthenticationSettingsAndroid
String
"firebaseAuthenticationSettingsIos" -> Value -> Parser FirebaseAuthenticationSettings
parseFirebaseAuthenticationSettingsIos Value
v
String
_ -> Parser FirebaseAuthenticationSettings
forall a. Monoid a => a
mempty
where
parseFirebaseAuthenticationSettingsIos :: A.Value -> AT.Parser FirebaseAuthenticationSettings
parseFirebaseAuthenticationSettingsIos :: Value -> Parser FirebaseAuthenticationSettings
parseFirebaseAuthenticationSettingsIos = String
-> (Object -> Parser FirebaseAuthenticationSettings)
-> Value
-> Parser FirebaseAuthenticationSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"FirebaseAuthenticationSettingsIos" ((Object -> Parser FirebaseAuthenticationSettings)
-> Value -> Parser FirebaseAuthenticationSettings)
-> (Object -> Parser FirebaseAuthenticationSettings)
-> Value
-> Parser FirebaseAuthenticationSettings
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
device_token_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"device_token"
Maybe Bool
is_app_sandbox_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_app_sandbox"
FirebaseAuthenticationSettings
-> Parser FirebaseAuthenticationSettings
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (FirebaseAuthenticationSettings
-> Parser FirebaseAuthenticationSettings)
-> FirebaseAuthenticationSettings
-> Parser FirebaseAuthenticationSettings
forall a b. (a -> b) -> a -> b
$ FirebaseAuthenticationSettingsIos
{ device_token :: Maybe Text
device_token = Maybe Text
device_token_
, is_app_sandbox :: Maybe Bool
is_app_sandbox = Maybe Bool
is_app_sandbox_
}
parseJSON Value
_ = Parser FirebaseAuthenticationSettings
forall a. Monoid a => a
mempty
instance AT.ToJSON FirebaseAuthenticationSettings where
toJSON :: FirebaseAuthenticationSettings -> Value
toJSON FirebaseAuthenticationSettings
FirebaseAuthenticationSettingsAndroid
= [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
"firebaseAuthenticationSettingsAndroid"
]
toJSON FirebaseAuthenticationSettingsIos
{ device_token :: FirebaseAuthenticationSettings -> Maybe Text
device_token = Maybe Text
device_token_
, is_app_sandbox :: FirebaseAuthenticationSettings -> Maybe Bool
is_app_sandbox = Maybe Bool
is_app_sandbox_
}
= [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
"firebaseAuthenticationSettingsIos"
, Key
"device_token" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
device_token_
, Key
"is_app_sandbox" 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_app_sandbox_
]