-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2387 from constantine2nd/develop
Fixed test
- Loading branch information
Showing
14 changed files
with
335 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
obp-api/src/main/scala/code/api/util/newstyle/BalanceNewStyle.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package code.api.util.newstyle | ||
|
||
import code.api.util.APIUtil.{OBPReturnType, unboxFullOrFail} | ||
import code.api.util.ErrorMessages.InvalidConnectorResponseForGetBankAccounts | ||
import code.api.util.{APIUtil, CallContext} | ||
import code.bankconnectors.Connector | ||
import code.views.Views | ||
import com.openbankproject.commons.model.{AccountBalances, AccountsBalances, BankId, BankIdAccountId, User, ViewId} | ||
|
||
import scala.concurrent.Future | ||
|
||
object BalanceNewStyle { | ||
|
||
import com.openbankproject.commons.ExecutionContext.Implicits.global | ||
|
||
def getAccountAccessAtBankThroughView(user: User, | ||
bankId: BankId, | ||
viewId: ViewId, | ||
callContext: Option[CallContext]): OBPReturnType[List[BankIdAccountId]] = { | ||
Future { | ||
val (views, accountAccesses) = Views.views.vend.getAccountAccessAtBankThroughView(user, bankId, viewId) | ||
// Filter views which can read the balance | ||
val canSeeBankAccountBalanceViews = views.filter(_.canSeeBankAccountBalance) | ||
// Filter accounts the user has permission to see balances and remove duplicates | ||
val allowedAccounts = APIUtil.intersectAccountAccessAndView(accountAccesses, canSeeBankAccountBalanceViews) | ||
allowedAccounts | ||
} map { | ||
(_, callContext) | ||
} | ||
} | ||
|
||
def getAccountAccessAtBank(user: User, | ||
bankId: BankId, | ||
callContext: Option[CallContext]): OBPReturnType[List[BankIdAccountId]] = { | ||
Future { | ||
val (views, accountAccesses) = Views.views.vend.privateViewsUserCanAccessAtBank(user, bankId) | ||
// Filter views which can read the balance | ||
val canSeeBankAccountBalanceViews = views.filter(_.canSeeBankAccountBalance) | ||
// Filter accounts the user has permission to see balances and remove duplicates | ||
val allowedAccounts = APIUtil.intersectAccountAccessAndView(accountAccesses, canSeeBankAccountBalanceViews) | ||
allowedAccounts | ||
} map { | ||
(_, callContext) | ||
} | ||
} | ||
|
||
def getBankAccountBalances(bankIdAccountId: BankIdAccountId, callContext: Option[CallContext]): OBPReturnType[AccountBalances] = { | ||
Connector.connector.vend.getBankAccountBalances(bankIdAccountId: BankIdAccountId, callContext: Option[CallContext]) map { i => | ||
(unboxFullOrFail(i._1, callContext,s"$InvalidConnectorResponseForGetBankAccounts", 400 ), i._2) | ||
} | ||
} | ||
|
||
def getBankAccountsBalances(bankIdAccountIds: List[BankIdAccountId], callContext: Option[CallContext]): OBPReturnType[AccountsBalances] = { | ||
Connector.connector.vend.getBankAccountsBalances(bankIdAccountIds: List[BankIdAccountId], callContext: Option[CallContext]) map { i => | ||
(unboxFullOrFail(i._1, callContext,s"$InvalidConnectorResponseForGetBankAccounts", 400 ), i._2) | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.