module TD.Data.PassportElementErrorSource
(PassportElementErrorSource(..)) 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 PassportElementErrorSource
= PassportElementErrorSourceUnspecified
| PassportElementErrorSourceDataField
{ PassportElementErrorSource -> Maybe Text
field_name :: Maybe T.Text
}
| PassportElementErrorSourceFrontSide
| PassportElementErrorSourceReverseSide
| PassportElementErrorSourceSelfie
| PassportElementErrorSourceTranslationFile
{ PassportElementErrorSource -> Maybe Int
file_index :: Maybe Int
}
| PassportElementErrorSourceTranslationFiles
| PassportElementErrorSourceFile
{ file_index :: Maybe Int
}
| PassportElementErrorSourceFiles
deriving (PassportElementErrorSource -> PassportElementErrorSource -> Bool
(PassportElementErrorSource -> PassportElementErrorSource -> Bool)
-> (PassportElementErrorSource
-> PassportElementErrorSource -> Bool)
-> Eq PassportElementErrorSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PassportElementErrorSource -> PassportElementErrorSource -> Bool
== :: PassportElementErrorSource -> PassportElementErrorSource -> Bool
$c/= :: PassportElementErrorSource -> PassportElementErrorSource -> Bool
/= :: PassportElementErrorSource -> PassportElementErrorSource -> Bool
Eq, Int -> PassportElementErrorSource -> ShowS
[PassportElementErrorSource] -> ShowS
PassportElementErrorSource -> String
(Int -> PassportElementErrorSource -> ShowS)
-> (PassportElementErrorSource -> String)
-> ([PassportElementErrorSource] -> ShowS)
-> Show PassportElementErrorSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PassportElementErrorSource -> ShowS
showsPrec :: Int -> PassportElementErrorSource -> ShowS
$cshow :: PassportElementErrorSource -> String
show :: PassportElementErrorSource -> String
$cshowList :: [PassportElementErrorSource] -> ShowS
showList :: [PassportElementErrorSource] -> ShowS
Show)
instance I.ShortShow PassportElementErrorSource where
shortShow :: PassportElementErrorSource -> String
shortShow PassportElementErrorSource
PassportElementErrorSourceUnspecified
= String
"PassportElementErrorSourceUnspecified"
shortShow PassportElementErrorSourceDataField
{ field_name :: PassportElementErrorSource -> Maybe Text
field_name = Maybe Text
field_name_
}
= String
"PassportElementErrorSourceDataField"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"field_name" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
field_name_
]
shortShow PassportElementErrorSource
PassportElementErrorSourceFrontSide
= String
"PassportElementErrorSourceFrontSide"
shortShow PassportElementErrorSource
PassportElementErrorSourceReverseSide
= String
"PassportElementErrorSourceReverseSide"
shortShow PassportElementErrorSource
PassportElementErrorSourceSelfie
= String
"PassportElementErrorSourceSelfie"
shortShow PassportElementErrorSourceTranslationFile
{ file_index :: PassportElementErrorSource -> Maybe Int
file_index = Maybe Int
file_index_
}
= String
"PassportElementErrorSourceTranslationFile"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"file_index" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
file_index_
]
shortShow PassportElementErrorSource
PassportElementErrorSourceTranslationFiles
= String
"PassportElementErrorSourceTranslationFiles"
shortShow PassportElementErrorSourceFile
{ file_index :: PassportElementErrorSource -> Maybe Int
file_index = Maybe Int
file_index_
}
= String
"PassportElementErrorSourceFile"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"file_index" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
file_index_
]
shortShow PassportElementErrorSource
PassportElementErrorSourceFiles
= String
"PassportElementErrorSourceFiles"
instance AT.FromJSON PassportElementErrorSource where
parseJSON :: Value -> Parser PassportElementErrorSource
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
"passportElementErrorSourceUnspecified" -> PassportElementErrorSource -> Parser PassportElementErrorSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PassportElementErrorSource
PassportElementErrorSourceUnspecified
String
"passportElementErrorSourceDataField" -> Value -> Parser PassportElementErrorSource
parsePassportElementErrorSourceDataField Value
v
String
"passportElementErrorSourceFrontSide" -> PassportElementErrorSource -> Parser PassportElementErrorSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PassportElementErrorSource
PassportElementErrorSourceFrontSide
String
"passportElementErrorSourceReverseSide" -> PassportElementErrorSource -> Parser PassportElementErrorSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PassportElementErrorSource
PassportElementErrorSourceReverseSide
String
"passportElementErrorSourceSelfie" -> PassportElementErrorSource -> Parser PassportElementErrorSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PassportElementErrorSource
PassportElementErrorSourceSelfie
String
"passportElementErrorSourceTranslationFile" -> Value -> Parser PassportElementErrorSource
parsePassportElementErrorSourceTranslationFile Value
v
String
"passportElementErrorSourceTranslationFiles" -> PassportElementErrorSource -> Parser PassportElementErrorSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PassportElementErrorSource
PassportElementErrorSourceTranslationFiles
String
"passportElementErrorSourceFile" -> Value -> Parser PassportElementErrorSource
parsePassportElementErrorSourceFile Value
v
String
"passportElementErrorSourceFiles" -> PassportElementErrorSource -> Parser PassportElementErrorSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PassportElementErrorSource
PassportElementErrorSourceFiles
String
_ -> Parser PassportElementErrorSource
forall a. Monoid a => a
mempty
where
parsePassportElementErrorSourceDataField :: A.Value -> AT.Parser PassportElementErrorSource
parsePassportElementErrorSourceDataField :: Value -> Parser PassportElementErrorSource
parsePassportElementErrorSourceDataField = String
-> (Object -> Parser PassportElementErrorSource)
-> Value
-> Parser PassportElementErrorSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PassportElementErrorSourceDataField" ((Object -> Parser PassportElementErrorSource)
-> Value -> Parser PassportElementErrorSource)
-> (Object -> Parser PassportElementErrorSource)
-> Value
-> Parser PassportElementErrorSource
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
field_name_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"field_name"
PassportElementErrorSource -> Parser PassportElementErrorSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PassportElementErrorSource -> Parser PassportElementErrorSource)
-> PassportElementErrorSource -> Parser PassportElementErrorSource
forall a b. (a -> b) -> a -> b
$ PassportElementErrorSourceDataField
{ field_name :: Maybe Text
field_name = Maybe Text
field_name_
}
parsePassportElementErrorSourceTranslationFile :: A.Value -> AT.Parser PassportElementErrorSource
parsePassportElementErrorSourceTranslationFile :: Value -> Parser PassportElementErrorSource
parsePassportElementErrorSourceTranslationFile = String
-> (Object -> Parser PassportElementErrorSource)
-> Value
-> Parser PassportElementErrorSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PassportElementErrorSourceTranslationFile" ((Object -> Parser PassportElementErrorSource)
-> Value -> Parser PassportElementErrorSource)
-> (Object -> Parser PassportElementErrorSource)
-> Value
-> Parser PassportElementErrorSource
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
file_index_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"file_index"
PassportElementErrorSource -> Parser PassportElementErrorSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PassportElementErrorSource -> Parser PassportElementErrorSource)
-> PassportElementErrorSource -> Parser PassportElementErrorSource
forall a b. (a -> b) -> a -> b
$ PassportElementErrorSourceTranslationFile
{ file_index :: Maybe Int
file_index = Maybe Int
file_index_
}
parsePassportElementErrorSourceFile :: A.Value -> AT.Parser PassportElementErrorSource
parsePassportElementErrorSourceFile :: Value -> Parser PassportElementErrorSource
parsePassportElementErrorSourceFile = String
-> (Object -> Parser PassportElementErrorSource)
-> Value
-> Parser PassportElementErrorSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PassportElementErrorSourceFile" ((Object -> Parser PassportElementErrorSource)
-> Value -> Parser PassportElementErrorSource)
-> (Object -> Parser PassportElementErrorSource)
-> Value
-> Parser PassportElementErrorSource
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
file_index_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"file_index"
PassportElementErrorSource -> Parser PassportElementErrorSource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PassportElementErrorSource -> Parser PassportElementErrorSource)
-> PassportElementErrorSource -> Parser PassportElementErrorSource
forall a b. (a -> b) -> a -> b
$ PassportElementErrorSourceFile
{ file_index :: Maybe Int
file_index = Maybe Int
file_index_
}
parseJSON Value
_ = Parser PassportElementErrorSource
forall a. Monoid a => a
mempty