mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 16:56:56 +00:00
Endpoint getCustomersForCurrentUserAtBank v3.1.0 rewritten in new style
This commit is contained in:
parent
5f32a1fb99
commit
705aab322a
@ -59,6 +59,7 @@ object NewStyle {
|
||||
(nameOf(Implementations2_0_0.addKycStatus), ApiVersion.v2_0_0.toString),
|
||||
(nameOf(Implementations2_0_0.addKycCheck), ApiVersion.v2_0_0.toString),
|
||||
(nameOf(Implementations2_1_0.getRoles), ApiVersion.v3_1_0.toString),
|
||||
(nameOf(Implementations2_1_0.getCustomersForCurrentUserAtBank), ApiVersion.v3_1_0.toString),
|
||||
(nameOf(Implementations2_2_0.config), ApiVersion.v2_2_0.toString),
|
||||
(nameOf(Implementations2_2_0.getViewsForBankAccount), ApiVersion.v2_2_0.toString),
|
||||
(nameOf(Implementations2_2_0.getCurrentFxRate), ApiVersion.v2_2_0.toString),
|
||||
|
||||
@ -1485,14 +1485,16 @@ trait APIMethods210 {
|
||||
case "banks" :: BankId(bankId) :: "customers" :: Nil JsonGet _ => {
|
||||
cc => {
|
||||
for {
|
||||
u <- cc.user ?~! UserNotLoggedIn
|
||||
(bank, callContext ) <- BankX(bankId, Some(cc)) ?~! {BankNotFound}
|
||||
customers <- tryo{CustomerX.customerProvider.vend.getCustomersByUserId(u.userId)} ?~! UserCustomerLinksNotFoundForUser
|
||||
// Filter so we only see the ones for the bank in question
|
||||
bankCustomers = customers.filter(_.bankId==bankId.value)
|
||||
(Full(u), callContext) <- authorizedAccess(cc)
|
||||
(_, callContext) <- NewStyle.function.getBank(bankId, callContext)
|
||||
(customers, callContext) <- Connector.connector.vend.getCustomersByUserId(u.userId, callContext) map {
|
||||
connectorEmptyResponse(_, callContext)
|
||||
}
|
||||
} yield {
|
||||
// Filter so we only see the ones for the bank in question
|
||||
val bankCustomers = customers.filter(_.bankId==bankId.value)
|
||||
val json = JSONFactory210.createCustomersJson(bankCustomers)
|
||||
successJsonResponse(Extraction.decompose(json))
|
||||
(json, HttpCode.`200`(callContext))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user