module TD.Data.EncryptedPassportElement
(EncryptedPassportElement(..)) 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.PassportElementType as PassportElementType
import qualified Data.ByteString as BS
import qualified TD.Data.DatedFile as DatedFile
import qualified Data.Text as T
data EncryptedPassportElement
= EncryptedPassportElement
{ EncryptedPassportElement -> Maybe PassportElementType
_type :: Maybe PassportElementType.PassportElementType
, EncryptedPassportElement -> Maybe ByteString
_data :: Maybe BS.ByteString
, EncryptedPassportElement -> Maybe DatedFile
front_side :: Maybe DatedFile.DatedFile
, EncryptedPassportElement -> Maybe DatedFile
reverse_side :: Maybe DatedFile.DatedFile
, EncryptedPassportElement -> Maybe DatedFile
selfie :: Maybe DatedFile.DatedFile
, EncryptedPassportElement -> Maybe [DatedFile]
translation :: Maybe [DatedFile.DatedFile]
, EncryptedPassportElement -> Maybe [DatedFile]
files :: Maybe [DatedFile.DatedFile]
, EncryptedPassportElement -> Maybe Text
value :: Maybe T.Text
, EncryptedPassportElement -> Maybe Text
hash :: Maybe T.Text
}
deriving (EncryptedPassportElement -> EncryptedPassportElement -> Bool
(EncryptedPassportElement -> EncryptedPassportElement -> Bool)
-> (EncryptedPassportElement -> EncryptedPassportElement -> Bool)
-> Eq EncryptedPassportElement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EncryptedPassportElement -> EncryptedPassportElement -> Bool
== :: EncryptedPassportElement -> EncryptedPassportElement -> Bool
$c/= :: EncryptedPassportElement -> EncryptedPassportElement -> Bool
/= :: EncryptedPassportElement -> EncryptedPassportElement -> Bool
Eq, Int -> EncryptedPassportElement -> ShowS
[EncryptedPassportElement] -> ShowS
EncryptedPassportElement -> String
(Int -> EncryptedPassportElement -> ShowS)
-> (EncryptedPassportElement -> String)
-> ([EncryptedPassportElement] -> ShowS)
-> Show EncryptedPassportElement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EncryptedPassportElement -> ShowS
showsPrec :: Int -> EncryptedPassportElement -> ShowS
$cshow :: EncryptedPassportElement -> String
show :: EncryptedPassportElement -> String
$cshowList :: [EncryptedPassportElement] -> ShowS
showList :: [EncryptedPassportElement] -> ShowS
Show)
instance I.ShortShow EncryptedPassportElement where
shortShow :: EncryptedPassportElement -> String
shortShow EncryptedPassportElement
{ _type :: EncryptedPassportElement -> Maybe PassportElementType
_type = Maybe PassportElementType
_type_
, _data :: EncryptedPassportElement -> Maybe ByteString
_data = Maybe ByteString
_data_
, front_side :: EncryptedPassportElement -> Maybe DatedFile
front_side = Maybe DatedFile
front_side_
, reverse_side :: EncryptedPassportElement -> Maybe DatedFile
reverse_side = Maybe DatedFile
reverse_side_
, selfie :: EncryptedPassportElement -> Maybe DatedFile
selfie = Maybe DatedFile
selfie_
, translation :: EncryptedPassportElement -> Maybe [DatedFile]
translation = Maybe [DatedFile]
translation_
, files :: EncryptedPassportElement -> Maybe [DatedFile]
files = Maybe [DatedFile]
files_
, value :: EncryptedPassportElement -> Maybe Text
value = Maybe Text
value_
, hash :: EncryptedPassportElement -> Maybe Text
hash = Maybe Text
hash_
}
= String
"EncryptedPassportElement"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"_type" String -> Maybe PassportElementType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe PassportElementType
_type_
, String
"_data" String -> Maybe ByteString -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ByteString
_data_
, String
"front_side" String -> Maybe DatedFile -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe DatedFile
front_side_
, String
"reverse_side" String -> Maybe DatedFile -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe DatedFile
reverse_side_
, String
"selfie" String -> Maybe DatedFile -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe DatedFile
selfie_
, String
"translation" String -> Maybe [DatedFile] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [DatedFile]
translation_
, String
"files" String -> Maybe [DatedFile] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [DatedFile]
files_
, String
"value" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
value_
, String
"hash" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
hash_
]
instance AT.FromJSON EncryptedPassportElement where
parseJSON :: Value -> Parser EncryptedPassportElement
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
"encryptedPassportElement" -> Value -> Parser EncryptedPassportElement
parseEncryptedPassportElement Value
v
String
_ -> Parser EncryptedPassportElement
forall a. Monoid a => a
mempty
where
parseEncryptedPassportElement :: A.Value -> AT.Parser EncryptedPassportElement
parseEncryptedPassportElement :: Value -> Parser EncryptedPassportElement
parseEncryptedPassportElement = String
-> (Object -> Parser EncryptedPassportElement)
-> Value
-> Parser EncryptedPassportElement
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"EncryptedPassportElement" ((Object -> Parser EncryptedPassportElement)
-> Value -> Parser EncryptedPassportElement)
-> (Object -> Parser EncryptedPassportElement)
-> Value
-> Parser EncryptedPassportElement
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe PassportElementType
_type_ <- Object
o Object -> Key -> Parser (Maybe PassportElementType)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"type"
Maybe ByteString
_data_ <- (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
"data"
Maybe DatedFile
front_side_ <- Object
o Object -> Key -> Parser (Maybe DatedFile)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"front_side"
Maybe DatedFile
reverse_side_ <- Object
o Object -> Key -> Parser (Maybe DatedFile)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"reverse_side"
Maybe DatedFile
selfie_ <- Object
o Object -> Key -> Parser (Maybe DatedFile)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"selfie"
Maybe [DatedFile]
translation_ <- Object
o Object -> Key -> Parser (Maybe [DatedFile])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"translation"
Maybe [DatedFile]
files_ <- Object
o Object -> Key -> Parser (Maybe [DatedFile])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"files"
Maybe Text
value_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"value"
Maybe Text
hash_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"hash"
EncryptedPassportElement -> Parser EncryptedPassportElement
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (EncryptedPassportElement -> Parser EncryptedPassportElement)
-> EncryptedPassportElement -> Parser EncryptedPassportElement
forall a b. (a -> b) -> a -> b
$ EncryptedPassportElement
{ _type :: Maybe PassportElementType
_type = Maybe PassportElementType
_type_
, _data :: Maybe ByteString
_data = Maybe ByteString
_data_
, front_side :: Maybe DatedFile
front_side = Maybe DatedFile
front_side_
, reverse_side :: Maybe DatedFile
reverse_side = Maybe DatedFile
reverse_side_
, selfie :: Maybe DatedFile
selfie = Maybe DatedFile
selfie_
, translation :: Maybe [DatedFile]
translation = Maybe [DatedFile]
translation_
, files :: Maybe [DatedFile]
files = Maybe [DatedFile]
files_
, value :: Maybe Text
value = Maybe Text
value_
, hash :: Maybe Text
hash = Maybe Text
hash_
}
parseJSON Value
_ = Parser EncryptedPassportElement
forall a. Monoid a => a
mempty