chore(avs): add remaining queries to new unifying class
This commit is contained in:
parent
66ef4066b3
commit
caf8e8b71e
@ -247,7 +247,8 @@ avsPersonIdZero = AvsPersonId 0 -- this mus be zero acording to VSM specificatio
|
|||||||
newtype AvsObjPersonId = AvsObjPersonId -- tagged object
|
newtype AvsObjPersonId = AvsObjPersonId -- tagged object
|
||||||
{ avsObjPersonID :: AvsPersonId
|
{ avsObjPersonID :: AvsPersonId
|
||||||
}
|
}
|
||||||
deriving (Eq, Ord, Show, Generic)
|
deriving (Show, Generic)
|
||||||
|
deriving newtype (Eq, Ord, NFData, Binary)
|
||||||
deriveJSON defaultOptions
|
deriveJSON defaultOptions
|
||||||
{ fieldLabelModifier = dropCamel 2
|
{ fieldLabelModifier = dropCamel 2
|
||||||
, omitNothingFields = True
|
, omitNothingFields = True
|
||||||
@ -421,7 +422,7 @@ data AvsStatusPerson = AvsStatusPerson
|
|||||||
{ avsStatusPersonID :: AvsPersonId
|
{ avsStatusPersonID :: AvsPersonId
|
||||||
, avsStatusPersonCardStatus :: Set AvsDataPersonCard -- only delivers non-Maybe fields, all Maybe-fields are Nothing
|
, avsStatusPersonCardStatus :: Set AvsDataPersonCard -- only delivers non-Maybe fields, all Maybe-fields are Nothing
|
||||||
}
|
}
|
||||||
deriving (Eq, Ord, Show, Generic)
|
deriving (Eq, Ord, Show, Generic, NFData, Binary)
|
||||||
|
|
||||||
deriveJSON defaultOptions
|
deriveJSON defaultOptions
|
||||||
{ fieldLabelModifier = \case { "avsStatusPersonCardStatus" -> "personCardStatus"; others -> dropCamel 2 others }
|
{ fieldLabelModifier = \case { "avsStatusPersonCardStatus" -> "personCardStatus"; others -> dropCamel 2 others }
|
||||||
@ -517,7 +518,7 @@ data AvsPersonInfo = AvsPersonInfo
|
|||||||
, avsInfoPersonEMail :: Maybe Text
|
, avsInfoPersonEMail :: Maybe Text
|
||||||
, avsInfoPersonMobilePhoneNo :: Maybe Text
|
, avsInfoPersonMobilePhoneNo :: Maybe Text
|
||||||
, avsInfoInternalPersonalNo :: Maybe AvsInternalPersonalNo -- Fraport Personalnummer
|
, avsInfoInternalPersonalNo :: Maybe AvsInternalPersonalNo -- Fraport Personalnummer
|
||||||
} deriving (Eq, Ord, Show, Generic, NFData)
|
} deriving (Eq, Ord, Show, Generic, NFData, Binary)
|
||||||
|
|
||||||
makeLenses_ ''AvsPersonInfo
|
makeLenses_ ''AvsPersonInfo
|
||||||
|
|
||||||
@ -563,7 +564,7 @@ data AvsFirmCommunication = AvsFirmCommunication
|
|||||||
, avsCommunicationCountry :: Maybe Text
|
, avsCommunicationCountry :: Maybe Text
|
||||||
, avsCommunicationStreetANDHouseNo :: Maybe Text
|
, avsCommunicationStreetANDHouseNo :: Maybe Text
|
||||||
, avsCommunicationEMail :: Maybe Text
|
, avsCommunicationEMail :: Maybe Text
|
||||||
} deriving (Eq, Ord, Show, Generic, NFData)
|
} deriving (Eq, Ord, Show, Generic, NFData, Binary)
|
||||||
|
|
||||||
instance {-# OVERLAPS #-} Canonical (Maybe AvsFirmCommunication) where
|
instance {-# OVERLAPS #-} Canonical (Maybe AvsFirmCommunication) where
|
||||||
canonical (Just AvsFirmCommunication{..})
|
canonical (Just AvsFirmCommunication{..})
|
||||||
@ -610,7 +611,7 @@ data AvsFirmInfo = AvsFirmInfo
|
|||||||
, avsFirmEMail :: Maybe Text
|
, avsFirmEMail :: Maybe Text
|
||||||
, avsFirmEMailSuperior :: Maybe Text
|
, avsFirmEMailSuperior :: Maybe Text
|
||||||
, avsFirmCommunication :: Maybe AvsFirmCommunication
|
, avsFirmCommunication :: Maybe AvsFirmCommunication
|
||||||
} deriving (Eq, Ord, Show, Generic, NFData)
|
} deriving (Eq, Ord, Show, Generic, NFData, Binary)
|
||||||
|
|
||||||
makeLenses_ ''AvsFirmInfo
|
makeLenses_ ''AvsFirmInfo
|
||||||
|
|
||||||
@ -668,7 +669,7 @@ data AvsDataContact = AvsDataContact
|
|||||||
{ avsContactPersonID :: AvsPersonId
|
{ avsContactPersonID :: AvsPersonId
|
||||||
, avsContactPersonInfo :: AvsPersonInfo
|
, avsContactPersonInfo :: AvsPersonInfo
|
||||||
, avsContactFirmInfo :: AvsFirmInfo
|
, avsContactFirmInfo :: AvsFirmInfo
|
||||||
} deriving (Eq, Ord, Show, Generic)
|
} deriving (Eq, Ord, Show, Generic, NFData, Binary)
|
||||||
|
|
||||||
makeLenses_ ''AvsDataContact
|
makeLenses_ ''AvsDataContact
|
||||||
|
|
||||||
@ -691,7 +692,8 @@ deriveJSON defaultOptions
|
|||||||
|
|
||||||
type AvsResponseStatus :: Type
|
type AvsResponseStatus :: Type
|
||||||
newtype AvsResponseStatus = AvsResponseStatus (Set AvsStatusPerson)
|
newtype AvsResponseStatus = AvsResponseStatus (Set AvsStatusPerson)
|
||||||
deriving (Eq, Ord, Show, Generic)
|
deriving (Show, Generic)
|
||||||
|
deriving newtype (Eq, Ord, NFData, Binary)
|
||||||
makeWrapped ''AvsResponseStatus
|
makeWrapped ''AvsResponseStatus
|
||||||
deriveJSON defaultOptions
|
deriveJSON defaultOptions
|
||||||
{ fieldLabelModifier = dropCamel 2
|
{ fieldLabelModifier = dropCamel 2
|
||||||
@ -714,7 +716,8 @@ deriveJSON defaultOptions
|
|||||||
} ''AvsResponsePerson
|
} ''AvsResponsePerson
|
||||||
|
|
||||||
newtype AvsResponseContact = AvsResponseContact (Set AvsDataContact)
|
newtype AvsResponseContact = AvsResponseContact (Set AvsDataContact)
|
||||||
deriving (Eq, Ord, Show, Generic)
|
deriving (Show, Generic)
|
||||||
|
deriving newtype (Eq, Ord, NFData, Binary)
|
||||||
makeWrapped ''AvsResponseContact
|
makeWrapped ''AvsResponseContact
|
||||||
deriveJSON defaultOptions
|
deriveJSON defaultOptions
|
||||||
{ fieldLabelModifier = dropCamel 2
|
{ fieldLabelModifier = dropCamel 2
|
||||||
@ -771,19 +774,24 @@ deriveJSON defaultOptions
|
|||||||
} ''AvsQueryPerson
|
} ''AvsQueryPerson
|
||||||
|
|
||||||
newtype AvsQueryStatus = AvsQueryStatus (Set AvsPersonId)
|
newtype AvsQueryStatus = AvsQueryStatus (Set AvsPersonId)
|
||||||
deriving (Eq, Ord, Show, Generic)
|
deriving (Show, Generic)
|
||||||
|
deriving newtype (Eq, Ord, NFData, Binary)
|
||||||
deriveJSON defaultOptions ''AvsQueryStatus
|
deriveJSON defaultOptions ''AvsQueryStatus
|
||||||
makeWrapped ''AvsQueryStatus
|
makeWrapped ''AvsQueryStatus
|
||||||
|
|
||||||
newtype AvsQueryContact = AvsQueryContact (Set AvsObjPersonId) -- note the difference to AvsQueryStatus, which receives a list of id, whereas here we sent a list of single-field object
|
newtype AvsQueryContact = AvsQueryContact (Set AvsObjPersonId) -- note the difference to AvsQueryStatus, which receives a list of id, whereas here we sent a list of single-field object
|
||||||
deriving (Eq, Ord, Show, Generic)
|
deriving (Show, Generic)
|
||||||
|
deriving newtype (Eq, Ord, NFData, Binary)
|
||||||
deriveJSON defaultOptions ''AvsQueryContact
|
deriveJSON defaultOptions ''AvsQueryContact
|
||||||
makeWrapped ''AvsQueryContact
|
makeWrapped ''AvsQueryContact
|
||||||
|
|
||||||
newtype AvsQueryGetLicences = AvsQueryGetLicences AvsObjPersonId -- this should have been a set, but the specification was implemented differently
|
newtype AvsQueryGetLicences = AvsQueryGetLicences AvsObjPersonId -- this should have been a set, but the specification was implemented differently; also currently only allows to ask for all licences with ID 0
|
||||||
deriving (Eq, Ord, Show, Generic)
|
deriving (Eq, Ord, Show, Generic)
|
||||||
deriveJSON defaultOptions ''AvsQueryGetLicences
|
deriveJSON defaultOptions ''AvsQueryGetLicences
|
||||||
|
|
||||||
|
data AvsQueryGetAllLicences = AvsQueryGetAllLicences -- for convenience, encoding AvsQueryGetLicences (AvsObjPersonId avsPersonIdZero)
|
||||||
|
deriving (Eq, Ord, Show, Generic)
|
||||||
|
|
||||||
newtype AvsQuerySetLicences = AvsQuerySetLicences (Set AvsPersonLicence)
|
newtype AvsQuerySetLicences = AvsQuerySetLicences (Set AvsPersonLicence)
|
||||||
deriving (Eq, Ord, Show, Generic)
|
deriving (Eq, Ord, Show, Generic)
|
||||||
deriveJSON defaultOptions ''AvsQuerySetLicences
|
deriveJSON defaultOptions ''AvsQuerySetLicences
|
||||||
|
|||||||
@ -64,10 +64,6 @@ data AvsQuery = AvsQuery
|
|||||||
|
|
||||||
makeLenses_ ''AvsQuery
|
makeLenses_ ''AvsQuery
|
||||||
|
|
||||||
-- | To query all active licences, a special constant argument must be prepared
|
|
||||||
avsQueryAllLicences :: AvsQueryGetLicences
|
|
||||||
avsQueryAllLicences = AvsQueryGetLicences $ AvsObjPersonId avsPersonIdZero
|
|
||||||
|
|
||||||
|
|
||||||
-- | `SomeAvsQuery` is an umbrella to unify usage of all AVS queries, since Servant required separate types to fit the existing AVS-VSM API
|
-- | `SomeAvsQuery` is an umbrella to unify usage of all AVS queries, since Servant required separate types to fit the existing AVS-VSM API
|
||||||
class (SomeAvsQuery (SomeAvsCachable q), Binary (SomeAvsCachable q), Binary (SomeAvsResponse (SomeAvsCachable q)), Typeable (SomeAvsResponse (SomeAvsCachable q)), NFData (SomeAvsResponse (SomeAvsCachable q)))
|
class (SomeAvsQuery (SomeAvsCachable q), Binary (SomeAvsCachable q), Binary (SomeAvsResponse (SomeAvsCachable q)), Typeable (SomeAvsResponse (SomeAvsCachable q)), NFData (SomeAvsResponse (SomeAvsCachable q)))
|
||||||
@ -79,9 +75,21 @@ class (SomeAvsQuery (SomeAvsCachable q), Binary (SomeAvsCachable q), Binary (Som
|
|||||||
|
|
||||||
instance SomeAvsQuery AvsQueryPerson where
|
instance SomeAvsQuery AvsQueryPerson where
|
||||||
type SomeAvsResponse AvsQueryPerson = AvsResponsePerson
|
type SomeAvsResponse AvsQueryPerson = AvsResponsePerson
|
||||||
pickQuery = avsQueryPerson
|
pickQuery = avsQueryPerson
|
||||||
type SomeAvsCachable AvsQueryPerson = AvsQueryPerson
|
type SomeAvsCachable AvsQueryPerson = AvsQueryPerson
|
||||||
cacheable _ = Just (id, id)
|
cacheable _ = Just (id, id)
|
||||||
|
|
||||||
|
instance SomeAvsQuery AvsQueryStatus where
|
||||||
|
type SomeAvsResponse AvsQueryStatus = AvsResponseStatus
|
||||||
|
pickQuery = avsQueryStatus
|
||||||
|
type SomeAvsCachable AvsQueryStatus = AvsQueryStatus
|
||||||
|
cacheable _ = Just (id, id)
|
||||||
|
|
||||||
|
instance SomeAvsQuery AvsQueryContact where
|
||||||
|
type SomeAvsResponse AvsQueryContact = AvsResponseContact
|
||||||
|
pickQuery = avsQueryContact
|
||||||
|
type SomeAvsCachable AvsQueryContact = AvsQueryContact
|
||||||
|
cacheable _ = Just (id, id)
|
||||||
|
|
||||||
-- class (SomeAvsQuery q, Typeable q, Binary q, Binary (SomeAvsResponse q), Typeable (SomeAvsResponse q), NFData (SomeAvsResponse q)) => SomeAvsCachable q
|
-- class (SomeAvsQuery q, Typeable q, Binary q, Binary (SomeAvsResponse q), Typeable (SomeAvsResponse q), NFData (SomeAvsResponse q)) => SomeAvsCachable q
|
||||||
-- instance SomeAvsCachable AvsQueryPerson
|
-- instance SomeAvsCachable AvsQueryPerson
|
||||||
@ -92,12 +100,30 @@ instance SomeAvsQuery () where
|
|||||||
type SomeAvsCachable () = ()
|
type SomeAvsCachable () = ()
|
||||||
pickQuery _ () = return $ Right ()
|
pickQuery _ () = return $ Right ()
|
||||||
cacheable _ = Just (id,id)
|
cacheable _ = Just (id,id)
|
||||||
|
|
||||||
instance SomeAvsQuery AvsQuerySetLicences where
|
instance SomeAvsQuery AvsQuerySetLicences where
|
||||||
type SomeAvsResponse AvsQuerySetLicences = AvsResponseSetLicences
|
type SomeAvsResponse AvsQuerySetLicences = AvsResponseSetLicences
|
||||||
pickQuery = avsQuerySetLicences
|
pickQuery = avsQuerySetLicences
|
||||||
type SomeAvsCachable AvsQuerySetLicences = () -- not cachable
|
type SomeAvsCachable AvsQuerySetLicences = () -- not cachable
|
||||||
cacheable _ = Nothing
|
cacheable _ = Nothing
|
||||||
|
|
||||||
|
instance SomeAvsQuery AvsQueryGetAllLicences where
|
||||||
|
type SomeAvsResponse AvsQueryGetAllLicences = AvsResponseGetLicences
|
||||||
|
pickQuery = const . avsQueryGetAllLicences
|
||||||
|
type SomeAvsCachable AvsQueryGetAllLicences = () -- not cachable
|
||||||
|
cacheable _ = Nothing
|
||||||
|
|
||||||
|
-- AVS/VSM-Interface currently only allows to query ID 0, which means all licences
|
||||||
|
-- instance SomeAvsQuery AvsQueryGetLicences where
|
||||||
|
-- type SomeAvsResponse AvsQueryGetLicences = AvsResponseGetLicences
|
||||||
|
-- pickQuery = avsQuerySetLicences
|
||||||
|
-- type SomeAvsCachable AvsQueryGetLicences = () -- not cachable
|
||||||
|
-- cacheable _ = Nothing
|
||||||
|
|
||||||
|
-- | To query all active licences, a special constant argument must be prepared
|
||||||
|
avsQueryAllLicences :: AvsQueryGetLicences
|
||||||
|
avsQueryAllLicences = AvsQueryGetLicences $ AvsObjPersonId avsPersonIdZero
|
||||||
|
|
||||||
|
|
||||||
mkAvsQuery :: BaseUrl -> BasicAuthData -> ClientEnv -> AvsQuery
|
mkAvsQuery :: BaseUrl -> BasicAuthData -> ClientEnv -> AvsQuery
|
||||||
#ifdef DEVELOPMENT
|
#ifdef DEVELOPMENT
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user