chore(avs): adjust to newly refined VSM specifications (WIP)
This commit is contained in:
parent
39474d169c
commit
df559fead1
@ -137,10 +137,14 @@ instance ToJSON AvsLicence where
|
|||||||
toJSON AvsLicenceRollfeld = Number 2
|
toJSON AvsLicenceRollfeld = Number 2
|
||||||
|
|
||||||
instance FromJSON AvsLicence where
|
instance FromJSON AvsLicence where
|
||||||
parseJSON (Number n) | n == 0 = pure AvsNoLicence
|
parseJSON (Number n) | n == 1 = pure AvsLicenceVorfeld -- ordered by occurrence, n==1 is most common case
|
||||||
| n == 1 = pure AvsLicenceVorfeld
|
|
||||||
| n == 2 = pure AvsLicenceRollfeld
|
| n == 2 = pure AvsLicenceRollfeld
|
||||||
|
| n == 0 = pure AvsNoLicence -- n==0 never received from AVS, only sent to AVS
|
||||||
|
#ifdef DEVELOPMENT
|
||||||
parseJSON invalid = prependFailure "parsing AvsLicence failed, " $ fail $ "expected Int value being 0, 1 or 2. Found " ++ show invalid
|
parseJSON invalid = prependFailure "parsing AvsLicence failed, " $ fail $ "expected Int value being 0, 1 or 2. Found " ++ show invalid
|
||||||
|
#else
|
||||||
|
parseJSON _ = pure AvsNoLicence -- we simply ignore all other values
|
||||||
|
#endif
|
||||||
|
|
||||||
-- | Ought to be identical to QualificationShortname!
|
-- | Ought to be identical to QualificationShortname!
|
||||||
licence2char :: AvsLicence -> Char
|
licence2char :: AvsLicence -> Char
|
||||||
@ -312,8 +316,7 @@ deriveJSON defaultOptions
|
|||||||
|
|
||||||
data AvsPersonLicence = AvsPersonLicence
|
data AvsPersonLicence = AvsPersonLicence
|
||||||
{ avsLicencePersonID :: AvsPersonId
|
{ avsLicencePersonID :: AvsPersonId
|
||||||
, avsLicenceRampLicence :: AvsLicence -- Schnittstelle unklar: RampDrivingLicence oder RampLicence
|
, avsLicenceRampLicence :: AvsLicence
|
||||||
--, avsLicenceRampDrivingLicence :: AvsLicence
|
|
||||||
}
|
}
|
||||||
deriving (Eq, Ord, Show, Generic, Typeable)
|
deriving (Eq, Ord, Show, Generic, Typeable)
|
||||||
deriveJSON defaultOptions
|
deriveJSON defaultOptions
|
||||||
@ -324,16 +327,21 @@ deriveJSON defaultOptions
|
|||||||
} ''AvsPersonLicence
|
} ''AvsPersonLicence
|
||||||
|
|
||||||
data AvsLicenceResponse = AvsLicenceResponse
|
data AvsLicenceResponse = AvsLicenceResponse
|
||||||
{ avsResponsePersonID :: AvsPersonId
|
{ avsResponsePersonID :: AvsPersonId
|
||||||
, avsResponseSuccess :: SloppyBool
|
, avsResponseSuccess :: SloppyBool
|
||||||
, avsResponseMessage :: Text
|
, avsResponseMessage :: Text
|
||||||
}
|
}
|
||||||
|
| AvsErrorResponse
|
||||||
|
{ avsResponseStatus :: Text
|
||||||
|
, avsResponseMessage :: Text
|
||||||
|
}
|
||||||
deriving (Eq, Ord, Show, Generic, Typeable)
|
deriving (Eq, Ord, Show, Generic, Typeable)
|
||||||
deriveJSON defaultOptions
|
deriveJSON defaultOptions
|
||||||
{ fieldLabelModifier = dropCamel 2
|
{ fieldLabelModifier = dropCamel 2
|
||||||
, omitNothingFields = True
|
, omitNothingFields = True
|
||||||
, tagSingleConstructors = False
|
, tagSingleConstructors = False
|
||||||
, rejectUnknownFields = False
|
, rejectUnknownFields = False
|
||||||
|
, sumEncoding = UntaggedValue
|
||||||
} ''AvsLicenceResponse
|
} ''AvsLicenceResponse
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user