module TD.Data.PassportAuthorizationForm
(PassportAuthorizationForm(..)) 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.PassportRequiredElement as PassportRequiredElement
import qualified Data.Text as T
data PassportAuthorizationForm
= PassportAuthorizationForm
{ PassportAuthorizationForm -> Maybe Int
_id :: Maybe Int
, PassportAuthorizationForm -> Maybe [PassportRequiredElement]
required_elements :: Maybe [PassportRequiredElement.PassportRequiredElement]
, PassportAuthorizationForm -> Maybe Text
privacy_policy_url :: Maybe T.Text
}
deriving (PassportAuthorizationForm -> PassportAuthorizationForm -> Bool
(PassportAuthorizationForm -> PassportAuthorizationForm -> Bool)
-> (PassportAuthorizationForm -> PassportAuthorizationForm -> Bool)
-> Eq PassportAuthorizationForm
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PassportAuthorizationForm -> PassportAuthorizationForm -> Bool
== :: PassportAuthorizationForm -> PassportAuthorizationForm -> Bool
$c/= :: PassportAuthorizationForm -> PassportAuthorizationForm -> Bool
/= :: PassportAuthorizationForm -> PassportAuthorizationForm -> Bool
Eq, Int -> PassportAuthorizationForm -> ShowS
[PassportAuthorizationForm] -> ShowS
PassportAuthorizationForm -> String
(Int -> PassportAuthorizationForm -> ShowS)
-> (PassportAuthorizationForm -> String)
-> ([PassportAuthorizationForm] -> ShowS)
-> Show PassportAuthorizationForm
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PassportAuthorizationForm -> ShowS
showsPrec :: Int -> PassportAuthorizationForm -> ShowS
$cshow :: PassportAuthorizationForm -> String
show :: PassportAuthorizationForm -> String
$cshowList :: [PassportAuthorizationForm] -> ShowS
showList :: [PassportAuthorizationForm] -> ShowS
Show)
instance I.ShortShow PassportAuthorizationForm where
shortShow :: PassportAuthorizationForm -> String
shortShow PassportAuthorizationForm
{ _id :: PassportAuthorizationForm -> Maybe Int
_id = Maybe Int
_id_
, required_elements :: PassportAuthorizationForm -> Maybe [PassportRequiredElement]
required_elements = Maybe [PassportRequiredElement]
required_elements_
, privacy_policy_url :: PassportAuthorizationForm -> Maybe Text
privacy_policy_url = Maybe Text
privacy_policy_url_
}
= String
"PassportAuthorizationForm"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
_id_
, String
"required_elements" String -> Maybe [PassportRequiredElement] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [PassportRequiredElement]
required_elements_
, String
"privacy_policy_url" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
privacy_policy_url_
]
instance AT.FromJSON PassportAuthorizationForm where
parseJSON :: Value -> Parser PassportAuthorizationForm
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
"passportAuthorizationForm" -> Value -> Parser PassportAuthorizationForm
parsePassportAuthorizationForm Value
v
String
_ -> Parser PassportAuthorizationForm
forall a. Monoid a => a
mempty
where
parsePassportAuthorizationForm :: A.Value -> AT.Parser PassportAuthorizationForm
parsePassportAuthorizationForm :: Value -> Parser PassportAuthorizationForm
parsePassportAuthorizationForm = String
-> (Object -> Parser PassportAuthorizationForm)
-> Value
-> Parser PassportAuthorizationForm
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PassportAuthorizationForm" ((Object -> Parser PassportAuthorizationForm)
-> Value -> Parser PassportAuthorizationForm)
-> (Object -> Parser PassportAuthorizationForm)
-> Value
-> Parser PassportAuthorizationForm
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"id"
Maybe [PassportRequiredElement]
required_elements_ <- Object
o Object -> Key -> Parser (Maybe [PassportRequiredElement])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"required_elements"
Maybe Text
privacy_policy_url_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"privacy_policy_url"
PassportAuthorizationForm -> Parser PassportAuthorizationForm
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PassportAuthorizationForm -> Parser PassportAuthorizationForm)
-> PassportAuthorizationForm -> Parser PassportAuthorizationForm
forall a b. (a -> b) -> a -> b
$ PassportAuthorizationForm
{ _id :: Maybe Int
_id = Maybe Int
_id_
, required_elements :: Maybe [PassportRequiredElement]
required_elements = Maybe [PassportRequiredElement]
required_elements_
, privacy_policy_url :: Maybe Text
privacy_policy_url = Maybe Text
privacy_policy_url_
}
parseJSON Value
_ = Parser PassportAuthorizationForm
forall a. Monoid a => a
mempty