chore(avs): add firm communication address field to json parser
This commit is contained in:
parent
b68eff63ca
commit
1286dc7e78
@ -44,7 +44,7 @@ o .:?~ key = o .: key <|> maybe empty parseJSON go
|
|||||||
|
|
||||||
|
|
||||||
-- Like (.:?) but maps Just null to Nothing, ie. Nothing instead of Just ""
|
-- Like (.:?) but maps Just null to Nothing, ie. Nothing instead of Just ""
|
||||||
(.:?!) :: (MonoFoldable a, FromJSON a) => Object -> Text -> Parser (Maybe a)
|
(.:?!) :: (Canonical (Maybe a), FromJSON a) => Object -> Text -> Parser (Maybe a)
|
||||||
(.:?!) o k = canonical <$> (o .:? k)
|
(.:?!) o k = canonical <$> (o .:? k)
|
||||||
|
|
||||||
|
|
||||||
@ -521,6 +521,43 @@ instance ToJSON AvsPersonInfo where
|
|||||||
-- derivePersistFieldJSON ''AvsPersonInfo
|
-- derivePersistFieldJSON ''AvsPersonInfo
|
||||||
|
|
||||||
|
|
||||||
|
data AvsFirmCommunication = AvsFirmCommunication
|
||||||
|
{ avsCommunicationZIPCode :: Maybe Text
|
||||||
|
, avsCommunicationCity :: Maybe Text
|
||||||
|
, avsCommunicationCountry :: Maybe Text
|
||||||
|
, avsCommunicationStreetANDHouseNo :: Maybe Text
|
||||||
|
, avsCommunicationEMail :: Maybe Text
|
||||||
|
} deriving (Eq, Ord, Show, Generic)
|
||||||
|
|
||||||
|
instance {-# OVERLAPS #-} Canonical (Maybe AvsFirmCommunication) where
|
||||||
|
canonical (Just AvsFirmCommunication{..})
|
||||||
|
| isNothing avsCommunicationZIPCode
|
||||||
|
, isNothing avsCommunicationCity
|
||||||
|
, isNothing avsCommunicationCountry
|
||||||
|
, isNothing avsCommunicationStreetANDHouseNo
|
||||||
|
, isNothing avsCommunicationEMail
|
||||||
|
= Nothing
|
||||||
|
canonical other = other
|
||||||
|
|
||||||
|
makeLenses_ ''AvsFirmCommunication
|
||||||
|
|
||||||
|
instance FromJSON AvsFirmCommunication where
|
||||||
|
parseJSON = withObject "AvsFirmCommunication" $ \o -> AvsFirmCommunication
|
||||||
|
<$> o .:?! "ZIPCode"
|
||||||
|
<*> o .:?! "City"
|
||||||
|
<*> o .:?! "Country"
|
||||||
|
<*> o .:?! "StreetANDHouseNo"
|
||||||
|
<*> o .:?! "EMail"
|
||||||
|
|
||||||
|
instance ToJSON AvsFirmCommunication where
|
||||||
|
toJSON AvsFirmCommunication{..} = object $ catMaybes
|
||||||
|
[ ("ZIPCode" .=) <$> avsCommunicationZIPCode & canonical
|
||||||
|
, ("City" .=) <$> avsCommunicationCity & canonical
|
||||||
|
, ("Country" .=) <$> avsCommunicationCountry & canonical
|
||||||
|
, ("StreetANDHouseNo" .=) <$> avsCommunicationStreetANDHouseNo & canonical
|
||||||
|
, ("EMail" .=) <$> avsCommunicationEMail & canonical
|
||||||
|
]
|
||||||
|
|
||||||
data AvsFirmInfo = AvsFirmInfo
|
data AvsFirmInfo = AvsFirmInfo
|
||||||
{ avsFirmFirm :: Text
|
{ avsFirmFirm :: Text
|
||||||
, avsFirmFirmNo :: Int
|
, avsFirmFirmNo :: Int
|
||||||
@ -531,6 +568,7 @@ data AvsFirmInfo = AvsFirmInfo
|
|||||||
, avsFirmStreetANDHouseNo :: Maybe Text
|
, avsFirmStreetANDHouseNo :: Maybe Text
|
||||||
, avsFirmEMail :: Maybe Text
|
, avsFirmEMail :: Maybe Text
|
||||||
, avsFirmEMailSuperior :: Maybe Text
|
, avsFirmEMailSuperior :: Maybe Text
|
||||||
|
, avsFirmCommunication :: Maybe AvsFirmCommunication
|
||||||
} deriving (Eq, Ord, Show, Generic)
|
} deriving (Eq, Ord, Show, Generic)
|
||||||
|
|
||||||
makeLenses_ ''AvsFirmInfo
|
makeLenses_ ''AvsFirmInfo
|
||||||
@ -546,6 +584,7 @@ instance FromJSON AvsFirmInfo where
|
|||||||
<*> o .:?! "StreetANDHouseNo"
|
<*> o .:?! "StreetANDHouseNo"
|
||||||
<*> o .:?! "EMail"
|
<*> o .:?! "EMail"
|
||||||
<*> o .:?! "EMailSuperior"
|
<*> o .:?! "EMailSuperior"
|
||||||
|
<*> o .:?! "Communication"
|
||||||
|
|
||||||
instance ToJSON AvsFirmInfo where
|
instance ToJSON AvsFirmInfo where
|
||||||
toJSON AvsFirmInfo{..} = object $ catMaybes
|
toJSON AvsFirmInfo{..} = object $ catMaybes
|
||||||
@ -555,6 +594,7 @@ instance ToJSON AvsFirmInfo where
|
|||||||
, ("StreetANDHouseNo" .=) <$> avsFirmStreetANDHouseNo & canonical
|
, ("StreetANDHouseNo" .=) <$> avsFirmStreetANDHouseNo & canonical
|
||||||
, ("EMail" .=) <$> avsFirmEMail & canonical
|
, ("EMail" .=) <$> avsFirmEMail & canonical
|
||||||
, ("EMailSuperior" .=) <$> avsFirmEMailSuperior & canonical
|
, ("EMailSuperior" .=) <$> avsFirmEMailSuperior & canonical
|
||||||
|
, ("Communication" .=) <$> avsFirmCommunication & canonical
|
||||||
] <>
|
] <>
|
||||||
[ "Firm" .= avsFirmFirm
|
[ "Firm" .= avsFirmFirm
|
||||||
, "FirmNo" .= avsFirmFirmNo
|
, "FirmNo" .= avsFirmFirmNo
|
||||||
|
|||||||
Reference in New Issue
Block a user