Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions obp-api/src/main/resources/props/sample.props.template
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,9 @@ apiOptions.getProductsIsPublic = true
apiOptions.getTransactionTypesIsPublic = true
apiOptions.getCurrentFxRateIsPublic = true

## Default Bank. Incase the server wants to support a default bank so developers don't have to specify BANK_ID
## Default Bank. Incase the server wants to support a default bank so developers don't have to specify BANK_ID, the default value is OBP.
## e.g. developers could use /my/accounts as well as /my/banks/BANK_ID/accounts
defaultBank.bank_id=THE_DEFAULT_BANK_ID
defaultBank.bank_id=OBP



Expand Down
3 changes: 2 additions & 1 deletion obp-api/src/main/scala/bootstrap/liftweb/Boot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ import code.regulatedentities.attribute.RegulatedEntityAttribute
import com.openbankproject.commons.model.ErrorMessage
import com.openbankproject.commons.util.Functions.Implicits._
import com.openbankproject.commons.util.{ApiVersion, Functions}

import code.bankaccountbalance.BankAccountBalance
import javax.mail.internet.MimeMessage
import net.liftweb.common._
import net.liftweb.db.{DB, DBLogEntry}
Expand Down Expand Up @@ -1129,6 +1129,7 @@ object ToSchemify {
CustomerAccountLink,
TransactionIdMapping,
RegulatedEntityAttribute,
BankAccountBalance
)

// start grpc server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5669,7 +5669,23 @@ object SwaggerDefinitionsJSON {
lazy val regulatedEntityAttributesJsonV510 = RegulatedEntityAttributesJsonV510(
List(regulatedEntityAttributeResponseJsonV510)
)

lazy val bankAccountBalanceRequestJsonV510 = BankAccountBalanceRequestJsonV510(
balance_type = balanceTypeExample.value,
balance_amount = balanceAmountExample.value
)

lazy val bankAccountBalanceResponseJsonV510 = BankAccountBalanceResponseJsonV510(
bank_id = bankIdExample.value,
account_id = accountIdExample.value,
balance_id = balanceIdExample.value,
balance_type = balanceTypeExample.value,
balance_amount = balanceAmountExample.value
)

lazy val bankAccountBalancesJsonV510 = BankAccountBalancesJsonV510(
balances = List(bankAccountBalanceResponseJsonV510)
)
//The common error or success format.
//Just some helper format to use in Json
case class NotSupportedYet()
Expand Down
18 changes: 17 additions & 1 deletion obp-api/src/main/scala/code/api/util/ApiRole.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,23 @@ object ApiRole extends MdcLoggable{

case class CanGetBankLevelEndpointTag(requiresBankId: Boolean = true) extends ApiRole
lazy val canGetBankLevelEndpointTag = CanGetBankLevelEndpointTag()


// // BankAccountBalance roles
case class CanCreateBankAccountBalance(requiresBankId: Boolean = true) extends ApiRole
lazy val canCreateBankAccountBalance = CanCreateBankAccountBalance()
//
// case class CanGetBankAccountBalance(requiresBankId: Boolean = false) extends ApiRole
// lazy val canGetBankAccountBalance = CanGetBankAccountBalance()
//
// case class CanGetBankAccountBalances(requiresBankId: Boolean = false) extends ApiRole
// lazy val canGetBankAccountBalances = CanGetBankAccountBalances()

case class CanUpdateBankAccountBalance(requiresBankId: Boolean = true) extends ApiRole
lazy val canUpdateBankAccountBalance = CanUpdateBankAccountBalance()

case class CanDeleteBankAccountBalance(requiresBankId: Boolean = true) extends ApiRole
lazy val canDeleteBankAccountBalance = CanDeleteBankAccountBalance()

case class CanCreateHistoricalTransactionAtBank(requiresBankId: Boolean = true) extends ApiRole
lazy val canCreateHistoricalTransactionAtBank = CanCreateHistoricalTransactionAtBank()

Expand Down
1 change: 1 addition & 0 deletions obp-api/src/main/scala/code/api/util/ApiTag.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ object ApiTag {
val apiTagMXOpenFinance = ResourceDocTag("MXOpenFinance")
val apiTagAggregateMetrics = ResourceDocTag("Aggregate-Metrics")
val apiTagSystemIntegrity = ResourceDocTag("System-Integrity")
val apiTagBalance = ResourceDocTag("Balance")
val apiTagWebhook = ResourceDocTag("Webhook")
val apiTagMockedData = ResourceDocTag("Mocked-Data")
val apiTagConsent = ResourceDocTag("Consent")
Expand Down
2 changes: 2 additions & 0 deletions obp-api/src/main/scala/code/api/util/ErrorMessages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ object ErrorMessages {
val InvalidUserProvider = "OBP-20103: Invalid DAuth User Provider."
val UserNotFoundByProviderAndProvideId= "OBP-20104: User not found by PROVIDER and PROVIDER_ID."

val BankAccountBalanceNotFoundById = "OBP-20105: BankAccountBalance not found. Please specify a valid value for BALANCE_ID."

// OAuth 2
val ApplicationNotIdentified = "OBP-20200: The application cannot be identified. "
val Oauth2IsNotAllowed = "OBP-20201: OAuth2 is not allowed at this instance."
Expand Down
6 changes: 6 additions & 0 deletions obp-api/src/main/scala/code/api/util/ExampleValue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,12 @@ object ExampleValue {
lazy val accountTypeExample = ConnectorField("AC","A short code that represents the type of the account as provided by the bank.")

lazy val balanceAmountExample = ConnectorField("50.89", "The balance on the account.")

lazy val balanceTypeExample = ConnectorField("openingBooked", "The balance type.")
glossaryItems += makeGlossaryItem("balance_type", balanceTypeExample)

lazy val balanceIdExample = ConnectorField("7uy8a7e4-6d02-40e3-a129-0b2bf89de8uh", "A string that MUST uniquely identify the Account Balance on this OBP instance, can be used in all cache.")
glossaryItems += makeGlossaryItem("balance_id", balanceIdExample)

lazy val amountExample = ConnectorField("10.12", "The balance on the account.")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package code.api.util.newstyle

import code.api.util.APIUtil.{OBPReturnType, unboxFullOrFail}
import code.bankconnectors.Connector
import code.api.util.{APIUtil, CallContext}
import code.api.util.CallContext
import code.api.util.ErrorMessages.BankAccountBalanceNotFoundById
import com.openbankproject.commons.ExecutionContext.Implicits.global
import com.openbankproject.commons.model.{AccountId, BankAccountBalanceTrait, BankId}
import com.openbankproject.commons.model.BalanceId


object BankAccountBalanceNewStyle {

def getBankAccountBalances(
accountId: AccountId,
callContext: Option[CallContext]
): OBPReturnType[List[BankAccountBalanceTrait]] = {
Connector.connector.vend.getBankAccountBalancesByAccountId(
accountId: AccountId,
callContext: Option[CallContext]
) map {
i => (APIUtil.connectorEmptyResponse(i._1, callContext), i._2)
}
}

def getBankAccountBalanceById(
balanceId: BalanceId,
callContext: Option[CallContext]
): OBPReturnType[BankAccountBalanceTrait] = {
Connector.connector.vend.getBankAccountBalanceById(
balanceId: BalanceId,
callContext: Option[CallContext]
).map {
result =>
(
unboxFullOrFail(
result._1,
result._2,
s"$BankAccountBalanceNotFoundById Current BALANCE_ID(${balanceId.value})",
404),
callContext
)
}
}

def createOrUpdateBankAccountBalance(
bankId: BankId,
accountId: AccountId,
balanceId: Option[BalanceId],
balanceType: String,
balanceAmount: BigDecimal,
callContext: Option[CallContext]
): OBPReturnType[BankAccountBalanceTrait] = {
Connector.connector.vend.createOrUpdateBankAccountBalance(
bankId: BankId,
accountId: AccountId,
balanceId: Option[BalanceId],
balanceType: String,
balanceAmount: BigDecimal,
callContext: Option[CallContext]
) map {
i => (APIUtil.connectorEmptyResponse(i._1, callContext), i._2)
}
}

def deleteBankAccountBalance(
balanceId: BalanceId,
callContext: Option[CallContext]
): OBPReturnType[Boolean] = {
Connector.connector.vend.deleteBankAccountBalance(
balanceId: BalanceId,
callContext: Option[CallContext]
) map {
i => (APIUtil.connectorEmptyResponse(i._1, callContext), i._2)
}
}

}
Loading