mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 17:56:46 +00:00
Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
commit
b7f38bddf5
@ -8,7 +8,7 @@
|
||||
<groupId>com.tesobe</groupId>
|
||||
<artifactId>obp-parent</artifactId>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
<version>1.4.4</version>
|
||||
<version>1.5.0</version>
|
||||
</parent>
|
||||
<artifactId>obp-api</artifactId>
|
||||
<packaging>war</packaging>
|
||||
|
||||
@ -5,7 +5,8 @@ import java.util.Date
|
||||
import code.api.util.APIUtil._
|
||||
import code.api.util.ExampleValue._
|
||||
import com.github.dwickern.macros.NameOf.nameOf
|
||||
import com.openbankproject.commons.model.{BankAccountCommons, CustomerCommons, InboundAdapterCallContext, InboundAdapterInfoInternal, InboundStatusMessage, _}
|
||||
import com.openbankproject.commons.model.enums.CustomerAttributeType
|
||||
import com.openbankproject.commons.model.{BankAccountCommons, CustomerAttributeCommons, CustomerCommons, InboundAdapterCallContext, InboundAdapterInfoInternal, InboundStatusMessage, _}
|
||||
import com.openbankproject.commons.util.ReflectUtils
|
||||
|
||||
import scala.collection.immutable.{List, Nil}
|
||||
@ -105,6 +106,8 @@ object MessageDocsSwaggerDefinitions
|
||||
|
||||
val inboundStatus = Status("Status errorCode", List(inboundStatusMessage))
|
||||
|
||||
val successStatus = Status("", List(inboundStatusMessage.copy(errorCode = "")))
|
||||
|
||||
val inboundAdapterInfoInternal = InboundAdapterInfoInternal(
|
||||
errorCode ="",
|
||||
backendMessages = List(inboundStatusMessage),
|
||||
@ -113,7 +116,7 @@ object MessageDocsSwaggerDefinitions
|
||||
git_commit = "String",
|
||||
date = DateWithMsExampleString
|
||||
)
|
||||
|
||||
|
||||
val bankCommons = BankCommons(
|
||||
bankId = BankId(bankIdExample.value),
|
||||
shortName = "The Royal Bank of Scotland",
|
||||
@ -163,6 +166,15 @@ object MessageDocsSwaggerDefinitions
|
||||
branchId = branchIdExample.value,
|
||||
nameSuffix = nameSuffixExample.value
|
||||
)
|
||||
|
||||
val customerAttribute = CustomerAttributeCommons(
|
||||
bankId = BankId(customerCommons.bankId),
|
||||
customerId = CustomerId(customerCommons.customerId),
|
||||
customerAttributeId = "some_customer_attributeId_value",
|
||||
attributeType = CustomerAttributeType.INTEGER,
|
||||
name = "customer_attribute_field",
|
||||
value = "example_value"
|
||||
)
|
||||
|
||||
val counterparty = Counterparty(
|
||||
nationalIdentifier= "", // This is the scheme a consumer would use to instruct a payment e.g. IBAN
|
||||
|
||||
@ -2,8 +2,10 @@ package code.api.util
|
||||
|
||||
import java.util.Date
|
||||
|
||||
import com.openbankproject.commons.dto.CustomerAndAttribute
|
||||
import com.openbankproject.commons.model.enums.TransactionRequestStatus
|
||||
import com.openbankproject.commons.model.enums.StrongCustomerAuthentication
|
||||
import com.openbankproject.commons.model.{CardAction, CardReplacementReason, PinResetReason}
|
||||
import com.openbankproject.commons.model.{CardAction, CardReplacementReason, InboundAdapterCallContext, OutboundAdapterCallContext, PinResetReason, Status}
|
||||
import com.openbankproject.commons.util.{EnumValue, ReflectUtils}
|
||||
import org.apache.commons.lang3.StringUtils
|
||||
|
||||
@ -14,6 +16,51 @@ import scala.reflect.runtime.{universe => ru}
|
||||
|
||||
object CodeGenerateUtils {
|
||||
|
||||
/**
|
||||
* when create example, if fieldName and|or fieldType match, the example is fixed value
|
||||
* @param fieldName fieldName, this value can be null, but should not together with tp are both null
|
||||
* @param tp fieldType, this value can be null, but should not together with fieldName are both null
|
||||
* @param example example string
|
||||
*/
|
||||
private case class NameTypeExample(fieldName: String, tp: Type, example: String) {
|
||||
assert(StringUtils.isNotBlank(fieldName) || tp != null, s"fieldName and tp should not both empty")
|
||||
|
||||
def isFieldMatch(fieldName: String, tp: Type): Boolean =
|
||||
if(tp != null && StringUtils.isNotBlank(this.fieldName)) {
|
||||
this.tp <:< tp && fieldName == this.fieldName
|
||||
} else if(tp != null) {
|
||||
this.tp <:< tp
|
||||
} else {
|
||||
fieldName == this.fieldName
|
||||
}
|
||||
|
||||
def getExample(fieldName: String, tp: Type): Option[String] =
|
||||
if(isFieldMatch(fieldName, tp)) {
|
||||
Some(example)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
// fixed example for given field or type
|
||||
private val fixedExamples: List[NameTypeExample] = List(
|
||||
NameTypeExample(null, typeOf[OutboundAdapterCallContext], "MessageDocsSwaggerDefinitions.outboundAdapterCallContext"),
|
||||
NameTypeExample(null, typeOf[InboundAdapterCallContext], "MessageDocsSwaggerDefinitions.inboundAdapterCallContext"),
|
||||
NameTypeExample("status", typeOf[Status], "MessageDocsSwaggerDefinitions.inboundStatus"),
|
||||
NameTypeExample("statusValue", typeOf[String], s""""${TransactionRequestStatus.values.mkString(" | ")}""""),
|
||||
NameTypeExample(null, typeOf[List[CustomerAndAttribute]],
|
||||
""" List(
|
||||
| CustomerAndAttribute(
|
||||
| MessageDocsSwaggerDefinitions.customerCommons,
|
||||
| List(MessageDocsSwaggerDefinitions.customerAttribute)
|
||||
| )
|
||||
| )
|
||||
|""".stripMargin),
|
||||
)
|
||||
|
||||
|
||||
private def getFixedExample(fieldName: String, tp: Type): Option[String] =
|
||||
fixedExamples.find(_.isFieldMatch(fieldName, tp)).map(_.example)
|
||||
|
||||
/**
|
||||
* create messageDocs example object string, for example exampleOutboundMessage and exampleInboundMessage,
|
||||
* this is just return a string for code generation
|
||||
@ -24,7 +71,11 @@ object CodeGenerateUtils {
|
||||
* @return initialize object string
|
||||
*/
|
||||
def createDocExample(tp: ru.Type, fieldName: Option[String] = None, parentFieldName: Option[String] = None, parentType: Option[ru.Type] = None): String = {
|
||||
if(tp =:= typeOf[CardAction]) {
|
||||
// if given fieldName and tp have fixed example, just return fixed example
|
||||
val fixedExample = getFixedExample(fieldName.orNull, tp)
|
||||
if(fixedExample.isDefined) {
|
||||
return fixedExample.get
|
||||
} else if(tp =:= typeOf[CardAction]) {
|
||||
return "com.openbankproject.commons.model.CardAction.DEBIT"
|
||||
} else if(tp =:= typeOf[CardReplacementReason]) {
|
||||
return "com.openbankproject.commons.model.CardReplacementReason.FIRST"
|
||||
@ -175,7 +226,7 @@ object CodeGenerateUtils {
|
||||
val valueName = symbol.name.toString.replaceFirst("^type$", "`type`")
|
||||
s"""$str,
|
||||
|${valueName}=${value}""".stripMargin
|
||||
}).substring(2)
|
||||
}).replaceFirst("""^\s*,\s*""", "")
|
||||
val withNew = if(!concreteObpType.get.typeSymbol.asClass.isCaseClass) "new" else ""
|
||||
s"$withNew ${concreteObpType.get.typeSymbol.name}($fields)"
|
||||
} else {
|
||||
|
||||
@ -9,7 +9,7 @@ import code.api.util.ApiRole.rolesMappedToClasses
|
||||
import code.api.v3_1_0.ListResult
|
||||
import code.util.Helper.MdcLoggable
|
||||
import com.openbankproject.commons.model.JsonFieldReName
|
||||
import com.openbankproject.commons.util.{EnumValue, Functions, JsonAbleSerializer, OBPEnumeration, ReflectUtils}
|
||||
import com.openbankproject.commons.util.{EnumValueSerializer, Functions, JsonAbleSerializer, ReflectUtils}
|
||||
import com.tesobe.CacheKeyFromArguments
|
||||
import net.liftweb.json.JsonAST.JValue
|
||||
import net.liftweb.json.{TypeInfo, compactRender, _}
|
||||
@ -66,21 +66,6 @@ object BigDecimalSerializer extends Serializer[BigDecimal] {
|
||||
}
|
||||
}
|
||||
|
||||
object EnumValueSerializer extends Serializer[EnumValue] {
|
||||
private val IntervalClass = classOf[EnumValue]
|
||||
|
||||
override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), EnumValue] = {
|
||||
case (TypeInfo(clazz, _), json) if(IntervalClass.isAssignableFrom(clazz)) => json match {
|
||||
case JString(s) => OBPEnumeration.withName(clazz.asInstanceOf[Class[EnumValue]], s)
|
||||
case x => throw new MappingException(s"Can't convert $x to $clazz")
|
||||
}
|
||||
}
|
||||
|
||||
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = {
|
||||
case x: EnumValue => JString(x.toString())
|
||||
}
|
||||
}
|
||||
|
||||
object FiledRenameSerializer extends Serializer[JsonFieldReName] {
|
||||
private val clazz = classOf[JsonFieldReName]
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ package code.api.util
|
||||
|
||||
import java.util.Objects
|
||||
import java.util.regex.Pattern
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestStatus._
|
||||
import com.openbankproject.commons.model.enums.TransactionRequestStatus._
|
||||
import code.api.Constant._
|
||||
|
||||
object ErrorMessages {
|
||||
|
||||
@ -20,11 +20,12 @@ import code.bankconnectors.Connector
|
||||
import code.bankconnectors.rest.RestConnector_vMar2019
|
||||
import code.branches.Branches.{Branch, DriveUpString, LobbyString}
|
||||
import code.consumer.Consumers
|
||||
import code.directdebit.DirectDebitTrait
|
||||
import com.openbankproject.commons.model.DirectDebitTrait
|
||||
import code.dynamicEntity.{DynamicEntityProvider, DynamicEntityT}
|
||||
import code.entitlement.Entitlement
|
||||
import code.entitlementrequest.EntitlementRequest
|
||||
import code.fx.{FXRate, MappedFXRate, fx}
|
||||
import code.fx.{MappedFXRate, fx}
|
||||
import com.openbankproject.commons.model.FXRate
|
||||
import code.metadata.counterparties.Counterparties
|
||||
import code.methodrouting.{MethodRoutingProvider, MethodRoutingT}
|
||||
import code.model._
|
||||
|
||||
@ -4,10 +4,9 @@ import java.util.Date
|
||||
|
||||
import code.api.util.APIUtil.{EmptyBody, PrimaryDataBody, ResourceDoc}
|
||||
import code.api.util.{ApiRole, PegdownOptions}
|
||||
import code.api.v2_1_0.CounterpartyIdJson
|
||||
import code.api.v3_1_0.ListResult
|
||||
import code.crm.CrmEvent.CrmEvent
|
||||
import code.transactionrequests.TransactionRequestTypeCharge
|
||||
import com.openbankproject.commons.model.TransactionRequestTypeCharge
|
||||
import com.openbankproject.commons.model.{Product, _}
|
||||
import com.openbankproject.commons.util.{EnumValue, OBPEnumeration, ReflectUtils}
|
||||
import net.liftweb.common.Full
|
||||
|
||||
@ -39,7 +39,7 @@ import code.api.v1_4_0.JSONFactory1_4_0._
|
||||
import code.api.v2_1_0.{JSONFactory210, LocationJsonV210, PostCounterpartyBespokeJson, ResourceUserJSON}
|
||||
import code.atms.Atms.Atm
|
||||
import code.branches.Branches.{Branch, DriveUpString, LobbyString}
|
||||
import code.fx.FXRate
|
||||
import com.openbankproject.commons.model.FXRate
|
||||
import code.metrics.ConnectorMetric
|
||||
import code.model.dataAccess.ResourceUser
|
||||
import code.model._
|
||||
|
||||
@ -520,7 +520,7 @@ trait APIMethods300 {
|
||||
//2 each bankAccount object find the proper view.
|
||||
//3 use view and user to moderate the bankaccount object.
|
||||
bankIdAccountId <- availableBankIdAccountIdList2
|
||||
bankAccount <- Connector.connector.vend.getBankAccount(bankIdAccountId.bankId, bankIdAccountId.accountId) ?~! s"$BankAccountNotFound Current Bank_Id(${bankIdAccountId.bankId}), Account_Id(${bankIdAccountId.accountId}) "
|
||||
bankAccount <- Connector.connector.vend.getBankAccountOld(bankIdAccountId.bankId, bankIdAccountId.accountId) ?~! s"$BankAccountNotFound Current Bank_Id(${bankIdAccountId.bankId}), Account_Id(${bankIdAccountId.accountId}) "
|
||||
moderatedAccount <- bankAccount.moderatedBankAccount(view, bankIdAccountId, Full(u), callContext) //Error handling is in lower method
|
||||
} yield {
|
||||
moderatedAccount
|
||||
|
||||
@ -41,7 +41,8 @@ import code.transactionChallenge.MappedExpectedChallengeAnswer
|
||||
import code.transactionrequests.MappedTransactionRequestProvider
|
||||
import code.transactionrequests.TransactionRequests.TransactionChallengeTypes._
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestTypes.{apply => _, _}
|
||||
import code.transactionrequests.TransactionRequests.{TransactionRequestStatus, TransactionRequestTypes}
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestTypes
|
||||
import com.openbankproject.commons.model.enums.TransactionRequestStatus
|
||||
import code.userlocks.UserLocksProvider
|
||||
import code.users.Users
|
||||
import code.util.Helper.booleanToBox
|
||||
|
||||
@ -40,7 +40,7 @@ import code.api.v3_0_0.JSONFactory300.createAccountRoutingsJSON
|
||||
import code.api.v3_0_0.{CustomerAttributeResponseJsonV300, ViewBasicV300}
|
||||
import code.api.v3_1_0.AccountAttributeResponseJson
|
||||
import code.api.v3_1_0.JSONFactory310.createAccountAttributeJson
|
||||
import code.directdebit.DirectDebitTrait
|
||||
import com.openbankproject.commons.model.DirectDebitTrait
|
||||
import code.entitlement.Entitlement
|
||||
import code.model.{Consumer, ModeratedBankAccountCore}
|
||||
import code.standingorders.StandingOrderTrait
|
||||
|
||||
@ -24,9 +24,8 @@ import code.bankconnectors.vMar2017.KafkaMappedConnector_vMar2017
|
||||
import code.bankconnectors.vMay2019.KafkaMappedConnector_vMay2019
|
||||
import code.bankconnectors.vSept2018.KafkaMappedConnector_vSept2018
|
||||
import code.branches.Branches.Branch
|
||||
import code.customerattribute.MappedCustomerAttribute
|
||||
import code.directdebit.DirectDebitTrait
|
||||
import code.fx.FXRate
|
||||
import com.openbankproject.commons.model.DirectDebitTrait
|
||||
import com.openbankproject.commons.model.FXRate
|
||||
import code.fx.fx.TTL
|
||||
import code.management.ImporterAPI.ImporterTransaction
|
||||
import code.model.dataAccess.ResourceUser
|
||||
@ -34,12 +33,13 @@ import code.model.toUserExtended
|
||||
import code.standingorders.StandingOrderTrait
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestTypes._
|
||||
import code.transactionrequests.TransactionRequests._
|
||||
import code.transactionrequests.{TransactionRequestTypeCharge, TransactionRequests}
|
||||
import code.transactionrequests.TransactionRequests
|
||||
import com.openbankproject.commons.model.TransactionRequestTypeCharge
|
||||
import code.users.Users
|
||||
import code.util.Helper._
|
||||
import code.util.JsonUtils
|
||||
import code.views.Views
|
||||
import com.openbankproject.commons.model.enums.{AccountAttributeType, AttributeCategory, AttributeType, CardAttributeType, CustomerAttributeType, DynamicEntityOperation, ProductAttributeType, TransactionAttributeType}
|
||||
import com.openbankproject.commons.model.enums.{AccountAttributeType, AttributeCategory, AttributeType, CardAttributeType, CustomerAttributeType, DynamicEntityOperation, ProductAttributeType, TransactionAttributeType, TransactionRequestStatus}
|
||||
import com.openbankproject.commons.model.{AccountApplication, Bank, CounterpartyTrait, CustomerAddress, Product, ProductCollection, ProductCollectionItem, TaxResidence, TransactionRequestStatus, UserAuthContext, UserAuthContextUpdate, _}
|
||||
import com.tesobe.CacheKeyFromArguments
|
||||
import net.liftweb.common.{Box, Empty, EmptyBox, Failure, Full, ParamFailure}
|
||||
@ -55,12 +55,13 @@ import com.openbankproject.commons.util.ReflectUtils
|
||||
import com.openbankproject.commons.util.Functions.lazyValue
|
||||
import net.liftweb.json
|
||||
|
||||
import scala.concurrent.Future
|
||||
import scala.concurrent.{Await, Future}
|
||||
import scala.concurrent.duration._
|
||||
import scala.math.{BigDecimal, BigInt}
|
||||
import scala.util.Random
|
||||
import scala.reflect.runtime.universe.{MethodSymbol, typeOf}
|
||||
import _root_.akka.http.scaladsl.model.HttpMethod
|
||||
import com.openbankproject.commons.dto.InBoundTrait
|
||||
|
||||
/*
|
||||
So we can switch between different sources of resources e.g.
|
||||
@ -212,6 +213,15 @@ trait Connector extends MdcLoggable {
|
||||
connectorMethods ++ result // result put after ++ to make sure methods of Connector's subtype be kept when name conflict.
|
||||
}
|
||||
|
||||
protected implicit def boxToTuple[T](box: Box[(T, Option[CallContext])]): (Box[T], Option[CallContext]) =
|
||||
(box.map(_._1), box.flatMap(_._2))
|
||||
|
||||
protected implicit def tupleToBoxTuple[T](tuple: (Box[T], Option[CallContext])): Box[(T, Option[CallContext])] =
|
||||
tuple._1.map(it => (it, tuple._2))
|
||||
|
||||
protected implicit def tupleToBox[T](tuple: (Box[T], Option[CallContext])): Box[T] = tuple._1
|
||||
|
||||
|
||||
/**
|
||||
* convert original return type future to OBPReturnType
|
||||
*
|
||||
@ -219,9 +229,8 @@ trait Connector extends MdcLoggable {
|
||||
* @tparam T future success value type
|
||||
* @return OBPReturnType type future
|
||||
*/
|
||||
protected implicit def futureReturnTypeToOBPReturnType[T](future: Future[Box[(T, Option[CallContext])]]): OBPReturnType[Box[T]] = future map {
|
||||
boxedTuple => (boxedTuple.map(_._1), boxedTuple.map(_._2).getOrElse(None))
|
||||
}
|
||||
protected implicit def futureReturnTypeToOBPReturnType[T](future: Future[Box[(T, Option[CallContext])]]): OBPReturnType[Box[T]] =
|
||||
future map boxToTuple
|
||||
|
||||
/**
|
||||
* convert OBPReturnType return type to original future type
|
||||
@ -230,8 +239,61 @@ trait Connector extends MdcLoggable {
|
||||
* @tparam T future success value type
|
||||
* @return original future type
|
||||
*/
|
||||
protected implicit def OBPReturnTypeToFutureReturnType[T](value: OBPReturnType[Box[T]]): Future[Box[(T, Option[CallContext])]] = value.map {
|
||||
tuple => tuple._1.map((_, tuple._2))
|
||||
protected implicit def OBPReturnTypeToFutureReturnType[T](value: OBPReturnType[Box[T]]): Future[Box[(T, Option[CallContext])]] =
|
||||
value map tupleToBoxTuple
|
||||
|
||||
private val futureTimeOut: Duration = 20 seconds
|
||||
/**
|
||||
* convert OBPReturnType return type to Tuple type
|
||||
*
|
||||
* @param value Tuple return type
|
||||
* @tparam T future success value type
|
||||
* @return original future tuple box type
|
||||
*/
|
||||
protected implicit def OBPReturnTypeToTupleBox[T](value: OBPReturnType[Box[T]]): (Box[T], Option[CallContext]) =
|
||||
Await.result(value, futureTimeOut)
|
||||
|
||||
/**
|
||||
* convert OBPReturnType return type to Box Tuple type
|
||||
*
|
||||
* @param value Box Tuple return type
|
||||
* @tparam T future success value type
|
||||
* @return original future box tuple type
|
||||
*/
|
||||
protected implicit def OBPReturnTypeToBoxTuple[T](value: OBPReturnType[Box[T]]): Box[(T, Option[CallContext])] =
|
||||
Await.result(
|
||||
OBPReturnTypeToFutureReturnType(value), 30 seconds
|
||||
)
|
||||
|
||||
/**
|
||||
* convert OBPReturnType return type to Box value
|
||||
*
|
||||
* @param value Box Tuple return type
|
||||
* @tparam T future success value type
|
||||
* @return original future box value
|
||||
*/
|
||||
protected implicit def OBPReturnTypeToBox[T](value: OBPReturnType[Box[T]]): Box[T] =
|
||||
Await.result(
|
||||
value.map(_._1),
|
||||
30 seconds
|
||||
)
|
||||
|
||||
protected def convertToTuple[T](callContext: Option[CallContext])(inbound: Box[InBoundTrait[T]]): (Box[T], Option[CallContext]) = {
|
||||
val boxedResult = inbound match {
|
||||
case Full(in) if (in.status.hasNoError) => Full(in.data)
|
||||
case Full(inbound) if (inbound.status.hasError) => {
|
||||
val errorMessage = "CoreBank - Status: " + inbound.status.backendMessages
|
||||
val errorCode: Int = try {
|
||||
inbound.status.errorCode.toInt
|
||||
} catch {
|
||||
case _: Throwable => 400
|
||||
}
|
||||
ParamFailure(errorMessage, Empty, Empty, APIFailure(errorMessage, errorCode))
|
||||
}
|
||||
case failureOrEmpty: Failure => failureOrEmpty
|
||||
}
|
||||
|
||||
(boxedResult, callContext)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -360,7 +422,7 @@ trait Connector extends MdcLoggable {
|
||||
def updateUserAccountViewsOld(user: ResourceUser) = {}
|
||||
|
||||
//This is old one, no callContext there. only for old style endpoints.
|
||||
def getBankAccount(bankId : BankId, accountId : AccountId) : Box[BankAccount]= {
|
||||
def getBankAccountOld(bankId : BankId, accountId : AccountId) : Box[BankAccount]= {
|
||||
getBankAccountLegacy(bankId, accountId, None).map(_._1)
|
||||
}
|
||||
|
||||
@ -369,12 +431,12 @@ trait Connector extends MdcLoggable {
|
||||
|
||||
//This one return the Future.
|
||||
def getBankAccount(bankId : BankId, accountId : AccountId, callContext: Option[CallContext]) : OBPReturnType[Box[BankAccount]]= Future{(Failure(setUnimplementedError),callContext)}
|
||||
|
||||
|
||||
def getBankAccountByIban(iban : String, callContext: Option[CallContext]) : OBPReturnType[Box[BankAccount]]= Future{(Failure(setUnimplementedError),callContext)}
|
||||
def getBankAccountByRouting(scheme : String, address : String, callContext: Option[CallContext]) : Box[(BankAccount, Option[CallContext])]= Failure(setUnimplementedError)
|
||||
|
||||
def getBankAccounts(bankIdAccountIds: List[BankIdAccountId], callContext: Option[CallContext]) : OBPReturnType[Box[List[BankAccount]]]= Future{(Failure(setUnimplementedError), callContext)}
|
||||
|
||||
|
||||
def getBankAccountsBalances(bankIdAccountIds: List[BankIdAccountId], callContext: Option[CallContext]) : OBPReturnType[Box[AccountsBalances]]= Future{(Failure(setUnimplementedError), callContext)}
|
||||
|
||||
def getCoreBankAccountsLegacy(bankIdAccountIds: List[BankIdAccountId], callContext: Option[CallContext]) : Box[(List[CoreAccount], Option[CallContext])] =
|
||||
@ -455,10 +517,10 @@ trait Connector extends MdcLoggable {
|
||||
}
|
||||
|
||||
def getPhysicalCards(user : User) : Box[List[PhysicalCard]] = Failure(setUnimplementedError)
|
||||
|
||||
|
||||
def getPhysicalCardForBank(bankId: BankId, cardId: String, callContext:Option[CallContext]) : OBPReturnType[Box[PhysicalCardTrait]] = Future{(Failure(setUnimplementedError), callContext)}
|
||||
def deletePhysicalCardForBank(bankId: BankId, cardId: String, callContext:Option[CallContext]) : OBPReturnType[Box[Boolean]] = Future{(Failure(setUnimplementedError), callContext)}
|
||||
|
||||
|
||||
def getPhysicalCardsForBankLegacy(bank: Bank, user : User, queryParams: List[OBPQueryParam]) : Box[List[PhysicalCard]] = Failure(setUnimplementedError)
|
||||
def getPhysicalCardsForBank(bank: Bank, user : User, queryParams: List[OBPQueryParam], callContext:Option[CallContext]) : OBPReturnType[Box[List[PhysicalCard]]] = Future{(Failure(setUnimplementedError), callContext)}
|
||||
|
||||
@ -534,7 +596,7 @@ trait Connector extends MdcLoggable {
|
||||
customerId: String,
|
||||
callContext: Option[CallContext]
|
||||
): OBPReturnType[Box[PhysicalCardTrait]] = Future{(Failure{setUnimplementedError}, callContext)}
|
||||
|
||||
|
||||
//Payments api: just return Failure("not supported") from makePaymentImpl if you don't want to implement it
|
||||
/**
|
||||
* \
|
||||
@ -548,10 +610,10 @@ trait Connector extends MdcLoggable {
|
||||
def makePayment(initiator : User, fromAccountUID : BankIdAccountId, toAccountUID : BankIdAccountId,
|
||||
amt : BigDecimal, description : String, transactionRequestType: TransactionRequestType) : Box[TransactionId] = {
|
||||
for{
|
||||
fromAccount <- getBankAccount(fromAccountUID.bankId, fromAccountUID.accountId) ?~
|
||||
fromAccount <- getBankAccountOld(fromAccountUID.bankId, fromAccountUID.accountId) ?~
|
||||
s"$BankAccountNotFound Account ${fromAccountUID.accountId} not found at bank ${fromAccountUID.bankId}"
|
||||
isOwner <- booleanToBox(initiator.hasOwnerViewAccess(BankIdAccountId(fromAccount.bankId,fromAccount.accountId)), UserNoOwnerView)
|
||||
toAccount <- getBankAccount(toAccountUID.bankId, toAccountUID.accountId) ?~
|
||||
toAccount <- getBankAccountOld(toAccountUID.bankId, toAccountUID.accountId) ?~
|
||||
s"$BankAccountNotFound Account ${toAccountUID.accountId} not found at bank ${toAccountUID.bankId}"
|
||||
sameCurrency <- booleanToBox(fromAccount.currency == toAccount.currency, {
|
||||
s"$InvalidTransactionRequestCurrency, Cannot send payment to account with different currency (From ${fromAccount.currency} to ${toAccount.currency}"
|
||||
@ -627,10 +689,10 @@ trait Connector extends MdcLoggable {
|
||||
|
||||
//create a new transaction request
|
||||
val request = for {
|
||||
fromAccountType <- getBankAccount(fromAccount.bankId, fromAccount.accountId) ?~
|
||||
fromAccountType <- getBankAccountOld(fromAccount.bankId, fromAccount.accountId) ?~
|
||||
s"account ${fromAccount.accountId} not found at bank ${fromAccount.bankId}"
|
||||
isOwner <- booleanToBox(initiator.hasOwnerViewAccess(BankIdAccountId(fromAccount.bankId,fromAccount.accountId)), UserNoOwnerView)
|
||||
toAccountType <- getBankAccount(toAccount.bankId, toAccount.accountId) ?~
|
||||
toAccountType <- getBankAccountOld(toAccount.bankId, toAccount.accountId) ?~
|
||||
s"account ${toAccount.accountId} not found at bank ${toAccount.bankId}"
|
||||
rawAmt <- tryo { BigDecimal(body.value.amount) } ?~! s"amount ${body.value.amount} not convertible to number"
|
||||
sameCurrency <- booleanToBox(fromAccount.currency == toAccount.currency, {
|
||||
@ -687,9 +749,9 @@ trait Connector extends MdcLoggable {
|
||||
|
||||
// Always create a new Transaction Request
|
||||
val request = for {
|
||||
fromAccountType <- getBankAccount(fromAccount.bankId, fromAccount.accountId) ?~ s"account ${fromAccount.accountId} not found at bank ${fromAccount.bankId}"
|
||||
fromAccountType <- getBankAccountOld(fromAccount.bankId, fromAccount.accountId) ?~ s"account ${fromAccount.accountId} not found at bank ${fromAccount.bankId}"
|
||||
isOwner <- booleanToBox(initiator.hasOwnerViewAccess(BankIdAccountId(fromAccount.bankId,fromAccount.accountId)) == true || hasEntitlement(fromAccount.bankId.value, initiator.userId, canCreateAnyTransactionRequest) == true, ErrorMessages.InsufficientAuthorisationToCreateTransactionRequest)
|
||||
toAccountType <- getBankAccount(toAccount.bankId, toAccount.accountId) ?~ s"account ${toAccount.accountId} not found at bank ${toAccount.bankId}"
|
||||
toAccountType <- getBankAccountOld(toAccount.bankId, toAccount.accountId) ?~ s"account ${toAccount.accountId} not found at bank ${toAccount.bankId}"
|
||||
rawAmt <- tryo { BigDecimal(body.value.amount) } ?~! s"amount ${body.value.amount} not convertible to number"
|
||||
// isValidTransactionRequestType is checked at API layer. Maybe here too.
|
||||
isPositiveAmtToSend <- booleanToBox(rawAmt > BigDecimal("0"), s"Can't send a payment with a value of 0 or less. (${rawAmt})")
|
||||
@ -851,17 +913,17 @@ trait Connector extends MdcLoggable {
|
||||
for {
|
||||
//if challenge necessary, create a new one
|
||||
(challengeId, callContext) <- createChallenge(
|
||||
fromAccount.bankId,
|
||||
fromAccount.accountId,
|
||||
initiator.userId,
|
||||
transactionRequestType: TransactionRequestType,
|
||||
fromAccount.bankId,
|
||||
fromAccount.accountId,
|
||||
initiator.userId,
|
||||
transactionRequestType: TransactionRequestType,
|
||||
transactionRequest.id.value,
|
||||
scaMethod,
|
||||
callContext
|
||||
) map { i =>
|
||||
(unboxFullOrFail(i._1, callContext, s"$InvalidConnectorResponseForGetChargeLevel ", 400), i._2)
|
||||
}
|
||||
|
||||
|
||||
newChallenge = TransactionRequestChallenge(challengeId, allowed_attempts = 3, challenge_type = challengeType.getOrElse(TransactionChallengeTypes.OTP_VIA_API.toString))
|
||||
_ <- Future (saveTransactionRequestChallenge(transactionRequest.id, newChallenge))
|
||||
transactionRequest <- Future(transactionRequest.copy(challenge = newChallenge))
|
||||
@ -966,7 +1028,7 @@ trait Connector extends MdcLoggable {
|
||||
permission <- Views.views.vend.permissions(BankIdAccountId(bankId, accountId))
|
||||
) yield {
|
||||
// Check the user has granted view with action canAddTransactionRequestToAnyAccount
|
||||
// in case it's true the a challenge will be sent to it
|
||||
// in case it's true the a challenge will be sent to it
|
||||
permission.views.exists(_.canAddTransactionRequestToAnyAccount == true) match {
|
||||
case true => Some(permission.user)
|
||||
case _ => None
|
||||
@ -1047,14 +1109,14 @@ trait Connector extends MdcLoggable {
|
||||
chargePolicy: String
|
||||
)
|
||||
|
||||
def saveTransactionRequestTransaction(transactionRequestId: TransactionRequestId, transactionId: TransactionId) = {
|
||||
def saveTransactionRequestTransaction(transactionRequestId: TransactionRequestId, transactionId: TransactionId): Box[Boolean] = {
|
||||
//put connector agnostic logic here if necessary
|
||||
saveTransactionRequestTransactionImpl(transactionRequestId, transactionId)
|
||||
}
|
||||
|
||||
protected def saveTransactionRequestTransactionImpl(transactionRequestId: TransactionRequestId, transactionId: TransactionId): Box[Boolean] = LocalMappedConnector.saveTransactionRequestTransactionImpl(transactionRequestId: TransactionRequestId, transactionId: TransactionId)
|
||||
|
||||
def saveTransactionRequestChallenge(transactionRequestId: TransactionRequestId, challenge: TransactionRequestChallenge) = {
|
||||
def saveTransactionRequestChallenge(transactionRequestId: TransactionRequestId, challenge: TransactionRequestChallenge): Box[Boolean] = {
|
||||
//put connector agnostic logic here if necessary
|
||||
saveTransactionRequestChallengeImpl(transactionRequestId, challenge)
|
||||
}
|
||||
@ -1066,7 +1128,7 @@ trait Connector extends MdcLoggable {
|
||||
def getTransactionRequests(initiator : User, fromAccount : BankAccount) : Box[List[TransactionRequest]] = {
|
||||
val transactionRequests =
|
||||
for {
|
||||
fromAccount <- getBankAccount(fromAccount.bankId, fromAccount.accountId) ?~
|
||||
fromAccount <- getBankAccountOld(fromAccount.bankId, fromAccount.accountId) ?~
|
||||
s"account ${fromAccount.accountId} not found at bank ${fromAccount.bankId}"
|
||||
isOwner <- booleanToBox(initiator.hasOwnerViewAccess(BankIdAccountId(fromAccount.bankId,fromAccount.accountId)), UserNoOwnerView)
|
||||
transactionRequests <- getTransactionRequestsImpl(fromAccount)
|
||||
|
||||
@ -0,0 +1,447 @@
|
||||
package code.bankconnectors
|
||||
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
|
||||
import code.api.util.{APIUtil, CallContext}
|
||||
import code.api.util.CodeGenerateUtils.createDocExample
|
||||
import code.bankconnectors.vSept2018.KafkaMappedConnector_vSept2018
|
||||
import com.openbankproject.commons.util.ReflectUtils
|
||||
import org.apache.commons.io.FileUtils
|
||||
import org.apache.commons.lang3.StringUtils.uncapitalize
|
||||
|
||||
import scala.collection.immutable.List
|
||||
import scala.language.postfixOps
|
||||
import scala.reflect.runtime.universe._
|
||||
import scala.reflect.runtime.{universe => ru}
|
||||
|
||||
/**
|
||||
* this is util for Connector builders, this should never be called by product code.
|
||||
*/
|
||||
object ConnectorBuilderUtil {
|
||||
// rewrite method code.webuiprops.MappedWebUiPropsProvider#getWebUiPropsValue, avoid access DB cause dataSource not found exception
|
||||
{
|
||||
import javassist.ClassPool
|
||||
val pool = ClassPool.getDefault
|
||||
val ct = pool.getCtClass("code.webuiprops.MappedWebUiPropsProvider$")
|
||||
val m = ct.getDeclaredMethod("getWebUiPropsValue")
|
||||
m.insertBefore("""return ""; """)
|
||||
ct.toClass
|
||||
}
|
||||
|
||||
private val mirror: ru.Mirror = ru.runtimeMirror(getClass().getClassLoader)
|
||||
private val clazz: ru.ClassSymbol = ru.typeOf[Connector].typeSymbol.asClass
|
||||
private val classMirror: ru.ClassMirror = mirror.reflectClass(clazz)
|
||||
/*
|
||||
* generateMethods and buildMethods has the same function, only responseExpression parameter type
|
||||
* different, because overload method can't compile for different responseExpression parameter.
|
||||
*/
|
||||
|
||||
def generateMethods(connectorMethodNames: List[String], connectorCodePath: String, responseExpression: String,
|
||||
setTopic: Boolean = false, doCache: Boolean = false) =
|
||||
buildMethods(connectorMethodNames, connectorCodePath, _ => responseExpression, setTopic, doCache)
|
||||
|
||||
def buildMethods(connectorMethodNames: List[String], connectorCodePath: String, connectorMethodToResponse: String => String,
|
||||
setTopic: Boolean = false, doCache: Boolean = false): Unit = {
|
||||
|
||||
val nameSignature: Iterable[ConnectorMethodGenerator] = ru.typeOf[Connector].decls
|
||||
.filter(_.isMethod)
|
||||
.filter(it => connectorMethodNames.contains(it.name.toString))
|
||||
.map(it => {
|
||||
val (methodName, typeSignature) = (it.name.toString, it.typeSignature)
|
||||
ConnectorMethodGenerator(methodName, typeSignature)
|
||||
})
|
||||
|
||||
// check whether some methods names are wrong typo
|
||||
if(connectorMethodNames.size > nameSignature.size) {
|
||||
val generatedMethodsNames = nameSignature.map(_.methodName).toSet
|
||||
val invalidMethodNames = connectorMethodNames.filterNot(generatedMethodsNames.contains(_))
|
||||
throw new IllegalArgumentException(s"Some methods not be supported, please check following methods: ${invalidMethodNames.mkString(", \n")}")
|
||||
}
|
||||
|
||||
val codeList = nameSignature.map(_.toCode(connectorMethodToResponse, setTopic, doCache))
|
||||
|
||||
// private val types: Iterable[ru.Type] = symbols.map(_.typeSignature)
|
||||
// println(symbols)
|
||||
println("-------------------")
|
||||
codeList.foreach(println(_))
|
||||
println("===================")
|
||||
|
||||
val path = new File(getClass.getResource("").toURI.toString.replaceFirst("target/.*", "").replace("file:", ""), connectorCodePath)
|
||||
val source = FileUtils.readFileToString(path, "utf-8")
|
||||
val start = "//---------------- dynamic start -------------------please don't modify this line"
|
||||
val end = "//---------------- dynamic end ---------------------please don't modify this line"
|
||||
val placeHolderInSource = s"""(?s)$start.+$end"""
|
||||
val currentTime = APIUtil.DateWithSecondsFormat.format(new Date())
|
||||
val insertCode =
|
||||
s"""$start
|
||||
|// ---------- create on $currentTime
|
||||
|${codeList.mkString}
|
||||
|// ---------- create on $currentTime
|
||||
|$end """.stripMargin
|
||||
val newSource = source.replaceFirst(placeHolderInSource, insertCode)
|
||||
FileUtils.writeStringToFile(path, newSource, "utf-8")
|
||||
}
|
||||
|
||||
|
||||
private case class ConnectorMethodGenerator(methodName: String, tp: Type) {
|
||||
private[this] def paramAnResult = tp.toString
|
||||
.replaceAll("""[.\w]+\.(\w+\.([A-Z]+\b|Value)\b)""", "$1") // two times replaceAll to delete package name, but keep enum type name
|
||||
.replaceAll("""([.\w]+\.){2,}(\w+\b)""", "$2")
|
||||
.replaceFirst("\\)", "): ")
|
||||
.replace("cardAttributeType: Value", "cardAttributeType: CardAttributeType.Value") // scala enum is bad for Reflection
|
||||
.replace("productAttributeType: Value", "productAttributeType: ProductAttributeType.Value") // scala enum is bad for Reflection
|
||||
.replace("accountAttributeType: Value", "accountAttributeType: AccountAttributeType.Value") // scala enum is bad for Reflection
|
||||
.replaceFirst("""\btype\b""", "`type`")
|
||||
|
||||
private[this] val params = tp.paramLists(0).filterNot(_.asTerm.info =:= ru.typeOf[Option[CallContext]]).map(_.name.toString).mkString(", ", ", ", "").replaceFirst("""\btype\b""", "`type`")
|
||||
private[this] val description = methodName.replaceAll("""(\w)([A-Z])""", "$1 $2").capitalize
|
||||
|
||||
private[this] val entityName = methodName.replaceFirst("^[a-z]+(OrUpdate)?", "")
|
||||
|
||||
private[this] val resultType = tp.resultType.toString.replaceAll("(\\w+\\.)+", "")
|
||||
|
||||
private[this] val isOBPReturnType = resultType.startsWith("OBPReturnType[")
|
||||
|
||||
private[this] val outBoundExample = {
|
||||
var typeName = s"com.openbankproject.commons.dto.OutBound${methodName.capitalize}"
|
||||
val outBoundType = ReflectUtils.getTypeByName(typeName)
|
||||
createDocExample(outBoundType).replaceAll("(?m)^(\\S)", " $1")
|
||||
}
|
||||
private[this] val inBoundExample = {
|
||||
var typeName = s"com.openbankproject.commons.dto.InBound${methodName.capitalize}"
|
||||
val inBoundType = ReflectUtils.getTypeByName(typeName)
|
||||
createDocExample(inBoundType).replaceAll("(?m)^(\\S)", " $1")
|
||||
}
|
||||
|
||||
var signature = s"$methodName$paramAnResult"
|
||||
|
||||
val hasCallContext = tp.paramLists(0)
|
||||
.exists(_.asTerm.info =:= ru.typeOf[Option[CallContext]])
|
||||
|
||||
/**
|
||||
* Get all the parameters name as a String from `typeSignature` object.
|
||||
* eg: it will return
|
||||
* , bankId, accountId, accountType, accountLabel, currency, initialBalance, accountHolderName, branchId, accountRoutingScheme, accountRoutingAddress
|
||||
*/
|
||||
private[this] val parametersNamesString = tp.paramLists(0)//paramLists will return all the curry parameters set.
|
||||
.filterNot(_.asTerm.info =:= ru.typeOf[Option[CallContext]]) // remove the `CallContext` field.
|
||||
.map(_.name.toString)//get all parameters name
|
||||
.map(it => if(it =="type") "`type`" else it)//This is special case for `type`, it is the keyword in scala.
|
||||
.map(it => if(it == "queryParams") "OBPQueryParam.getLimit(queryParams), OBPQueryParam.getOffset(queryParams), OBPQueryParam.getFromDate(queryParams), OBPQueryParam.getToDate(queryParams)" else it)
|
||||
match {
|
||||
case Nil if hasCallContext => "callContext.map(_.toOutboundAdapterCallContext).orNull"
|
||||
case Nil => ""
|
||||
case list:List[String] if hasCallContext => list.mkString("callContext.map(_.toOutboundAdapterCallContext).orNull, ", ", ", "")
|
||||
case list:List[String] => list.mkString(", ")
|
||||
}
|
||||
|
||||
// for cache
|
||||
private[this] val cacheMethodName = if(resultType.startsWith("Box[")) "memoizeSyncWithProvider" else "memoizeWithProvider"
|
||||
|
||||
private[this] val timeoutFieldName = uncapitalize(methodName.replaceFirst("^[a-z]+", "")) + "TTL"
|
||||
private[this] val cacheTimeout = ReflectUtils.findMethod(ru.typeOf[KafkaMappedConnector_vSept2018], timeoutFieldName)(_ => true)
|
||||
.map(_.name.toString)
|
||||
.getOrElse("accountTTL")
|
||||
|
||||
// end for cache
|
||||
|
||||
private val outBoundName = s"OutBound${methodName.capitalize}"
|
||||
private val inBoundName = s"InBound${methodName.capitalize}"
|
||||
|
||||
val inboundDataFieldType = ReflectUtils.getTypeByName(s"com.openbankproject.commons.dto.$inBoundName")
|
||||
.member(TermName("data")).asMethod
|
||||
.returnType.toString.replaceAll(
|
||||
"""(\w+\.)+(\w+\.Value)|(\w+\.)+(\w+)""", "$2$4"
|
||||
)
|
||||
|
||||
def toCode(responseExpression: String => String, setTopic: Boolean = false, doCache: Boolean = false) = {
|
||||
val (outBoundTopic, inBoundTopic) = setTopic match {
|
||||
case true =>
|
||||
(s"""Some(Topics.createTopicByClassName("$outBoundName").request)""" ,
|
||||
s"""Some(Topics.createTopicByClassName("$outBoundName").request)""" )
|
||||
case false => (None, None)
|
||||
}
|
||||
|
||||
val callContext = if(hasCallContext) {
|
||||
""
|
||||
} else {
|
||||
"\n val callContext: Option[CallContext] = None"
|
||||
}
|
||||
|
||||
var body =
|
||||
s"""| import com.openbankproject.commons.dto.{$outBoundName => OutBound, $inBoundName => InBound} $callContext
|
||||
| val req = OutBound($parametersNamesString)
|
||||
| val response: Future[Box[InBound]] = ${responseExpression(methodName)}
|
||||
| response.map(convertToTuple[$inboundDataFieldType](callContext)) """.stripMargin
|
||||
|
||||
|
||||
if(doCache && methodName.matches("^(get|check|validate).+")) {
|
||||
signature = signature.replaceFirst("""(\b\S+)\s*:\s*Option\[CallContext\]""", "@CacheKeyOmit callContext: Option[CallContext]")
|
||||
body =
|
||||
s"""saveConnectorMetric {
|
||||
| /**
|
||||
| * Please note that "var cacheKey = (randomUUID().toString, randomUUID().toString, randomUUID().toString)"
|
||||
| * is just a temporary value filed with UUID values in order to prevent any ambiguity.
|
||||
| * The real value will be assigned by Macro during compile time at this line of a code:
|
||||
| * https://github.com/OpenBankProject/scala-macros/blob/master/macros/src/main/scala/com/tesobe/CacheKeyFromArgumentsMacro.scala#L49
|
||||
| */
|
||||
| var cacheKey = (randomUUID().toString, randomUUID().toString, randomUUID().toString)
|
||||
| CacheKeyFromArguments.buildCacheKey {
|
||||
| Caching.${cacheMethodName}(Some(cacheKey.toString()))($cacheTimeout seconds) {
|
||||
|
|
||||
| ${body.replaceAll("(?m)^ ", " ")}
|
||||
|
|
||||
| }
|
||||
| }
|
||||
| }("$methodName")
|
||||
|""".stripMargin
|
||||
}
|
||||
s"""
|
||||
| messageDocs += ${methodName}Doc
|
||||
| def ${methodName}Doc = MessageDoc(
|
||||
| process = "obp.$methodName",
|
||||
| messageFormat = messageFormat,
|
||||
| description = "$description",
|
||||
| outboundTopic = $outBoundTopic,
|
||||
| inboundTopic = $inBoundTopic,
|
||||
| exampleOutboundMessage = (
|
||||
| $outBoundExample
|
||||
| ),
|
||||
| exampleInboundMessage = (
|
||||
| $inBoundExample
|
||||
| ),
|
||||
| adapterImplementation = Some(AdapterImplementation("- Core", 1))
|
||||
| )
|
||||
|
|
||||
| override def $signature = {
|
||||
| $body
|
||||
| }
|
||||
""".stripMargin
|
||||
}
|
||||
}
|
||||
|
||||
val commonMethodNames = List(
|
||||
"getAdapterInfo",
|
||||
"getChallengeThreshold",
|
||||
"getChargeLevel",
|
||||
"createChallenge",
|
||||
"getBank",
|
||||
"getBanks",
|
||||
"getBankAccountsForUser",
|
||||
"getUser",
|
||||
"getBankAccount",
|
||||
"getBankAccountsBalances",
|
||||
"getCoreBankAccounts",
|
||||
"getBankAccountsHeld",
|
||||
"getCounterpartyTrait",
|
||||
"getCounterpartyByCounterpartyId",
|
||||
"getCounterpartyByIban",
|
||||
"getCounterparties",
|
||||
"getTransactions",
|
||||
"getTransactionsCore",
|
||||
"getTransaction",
|
||||
"getPhysicalCardForBank",
|
||||
"deletePhysicalCardForBank",
|
||||
"getPhysicalCardsForBank",
|
||||
"createPhysicalCard",
|
||||
"updatePhysicalCard",
|
||||
"makePaymentv210",
|
||||
"createTransactionRequestv210",
|
||||
"getTransactionRequests210",
|
||||
"getTransactionRequestImpl",
|
||||
"createTransactionAfterChallengeV210",
|
||||
"updateBankAccount",
|
||||
"createBankAccount",
|
||||
"accountExists",
|
||||
"getBranch",
|
||||
"getBranches",
|
||||
"getAtm",
|
||||
"getAtms",
|
||||
"createTransactionAfterChallengev300",
|
||||
"makePaymentv300",
|
||||
"createTransactionRequestv300",
|
||||
"createCounterparty",
|
||||
"checkCustomerNumberAvailable",
|
||||
"createCustomer",
|
||||
"updateCustomerScaData",
|
||||
"updateCustomerCreditData",
|
||||
"updateCustomerGeneralData",
|
||||
"getCustomersByUserId",
|
||||
"getCustomerByCustomerId",
|
||||
"getCustomerByCustomerNumber",
|
||||
"getCustomerAddress",
|
||||
"createCustomerAddress",
|
||||
"updateCustomerAddress",
|
||||
"deleteCustomerAddress",
|
||||
"createTaxResidence",
|
||||
"getTaxResidence",
|
||||
"deleteTaxResidence",
|
||||
"getCustomers",
|
||||
"getCheckbookOrders",
|
||||
"getStatusOfCreditCardOrder",
|
||||
"createUserAuthContext",
|
||||
"createUserAuthContextUpdate",
|
||||
"deleteUserAuthContexts",
|
||||
"deleteUserAuthContextById",
|
||||
"getUserAuthContexts",
|
||||
"createOrUpdateProductAttribute",
|
||||
"getProductAttributeById",
|
||||
"getProductAttributesByBankAndCode",
|
||||
"deleteProductAttribute",
|
||||
"getAccountAttributeById",
|
||||
"createOrUpdateAccountAttribute",
|
||||
"createAccountAttributes",
|
||||
"getAccountAttributesByAccount",
|
||||
"createOrUpdateCardAttribute",
|
||||
"getCardAttributeById",
|
||||
"getCardAttributesFromProvider",
|
||||
"createAccountApplication",
|
||||
"getAllAccountApplication",
|
||||
"getAccountApplicationById",
|
||||
"updateAccountApplicationStatus",
|
||||
"getOrCreateProductCollection",
|
||||
"getProductCollection",
|
||||
"getOrCreateProductCollectionItem",
|
||||
"getProductCollectionItem",
|
||||
"getProductCollectionItemsTree",
|
||||
"createMeeting",
|
||||
"getMeetings",
|
||||
"getMeeting",
|
||||
"createOrUpdateKycCheck",
|
||||
"createOrUpdateKycDocument",
|
||||
"createOrUpdateKycMedia",
|
||||
"createOrUpdateKycStatus",
|
||||
"getKycChecks",
|
||||
"getKycDocuments",
|
||||
"getKycMedias",
|
||||
"getKycStatuses",
|
||||
"createMessage",
|
||||
"makeHistoricalPayment",
|
||||
"validateChallengeAnswer",
|
||||
//"getBankLegacy", // should not generate for Legacy methods
|
||||
//"getBanksLegacy", // should not generate for Legacy methods
|
||||
//"getBankAccountsForUserLegacy", // should not generate for Legacy methods
|
||||
//"getBankAccountLegacy", // should not generate for Legacy methods
|
||||
"getBankAccountByIban",
|
||||
"getBankAccountByRouting",
|
||||
"getBankAccounts",
|
||||
//"getCoreBankAccountsLegacy", // should not generate for Legacy methods
|
||||
//"getBankAccountsHeldLegacy", // should not generate for Legacy methods
|
||||
//"checkBankAccountExistsLegacy", // should not generate for Legacy methods
|
||||
//"getCounterpartyByCounterpartyIdLegacy", // should not generate for Legacy methods
|
||||
//"getCounterpartiesLegacy", // should not generate for Legacy methods
|
||||
//"getTransactionsLegacy", // should not generate for Legacy methods
|
||||
//"getTransactionLegacy", // should not generate for Legacy methods
|
||||
//"createPhysicalCardLegacy", // should not generate for Legacy methods
|
||||
//"getCustomerByCustomerIdLegacy", // should not generate for Legacy methods
|
||||
|
||||
"createChallenges",
|
||||
"createTransactionRequestv400",
|
||||
"getCustomersByCustomerPhoneNumber",
|
||||
"getTransactionAttributeById",
|
||||
"createOrUpdateCustomerAttribute",
|
||||
"createOrUpdateTransactionAttribute",
|
||||
"getCustomerAttributes",
|
||||
"getCustomerIdsByAttributeNameValues",
|
||||
"getCustomerAttributesForCustomers",
|
||||
"getTransactionIdsByAttributeNameValues",
|
||||
"getTransactionAttributes",
|
||||
"getCustomerAttributeById",
|
||||
"createDirectDebit",
|
||||
"deleteCustomerAttribute",
|
||||
|
||||
"getBankAccountOld", // old method, but v3.0.0 apis use a lot
|
||||
).distinct
|
||||
|
||||
/**
|
||||
* these connector methods have special parameter or return type
|
||||
*/
|
||||
val specialMethods = List(
|
||||
"getCounterparty",
|
||||
"getPhysicalCards",
|
||||
"makePayment",
|
||||
"makePaymentv200",
|
||||
"createTransactionRequest",
|
||||
"createTransactionRequestv200",
|
||||
"getStatus",
|
||||
"getChargeValue",
|
||||
"saveTransactionRequestTransaction",
|
||||
"saveTransactionRequestChallenge",
|
||||
"getTransactionRequests",
|
||||
"getTransactionRequestStatuses",
|
||||
"getTransactionRequestTypes",
|
||||
"createTransactionAfterChallenge",
|
||||
"createTransactionAfterChallengev200",
|
||||
"createBankAndAccount",
|
||||
"createSandboxBankAccount",
|
||||
"accountExists",
|
||||
"removeAccount",
|
||||
"getMatchingTransactionCount",
|
||||
"updateAccountBalance",
|
||||
"setBankAccountLastUpdated",
|
||||
"updateAccountLabel",
|
||||
"updateAccount",
|
||||
"getProducts",
|
||||
"getProduct",
|
||||
"createOrUpdateBranch",
|
||||
"createOrUpdateBank",
|
||||
"createOrUpdateAtm",
|
||||
"createOrUpdateProduct",
|
||||
"createOrUpdateFXRate",
|
||||
"accountOwnerExists",
|
||||
"getCurrentFxRate",
|
||||
"getCurrentFxRateCached",
|
||||
"getTransactionRequestTypeCharge",
|
||||
"getTransactionRequestTypeCharges",
|
||||
//"getPhysicalCardsForBankLegacy", // should not generate for Legacy methods
|
||||
//"getBranchLegacy", // should not generate for Legacy methods
|
||||
//"getAtmLegacy", // should not generate for Legacy methods
|
||||
"getEmptyBankAccount",
|
||||
"getCounterpartyFromTransaction",
|
||||
"getCounterpartiesFromTransaction",
|
||||
).distinct
|
||||
|
||||
/**
|
||||
* modifier is protected methods, not recommend generate these methods, they should always for special purpose
|
||||
*/
|
||||
val protectedMethods = List(
|
||||
"makePaymentImpl",
|
||||
"createTransactionRequestImpl",
|
||||
"createTransactionRequestImpl210",
|
||||
"saveTransactionRequestTransactionImpl",
|
||||
"saveTransactionRequestChallengeImpl",
|
||||
"saveTransactionRequestStatusImpl",
|
||||
"getTransactionRequestStatusesImpl",
|
||||
"getTransactionRequestsImpl",
|
||||
"getTransactionRequestsImpl210",
|
||||
"getTransactionRequestTypesImpl"
|
||||
).distinct
|
||||
|
||||
val omitMethods = List(
|
||||
// "answerTransactionRequestChallenge", //deprecated
|
||||
//"setAccountHolder", //deprecated
|
||||
// "createImportedTransaction", // should create manually
|
||||
// "createViews", // should not be auto generated
|
||||
// "UpdateUserAccoutViewsByUsername", // a helper function should not be auto generated
|
||||
// "updateUserAccountViewsOld", // deprecated
|
||||
//"createBankAccountLegacy", // should not generate for Legacy methods //deprecated
|
||||
|
||||
// "createOrUpdateAttributeDefinition", // should not be auto generated
|
||||
// "deleteAttributeDefinition", // should not be auto generated
|
||||
// "getAttributeDefinition", // should not be auto generated
|
||||
|
||||
// "createStandingOrder", // should not be auto generated
|
||||
|
||||
// "addBankAccount", // non-standard calls, should be used for test
|
||||
|
||||
//** the follow 5 methods should not be generated, should create manually
|
||||
// "dynamicEntityProcess",
|
||||
// "dynamicEndpointProcess",
|
||||
// "createDynamicEndpoint",
|
||||
// "getDynamicEndpoint",
|
||||
// "getDynamicEndpoints",
|
||||
).distinct
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ import com.openbankproject.commons.model.enums.StrongCustomerAuthentication.SCA
|
||||
import code.api.util._
|
||||
import code.bankconnectors.vMar2017.KafkaMappedConnector_vMar2017
|
||||
import code.branches.Branches.Branch
|
||||
import code.fx.{FXRate, fx}
|
||||
import code.fx.fx
|
||||
import code.kafka.KafkaHelper
|
||||
import code.management.ImporterAPI.ImporterTransaction
|
||||
import code.metadata.comments.Comments
|
||||
@ -45,7 +45,8 @@ import com.openbankproject.commons.model.Product
|
||||
import code.transaction.MappedTransaction
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestTypes._
|
||||
import code.transactionrequests.TransactionRequests._
|
||||
import code.transactionrequests.{TransactionRequestTypeCharge, TransactionRequests}
|
||||
import code.transactionrequests.TransactionRequests
|
||||
import com.openbankproject.commons.model.TransactionRequestTypeCharge
|
||||
import code.util.Helper.MdcLoggable
|
||||
import code.util.{Helper, TTLCache}
|
||||
import code.views.Views
|
||||
@ -744,7 +745,7 @@ object KafkaMappedConnector extends Connector with KafkaHelper with MdcLoggable
|
||||
val viewsDeleted = Views.views.vend.removeAllViews(bankId, accountId)
|
||||
|
||||
//delete account
|
||||
val account = getBankAccount(bankId, accountId)
|
||||
val account = getBankAccountOld(bankId, accountId)
|
||||
|
||||
val accountDeleted = account match {
|
||||
case acc => true //acc.delete_! //TODO
|
||||
@ -783,7 +784,7 @@ object KafkaMappedConnector extends Connector with KafkaHelper with MdcLoggable
|
||||
private def createAccountIfNotExisting(bankId: BankId, accountId: AccountId, accountNumber: String,
|
||||
accountType: String, accountLabel: String, currency: String,
|
||||
balanceInSmallestCurrencyUnits: Long, accountHolderName: String) : BankAccount = {
|
||||
getBankAccount(bankId, accountId) match {
|
||||
getBankAccountOld(bankId, accountId) match {
|
||||
case Full(a) =>
|
||||
logger.info(s"account with id $accountId at bank with id $bankId already exists. No need to create a new one.")
|
||||
a
|
||||
@ -833,7 +834,7 @@ object KafkaMappedConnector extends Connector with KafkaHelper with MdcLoggable
|
||||
|
||||
//this will be Full(true) if everything went well
|
||||
val result = for {
|
||||
acc <- getBankAccount(bankId, accountId)
|
||||
acc <- getBankAccountOld(bankId, accountId)
|
||||
(bank, _)<- getBankLegacy(bankId, None)
|
||||
} yield {
|
||||
//acc.balance = newBalance
|
||||
@ -925,7 +926,7 @@ object KafkaMappedConnector extends Connector with KafkaHelper with MdcLoggable
|
||||
bankId <- getBankByNationalIdentifier(bankNationalIdentifier).map(_.bankId)
|
||||
account <- getAccountByNumber(bankId, accountNumber)
|
||||
} yield {
|
||||
val acc = getBankAccount(bankId, account.accountId)
|
||||
val acc = getBankAccountOld(bankId, account.accountId)
|
||||
acc match {
|
||||
case a => true //a.lastUpdate = updateDate //TODO
|
||||
// case _ => logger.warn("can't set bank account.lastUpdated because the account was not found"); false
|
||||
@ -942,7 +943,7 @@ object KafkaMappedConnector extends Connector with KafkaHelper with MdcLoggable
|
||||
override def updateAccountLabel(bankId: BankId, accountId: AccountId, label: String) = {
|
||||
//this will be Full(true) if everything went well
|
||||
val result = for {
|
||||
acc <- getBankAccount(bankId, accountId)
|
||||
acc <- getBankAccountOld(bankId, accountId)
|
||||
(bank, _)<- getBankLegacy(bankId, None)
|
||||
d <- MappedBankAccountData.find(By(MappedBankAccountData.accountId, accountId.value), By(MappedBankAccountData.bankId, bank.bankId.value))
|
||||
} yield {
|
||||
@ -1013,7 +1014,7 @@ object KafkaMappedConnector extends Connector with KafkaHelper with MdcLoggable
|
||||
case Full(f) => Full(KafkaTransactionRequestTypeCharge(f))
|
||||
case _ =>
|
||||
for {
|
||||
fromAccount <- getBankAccount(bankId, accountId)
|
||||
fromAccount <- getBankAccountOld(bankId, accountId)
|
||||
fromAccountCurrency <- tryo{ fromAccount.currency }
|
||||
} yield {
|
||||
KafkaTransactionRequestTypeCharge(KafkaInboundTransactionRequestTypeCharge(transactionRequestType.value, bankId.value, fromAccountCurrency, "0.00", "Warning! Default value!"))
|
||||
@ -1054,7 +1055,7 @@ object KafkaMappedConnector extends Connector with KafkaHelper with MdcLoggable
|
||||
for {
|
||||
counterpartyId <- tryo{r.counterpartyId}
|
||||
counterpartyName <- tryo{r.counterpartyName}
|
||||
thisAccount <- getBankAccount(BankId(r.bankId), AccountId(r.accountId))
|
||||
thisAccount <- getBankAccountOld(BankId(r.bankId), AccountId(r.accountId))
|
||||
//creates a dummy OtherBankAccount without an OtherBankAccountMetadata, which results in one being generated (in OtherBankAccount init)
|
||||
dummyOtherBankAccount <- tryo{createCounterparty(counterpartyId, counterpartyName, thisAccount, None)}
|
||||
//and create the proper OtherBankAccount with the correct "id" attribute set to the metadataId of the OtherBankAccountMetadata object
|
||||
|
||||
@ -38,7 +38,7 @@ import code.api.util._
|
||||
import code.atms.{Atms, MappedAtm}
|
||||
import code.bankconnectors.vMar2017.KafkaMappedConnector_vMar2017
|
||||
import code.branches.Branches.Branch
|
||||
import code.fx.FXRate
|
||||
import com.openbankproject.commons.model.FXRate
|
||||
import code.kafka.KafkaHelper
|
||||
import code.management.ImporterAPI.ImporterTransaction
|
||||
import code.metadata.comments.Comments
|
||||
@ -52,7 +52,8 @@ import com.openbankproject.commons.model.Product
|
||||
import code.transaction.MappedTransaction
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestTypes._
|
||||
import code.transactionrequests.TransactionRequests._
|
||||
import code.transactionrequests.{MappedTransactionRequestTypeCharge, TransactionRequestTypeCharge, TransactionRequestTypeChargeMock, TransactionRequests}
|
||||
import code.transactionrequests.{MappedTransactionRequestTypeCharge, TransactionRequestTypeChargeMock, TransactionRequests}
|
||||
import com.openbankproject.commons.model.TransactionRequestTypeCharge
|
||||
import code.util.Helper
|
||||
import code.util.Helper.MdcLoggable
|
||||
import code.views.Views
|
||||
@ -915,7 +916,7 @@ object KafkaMappedConnector_JVMcompatible extends Connector with KafkaHelper wit
|
||||
val viewsDeleted = Views.views.vend.removeAllViews(bankId, accountId)
|
||||
|
||||
//delete account
|
||||
val account = getBankAccount(bankId, accountId)
|
||||
val account = getBankAccountOld(bankId, accountId)
|
||||
|
||||
val accountDeleted = account match {
|
||||
case acc => true //acc.delete_! //TODO
|
||||
@ -954,7 +955,7 @@ object KafkaMappedConnector_JVMcompatible extends Connector with KafkaHelper wit
|
||||
private def createAccountIfNotExisting(bankId: BankId, accountId: AccountId, accountNumber: String,
|
||||
accountType: String, accountLabel: String, currency: String,
|
||||
balanceInSmallestCurrencyUnits: Long, accountHolderName: String) : BankAccount = {
|
||||
getBankAccount(bankId, accountId) match {
|
||||
getBankAccountOld(bankId, accountId) match {
|
||||
case Full(a) =>
|
||||
logger.debug(s"account with id $accountId at bank with id $bankId already exists. No need to create a new one.")
|
||||
a
|
||||
@ -1004,7 +1005,7 @@ object KafkaMappedConnector_JVMcompatible extends Connector with KafkaHelper wit
|
||||
|
||||
//this will be Full(true) if everything went well
|
||||
val result = for {
|
||||
acc <- getBankAccount(bankId, accountId)
|
||||
acc <- getBankAccountOld(bankId, accountId)
|
||||
(bank, _)<- getBankLegacy(bankId, None)
|
||||
} yield {
|
||||
//acc.balance = newBalance
|
||||
@ -1116,7 +1117,7 @@ object KafkaMappedConnector_JVMcompatible extends Connector with KafkaHelper wit
|
||||
override def updateAccountLabel(bankId: BankId, accountId: AccountId, label: String) = {
|
||||
//this will be Full(true) if everything went well
|
||||
val result = for {
|
||||
acc <- getBankAccount(bankId, accountId)
|
||||
acc <- getBankAccountOld(bankId, accountId)
|
||||
(bank, _)<- getBankLegacy(bankId, None)
|
||||
d <- MappedBankAccountData.find(By(MappedBankAccountData.accountId, accountId.value), By(MappedBankAccountData.bankId, bank.bankId.value))
|
||||
} yield {
|
||||
@ -1183,7 +1184,7 @@ object KafkaMappedConnector_JVMcompatible extends Connector with KafkaHelper wit
|
||||
//If it is empty, return the default value : "0.0000000" and set the BankAccount currency
|
||||
case _ =>
|
||||
for {
|
||||
fromAccount <- getBankAccount(bankId, accountId)
|
||||
fromAccount <- getBankAccountOld(bankId, accountId)
|
||||
fromAccountCurrency <- tryo{ fromAccount.currency }
|
||||
} yield {
|
||||
TransactionRequestTypeChargeMock(transactionRequestType.value, bankId.value, fromAccountCurrency, "0.00", "Warning! Default value!")
|
||||
@ -1228,7 +1229,7 @@ object KafkaMappedConnector_JVMcompatible extends Connector with KafkaHelper wit
|
||||
for {
|
||||
counterpartyId <- tryo{r.counterpartyId}
|
||||
counterpartyName <- tryo{r.counterpartyName}
|
||||
thisAccount <- getBankAccount(BankId(r.bankId), AccountId(r.accountId))
|
||||
thisAccount <- getBankAccountOld(BankId(r.bankId), AccountId(r.accountId))
|
||||
//creates a dummy OtherBankAccount without an OtherBankAccountMetadata, which results in one being generated (in OtherBankAccount init)
|
||||
dummyOtherBankAccount <- tryo{createCounterparty(counterpartyId, counterpartyName, thisAccount, None)}
|
||||
//and create the proper OtherBankAccount with the correct "id" attribute set to the metadataId of the OtherBankAccountMetadata object
|
||||
|
||||
@ -28,10 +28,12 @@ import code.context.{UserAuthContextProvider, UserAuthContextUpdateProvider}
|
||||
import code.customer._
|
||||
import code.customeraddress.CustomerAddressX
|
||||
import code.customerattribute.{CustomerAttributeX, MappedCustomerAttribute}
|
||||
import code.directdebit.{DirectDebitTrait, DirectDebits}
|
||||
import code.directdebit.DirectDebits
|
||||
import com.openbankproject.commons.model.DirectDebitTrait
|
||||
import code.dynamicEntity.{DynamicEntityProvider, DynamicEntityT}
|
||||
import code.fx.fx.TTL
|
||||
import code.fx.{FXRate, MappedFXRate, fx}
|
||||
import code.fx.{MappedFXRate, fx}
|
||||
import com.openbankproject.commons.model.FXRate
|
||||
import code.kycchecks.KycChecks
|
||||
import code.kycdocuments.KycDocuments
|
||||
import code.kycmedias.KycMedias
|
||||
@ -57,7 +59,8 @@ import code.transaction.MappedTransaction
|
||||
import code.transactionChallenge.ExpectedChallengeAnswer
|
||||
import code.transactionattribute.TransactionAttributeX
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestTypes.{ACCOUNT, ACCOUNT_OTP, COUNTERPARTY, FREE_FORM, REFUND, SANDBOX_TAN, SEPA, SEPA_CREDIT_TRANSFERS}
|
||||
import code.transactionrequests.TransactionRequests.{TransactionChallengeTypes, TransactionRequestStatus, TransactionRequestTypes}
|
||||
import code.transactionrequests.TransactionRequests.{TransactionChallengeTypes, TransactionRequestTypes}
|
||||
import com.openbankproject.commons.model.enums.TransactionRequestStatus
|
||||
import code.transactionrequests._
|
||||
import code.users.Users
|
||||
import code.util.Helper
|
||||
@ -434,7 +437,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
|
||||
updateAccountTransactions(bankId, accountId)
|
||||
|
||||
for (account <- getBankAccount(bankId, accountId))
|
||||
for (account <- getBankAccountOld(bankId, accountId))
|
||||
yield mappedTransactions.flatMap(_.toTransaction(account)) //each transaction will be modified by account, here we return the `class Transaction` not a trait.
|
||||
}
|
||||
}
|
||||
@ -478,7 +481,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
|
||||
val mappedTransactions = MappedTransaction.findAll(mapperParams: _*)
|
||||
|
||||
for (account <- getBankAccount(bankId, accountId))
|
||||
for (account <- getBankAccountOld(bankId, accountId))
|
||||
yield mappedTransactions.flatMap(_.toTransactionCore(account)) //each transaction will be modified by account, here we return the `class Transaction` not a trait.
|
||||
}
|
||||
}
|
||||
@ -504,7 +507,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
|
||||
for {
|
||||
bank <- getMappedBank(bankId)
|
||||
account <- getBankAccount(bankId, accountId).map(_.asInstanceOf[MappedBankAccount])
|
||||
account <- getBankAccountOld(bankId, accountId).map(_.asInstanceOf[MappedBankAccount])
|
||||
} {
|
||||
Future {
|
||||
val useMessageQueue = APIUtil.getPropsAsBoolValue("messageQueue.updateBankAccountsTransaction", false)
|
||||
@ -566,7 +569,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
(Full(
|
||||
bankIdAccountIds.map(
|
||||
bankIdAccountId =>
|
||||
getBankAccount(
|
||||
getBankAccountOld(
|
||||
bankIdAccountId.bankId,
|
||||
bankIdAccountId.accountId
|
||||
).openOrThrowException(s"${ErrorMessages.BankAccountNotFound} current BANK_ID(${bankIdAccountId.bankId}) and ACCOUNT_ID(${bankIdAccountId.accountId})"))
|
||||
@ -578,7 +581,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
Future {
|
||||
val accountsBalances = for {
|
||||
bankIdAccountId <- bankIdAccountIds
|
||||
bankAccount <- getBankAccount(bankIdAccountId.bankId, bankIdAccountId.accountId) ?~! s"${ErrorMessages.BankAccountNotFound} current BANK_ID(${bankIdAccountId.bankId}) and ACCOUNT_ID(${bankIdAccountId.accountId})"
|
||||
bankAccount <- getBankAccountOld(bankIdAccountId.bankId, bankIdAccountId.accountId) ?~! s"${ErrorMessages.BankAccountNotFound} current BANK_ID(${bankIdAccountId.bankId}) and ACCOUNT_ID(${bankIdAccountId.accountId})"
|
||||
accountBalance = AccountBalance(
|
||||
id = bankAccount.accountId.value,
|
||||
label = bankAccount.label,
|
||||
@ -629,7 +632,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
Full(
|
||||
bankIdAccountIds
|
||||
.map(bankIdAccountId =>
|
||||
getBankAccount(
|
||||
getBankAccountOld(
|
||||
bankIdAccountId.bankId,
|
||||
bankIdAccountId.accountId)
|
||||
.openOrThrowException(s"${ErrorMessages.BankAccountNotFound} current BANK_ID(${bankIdAccountId.bankId}) and ACCOUNT_ID(${bankIdAccountId.accountId})"))
|
||||
@ -655,7 +658,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
Full(
|
||||
bankIdAccountIds
|
||||
.map(bankIdAccountId =>
|
||||
getBankAccount(
|
||||
getBankAccountOld(
|
||||
bankIdAccountId.bankId,
|
||||
bankIdAccountId.accountId)
|
||||
.openOrThrowException(s"${ErrorMessages.BankAccountNotFound} current BANK_ID(${bankIdAccountId.bankId}) and ACCOUNT_ID(${bankIdAccountId.accountId})"))
|
||||
@ -686,7 +689,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
*/
|
||||
def createOrUpdateMappedBankAccount(bankId: BankId, accountId: AccountId, currency: String): Box[BankAccount] = {
|
||||
|
||||
val mappedBankAccount = getBankAccount(bankId, accountId).map(_.asInstanceOf[MappedBankAccount]) match {
|
||||
val mappedBankAccount = getBankAccountOld(bankId, accountId).map(_.asInstanceOf[MappedBankAccount]) match {
|
||||
case Full(f) =>
|
||||
f.bank(bankId.value).theAccountId(accountId.value).accountCurrency(currency.toUpperCase).saveMe()
|
||||
case _ =>
|
||||
@ -1508,7 +1511,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
accountRoutingScheme: String,
|
||||
accountRoutingAddress: String
|
||||
): BankAccount = {
|
||||
getBankAccount(bankId, accountId) match {
|
||||
getBankAccountOld(bankId, accountId) match {
|
||||
case Full(a) =>
|
||||
logger.debug(s"account with id $accountId at bank with id $bankId already exists. No need to create a new one.")
|
||||
a
|
||||
@ -1543,7 +1546,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
//this will be Full(true) if everything went well
|
||||
val result = for {
|
||||
bank <- getMappedBank(bankId)
|
||||
account <- getBankAccount(bankId, accountId).map(_.asInstanceOf[MappedBankAccount])
|
||||
account <- getBankAccountOld(bankId, accountId).map(_.asInstanceOf[MappedBankAccount])
|
||||
} yield {
|
||||
account.accountBalance(Helper.convertToSmallestCurrencyUnits(newBalance, account.currency)).save
|
||||
setBankAccountLastUpdated(bank.nationalIdentifier, account.number, now).openOrThrowException(attemptedToOpenAnEmptyBox)
|
||||
@ -1659,7 +1662,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
override def updateAccountLabel(bankId: BankId, accountId: AccountId, label: String) = {
|
||||
//this will be Full(true) if everything went well
|
||||
val result = for {
|
||||
acc <- getBankAccount(bankId, accountId).map(_.asInstanceOf[MappedBankAccount])
|
||||
acc <- getBankAccountOld(bankId, accountId).map(_.asInstanceOf[MappedBankAccount])
|
||||
bank <- getMappedBank(bankId)
|
||||
} yield {
|
||||
acc.accountLabel(label).save
|
||||
@ -2255,7 +2258,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
)
|
||||
//If it is empty, return the default value : "0.0000000" and set the BankAccount currency
|
||||
case _ =>
|
||||
val fromAccountCurrency: String = getBankAccount(bankId, accountId).openOrThrowException(attemptedToOpenAnEmptyBox).currency
|
||||
val fromAccountCurrency: String = getBankAccountOld(bankId, accountId).openOrThrowException(attemptedToOpenAnEmptyBox).currency
|
||||
TransactionRequestTypeChargeMock(transactionRequestType.value, bankId.value, fromAccountCurrency, "0.00", "Warning! Default value!")
|
||||
}
|
||||
|
||||
@ -3237,7 +3240,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
}
|
||||
|
||||
//This is old one, no callContext there. only for old style endpoints.
|
||||
override def getBankAccount(bankId: BankId, accountId: AccountId): Box[BankAccount] = {
|
||||
override def getBankAccountOld(bankId: BankId, accountId: AccountId): Box[BankAccount] = {
|
||||
getBankAccountLegacy(bankId, accountId, None).map(_._1)
|
||||
}
|
||||
|
||||
@ -3266,10 +3269,10 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
override def makePayment(initiator: User, fromAccountUID: BankIdAccountId, toAccountUID: BankIdAccountId,
|
||||
amt: BigDecimal, description: String, transactionRequestType: TransactionRequestType): Box[TransactionId] = {
|
||||
for {
|
||||
fromAccount <- getBankAccount(fromAccountUID.bankId, fromAccountUID.accountId) ?~
|
||||
fromAccount <- getBankAccountOld(fromAccountUID.bankId, fromAccountUID.accountId) ?~
|
||||
s"$BankAccountNotFound Account ${fromAccountUID.accountId} not found at bank ${fromAccountUID.bankId}"
|
||||
isOwner <- booleanToBox(initiator.hasOwnerViewAccess(BankIdAccountId(fromAccount.bankId, fromAccount.accountId)), UserNoOwnerView)
|
||||
toAccount <- getBankAccount(toAccountUID.bankId, toAccountUID.accountId) ?~
|
||||
toAccount <- getBankAccountOld(toAccountUID.bankId, toAccountUID.accountId) ?~
|
||||
s"$BankAccountNotFound Account ${toAccountUID.accountId} not found at bank ${toAccountUID.bankId}"
|
||||
sameCurrency <- booleanToBox(fromAccount.currency == toAccount.currency, {
|
||||
s"$InvalidTransactionRequestCurrency, Cannot send payment to account with different currency (From ${fromAccount.currency} to ${toAccount.currency}"
|
||||
@ -3323,10 +3326,10 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
|
||||
//create a new transaction request
|
||||
val request = for {
|
||||
fromAccountType <- getBankAccount(fromAccount.bankId, fromAccount.accountId) ?~
|
||||
fromAccountType <- getBankAccountOld(fromAccount.bankId, fromAccount.accountId) ?~
|
||||
s"account ${fromAccount.accountId} not found at bank ${fromAccount.bankId}"
|
||||
isOwner <- booleanToBox(initiator.hasOwnerViewAccess(BankIdAccountId(fromAccount.bankId, fromAccount.accountId)), UserNoOwnerView)
|
||||
toAccountType <- getBankAccount(toAccount.bankId, toAccount.accountId) ?~
|
||||
toAccountType <- getBankAccountOld(toAccount.bankId, toAccount.accountId) ?~
|
||||
s"account ${toAccount.accountId} not found at bank ${toAccount.bankId}"
|
||||
rawAmt <- tryo {
|
||||
BigDecimal(body.value.amount)
|
||||
@ -3384,9 +3387,9 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
|
||||
// Always create a new Transaction Request
|
||||
val request = for {
|
||||
fromAccountType <- getBankAccount(fromAccount.bankId, fromAccount.accountId) ?~ s"account ${fromAccount.accountId} not found at bank ${fromAccount.bankId}"
|
||||
fromAccountType <- getBankAccountOld(fromAccount.bankId, fromAccount.accountId) ?~ s"account ${fromAccount.accountId} not found at bank ${fromAccount.bankId}"
|
||||
isOwner <- booleanToBox(initiator.hasOwnerViewAccess(BankIdAccountId(fromAccount.bankId, fromAccount.accountId)) == true || hasEntitlement(fromAccount.bankId.value, initiator.userId, canCreateAnyTransactionRequest) == true, ErrorMessages.InsufficientAuthorisationToCreateTransactionRequest)
|
||||
toAccountType <- getBankAccount(toAccount.bankId, toAccount.accountId) ?~ s"account ${toAccount.accountId} not found at bank ${toAccount.bankId}"
|
||||
toAccountType <- getBankAccountOld(toAccount.bankId, toAccount.accountId) ?~ s"account ${toAccount.accountId} not found at bank ${toAccount.bankId}"
|
||||
rawAmt <- tryo {
|
||||
BigDecimal(body.value.amount)
|
||||
} ?~! s"amount ${body.value.amount} not convertible to number"
|
||||
@ -3725,7 +3728,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
override def getTransactionRequests(initiator: User, fromAccount: BankAccount): Box[List[TransactionRequest]] = {
|
||||
val transactionRequests =
|
||||
for {
|
||||
fromAccount <- getBankAccount(fromAccount.bankId, fromAccount.accountId) ?~
|
||||
fromAccount <- getBankAccountOld(fromAccount.bankId, fromAccount.accountId) ?~
|
||||
s"account ${fromAccount.accountId} not found at bank ${fromAccount.bankId}"
|
||||
isOwner <- booleanToBox(initiator.hasOwnerViewAccess(BankIdAccountId(fromAccount.bankId, fromAccount.accountId)), UserNoOwnerView)
|
||||
transactionRequests <- getTransactionRequestsImpl(fromAccount)
|
||||
|
||||
@ -507,7 +507,7 @@ private object LocalRecordConnector extends Connector with MdcLoggable {
|
||||
|
||||
//used by the transaction import api
|
||||
override def updateAccountBalance(bankId: BankId, accountId: AccountId, newBalance: BigDecimal) = {
|
||||
getBankAccount(bankId, accountId).map(_.asInstanceOf[Account]) match {
|
||||
getBankAccountOld(bankId, accountId).map(_.asInstanceOf[Account]) match {
|
||||
case Full(acc) =>
|
||||
acc.accountBalance(newBalance).saveTheRecord().isDefined
|
||||
Full(true)
|
||||
@ -527,7 +527,7 @@ private object LocalRecordConnector extends Connector with MdcLoggable {
|
||||
}
|
||||
|
||||
override def updateAccountLabel(bankId: BankId, accountId: AccountId, label: String) = {
|
||||
getBankAccount(bankId, accountId).map(_.asInstanceOf[Account]) match {
|
||||
getBankAccountOld(bankId, accountId).map(_.asInstanceOf[Account]) match {
|
||||
case Full(acc) =>
|
||||
acc.accountLabel(label).saveTheRecord().isDefined
|
||||
Full(true)
|
||||
|
||||
@ -10,7 +10,8 @@ import code.accountholders.{AccountHolders, MapperAccountHolders}
|
||||
import code.api.util.ErrorMessages._
|
||||
import code.api.util._
|
||||
import code.branches.Branches.Branch
|
||||
import code.fx.{FXRate, fx}
|
||||
import code.fx.fx
|
||||
import com.openbankproject.commons.model.FXRate
|
||||
import code.management.ImporterAPI.ImporterTransaction
|
||||
import code.metadata.comments.Comments
|
||||
import code.metadata.narrative.MappedNarrative
|
||||
@ -764,7 +765,7 @@ object ObpJvmMappedConnector extends Connector with MdcLoggable {
|
||||
val viewsDeleted = Views.views.vend.removeAllViews(bankId, accountId)
|
||||
|
||||
//delete account
|
||||
val account = getBankAccount(bankId, accountId)
|
||||
val account = getBankAccountOld(bankId, accountId)
|
||||
|
||||
val accountDeleted = account match {
|
||||
case acc => true //acc.delete_! //TODO
|
||||
@ -803,7 +804,7 @@ object ObpJvmMappedConnector extends Connector with MdcLoggable {
|
||||
private def createAccountIfNotExisting(bankId: BankId, accountId: AccountId, accountNumber: String,
|
||||
accountType: String, accountLabel: String, currency: String,
|
||||
balanceInSmallestCurrencyUnits: Long, accountHolderName: String) : BankAccount = {
|
||||
getBankAccount(bankId, accountId) match {
|
||||
getBankAccountOld(bankId, accountId) match {
|
||||
case Full(a) =>
|
||||
logger.info(s"account with id $accountId at bank with id $bankId already exists. No need to create a new one.")
|
||||
a
|
||||
@ -854,7 +855,7 @@ object ObpJvmMappedConnector extends Connector with MdcLoggable {
|
||||
|
||||
//this will be Full(true) if everything went well
|
||||
val result = for {
|
||||
acc <- getBankAccount(bankId, accountId)
|
||||
acc <- getBankAccountOld(bankId, accountId)
|
||||
(bank, _)<- getBankLegacy(bankId, None)
|
||||
} yield {
|
||||
//acc.balance = newBalance
|
||||
@ -946,7 +947,7 @@ object ObpJvmMappedConnector extends Connector with MdcLoggable {
|
||||
bankId <- getBankByNationalIdentifier(bankNationalIdentifier).map(_.bankId)
|
||||
account <- getAccountByNumber(bankId, accountNumber, AuthUser.getCurrentUserUsername)
|
||||
} yield {
|
||||
val acc = getBankAccount(bankId, account.accountId)
|
||||
val acc = getBankAccountOld(bankId, account.accountId)
|
||||
acc match {
|
||||
case a => true //a.lastUpdate = updateDate //TODO
|
||||
// case _ => logger.warn("can't set bank account.lastUpdated because the account was not found"); false
|
||||
@ -963,7 +964,7 @@ object ObpJvmMappedConnector extends Connector with MdcLoggable {
|
||||
override def updateAccountLabel(bankId: BankId, accountId: AccountId, label: String) = {
|
||||
//this will be Full(true) if everything went well
|
||||
val result = for {
|
||||
acc <- getBankAccount(bankId, accountId)
|
||||
acc <- getBankAccountOld(bankId, accountId)
|
||||
(bank, _)<- getBankLegacy(bankId, None)
|
||||
d <- MappedBankAccountData.find(By(MappedBankAccountData.accountId, accountId.value), By(MappedBankAccountData.bankId, bank.bankId.value))
|
||||
} yield {
|
||||
@ -992,7 +993,7 @@ object ObpJvmMappedConnector extends Connector with MdcLoggable {
|
||||
|
||||
for {
|
||||
cparty <- r.counterparty
|
||||
thisAccount <- getBankAccount(BankId(r.this_account.bank), AccountId(r.this_account.id))
|
||||
thisAccount <- getBankAccountOld(BankId(r.this_account.bank), AccountId(r.this_account.id))
|
||||
//creates a dummy Counterparty without an CounterpartyMetadata, which results in one being generated (in Counterparty init)
|
||||
dummyCounterparty <- tryo{createCounterparty(cparty, thisAccount, None)}
|
||||
//and create the proper Counterparty with the correct "id" attribute set to the metadataId of the CounterpartyMetadata object
|
||||
@ -1325,7 +1326,7 @@ object ObpJvmMappedConnector extends Connector with MdcLoggable {
|
||||
//If it is empty, return the default value : "0.0000000" and set the BankAccount currency
|
||||
case _ =>
|
||||
for {
|
||||
fromAccount <- getBankAccount(bankId, accountId)
|
||||
fromAccount <- getBankAccountOld(bankId, accountId)
|
||||
fromAccountCurrency <- tryo{ fromAccount.currency }
|
||||
} yield {
|
||||
TransactionRequestTypeChargeMock(transactionRequestType.value, bankId.value, fromAccountCurrency, "0.00", "Warning! Default value!")
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package code.bankconnectors.akka
|
||||
|
||||
import code.bankconnectors.ConnectorBuilderUtil._
|
||||
|
||||
import scala.language.postfixOps
|
||||
|
||||
object AkkaConnectorBuilder extends App {
|
||||
|
||||
val createManually = List(
|
||||
"getAdapterInfo",
|
||||
"getBanks",
|
||||
"getBank",
|
||||
"getBankAccountsForUser",
|
||||
"checkBankAccountExists",
|
||||
"getBankAccount",
|
||||
"getCoreBankAccounts",
|
||||
"getCustomersByUserId",
|
||||
"getTransactions",
|
||||
"getTransaction",
|
||||
)
|
||||
// exclude manually created methods
|
||||
val toGenerateMethodNames = commonMethodNames.filterNot(createManually.contains)
|
||||
|
||||
generateMethods(toGenerateMethodNames,
|
||||
"src/main/scala/code/bankconnectors/akka/AkkaConnector_vDec2018.scala",
|
||||
"(southSideActor ? req).mapTo[InBound].recoverWith(recoverFunction).map(Box !! _) ")
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,467 +1,13 @@
|
||||
package code.bankconnectors.rest
|
||||
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
import code.bankconnectors.ConnectorBuilderUtil._
|
||||
|
||||
import code.api.util.{APIUtil, CallContext, OBPQueryParam}
|
||||
import code.bankconnectors.Connector
|
||||
import com.openbankproject.commons.util.ReflectUtils
|
||||
import org.apache.commons.io.FileUtils
|
||||
|
||||
import scala.collection.immutable.List
|
||||
import scala.language.postfixOps
|
||||
import scala.reflect.runtime.universe._
|
||||
import scala.reflect.runtime.{universe => ru}
|
||||
import code.api.util.CodeGenerateUtils.createDocExample
|
||||
|
||||
object RestConnectorBuilder extends App {
|
||||
// rewrite method code.webuiprops.MappedWebUiPropsProvider#getWebUiPropsValue, avoid access DB cause dataSource not found exception
|
||||
{
|
||||
import javassist.ClassPool
|
||||
val pool = ClassPool.getDefault
|
||||
val ct = pool.getCtClass("code.webuiprops.MappedWebUiPropsProvider$")
|
||||
val m = ct.getDeclaredMethod("getWebUiPropsValue")
|
||||
m.insertBefore("""return ""; """)
|
||||
ct.toClass
|
||||
}
|
||||
|
||||
val genMethodNames = List(
|
||||
// "getEmptyBankAccount", //not useful!
|
||||
// "getCounterpartyFromTransaction", //not useful!
|
||||
// "getCounterpartiesFromTransaction",//not useful!
|
||||
|
||||
"getAdapterInfo",
|
||||
"getChallengeThreshold",
|
||||
"getChargeLevel",
|
||||
"createChallenge",
|
||||
"getBank",
|
||||
"getBanks",
|
||||
"getBankAccountsForUser",
|
||||
"getUser",
|
||||
"getBankAccount",
|
||||
"getBankAccount",
|
||||
"getBankAccountsBalances",
|
||||
"getCoreBankAccounts",
|
||||
"getBankAccountsHeld",
|
||||
"checkBankAccountExists",
|
||||
"getCounterparty",
|
||||
"getCounterpartyTrait",
|
||||
"getCounterpartyByCounterpartyId",
|
||||
"getCounterpartyByIban",
|
||||
"getCounterparties",
|
||||
"getTransactions",
|
||||
"getTransactionsCore",
|
||||
"getTransaction",
|
||||
"getPhysicalCards",
|
||||
"getPhysicalCardForBank",
|
||||
"deletePhysicalCardForBank",
|
||||
"getPhysicalCardsForBank",
|
||||
"createPhysicalCard",
|
||||
"updatePhysicalCard",
|
||||
"makePayment",
|
||||
"makePaymentv200",
|
||||
"makePaymentv210",
|
||||
"makePaymentImpl",
|
||||
"createTransactionRequest",
|
||||
"createTransactionRequestv200",
|
||||
"getStatus",
|
||||
"getChargeValue",
|
||||
"createTransactionRequestv210",
|
||||
"createTransactionRequestImpl",
|
||||
"createTransactionRequestImpl210",
|
||||
"saveTransactionRequestTransaction",
|
||||
"saveTransactionRequestTransactionImpl",
|
||||
"saveTransactionRequestChallenge",
|
||||
"saveTransactionRequestChallengeImpl",
|
||||
"saveTransactionRequestStatusImpl",
|
||||
"getTransactionRequests",
|
||||
"getTransactionRequests210",
|
||||
"getTransactionRequestStatuses",
|
||||
"getTransactionRequestStatusesImpl",
|
||||
"getTransactionRequestsImpl",
|
||||
"getTransactionRequestsImpl210",
|
||||
"getTransactionRequestImpl",
|
||||
"getTransactionRequestTypes",
|
||||
"getTransactionRequestTypesImpl",
|
||||
"answerTransactionRequestChallenge",
|
||||
"createTransactionAfterChallenge",
|
||||
"createTransactionAfterChallengev200",
|
||||
"createTransactionAfterChallengeV210",
|
||||
"updateBankAccount",
|
||||
"createBankAndAccount",
|
||||
"createBankAccount",
|
||||
"createSandboxBankAccount",
|
||||
"setAccountHolder",
|
||||
"accountExists",
|
||||
"removeAccount",
|
||||
"getMatchingTransactionCount",
|
||||
"createImportedTransaction",
|
||||
"updateAccountBalance",
|
||||
"setBankAccountLastUpdated",
|
||||
"updateAccountLabel",
|
||||
"updateAccount",
|
||||
"getProducts",
|
||||
"getProduct",
|
||||
"createOrUpdateBranch",
|
||||
"createOrUpdateBank",
|
||||
"createOrUpdateAtm",
|
||||
"createOrUpdateProduct",
|
||||
"createOrUpdateFXRate",
|
||||
"getBranch",
|
||||
"getBranches",
|
||||
"getAtm",
|
||||
"getAtms",
|
||||
"accountOwnerExists",
|
||||
"createViews",
|
||||
"getCurrentFxRate",
|
||||
"getCurrentFxRateCached",
|
||||
"getTransactionRequestTypeCharge",
|
||||
"UpdateUserAccoutViewsByUsername",
|
||||
"createTransactionAfterChallengev300",
|
||||
"makePaymentv300",
|
||||
"createTransactionRequestv300",
|
||||
"getTransactionRequestTypeCharges",
|
||||
"createCounterparty",
|
||||
"checkCustomerNumberAvailable",
|
||||
"createCustomer",
|
||||
"updateCustomerScaData",
|
||||
"updateCustomerCreditData",
|
||||
"updateCustomerGeneralData",
|
||||
"getCustomersByUserId",
|
||||
"getCustomerByCustomerId",
|
||||
"getCustomerByCustomerNumber",
|
||||
"getCustomerAddress",
|
||||
"createCustomerAddress",
|
||||
"updateCustomerAddress",
|
||||
"deleteCustomerAddress",
|
||||
"createTaxResidence",
|
||||
"getTaxResidence",
|
||||
"deleteTaxResidence",
|
||||
"getCustomers",
|
||||
"getCheckbookOrders",
|
||||
"getStatusOfCreditCardOrder",
|
||||
"createUserAuthContext",
|
||||
"createUserAuthContextUpdate",
|
||||
"deleteUserAuthContexts",
|
||||
"deleteUserAuthContextById",
|
||||
"getUserAuthContexts",
|
||||
"createOrUpdateProductAttribute",
|
||||
"getProductAttributeById",
|
||||
"getProductAttributesByBankAndCode",
|
||||
"deleteProductAttribute",
|
||||
"getAccountAttributeById",
|
||||
"createOrUpdateAccountAttribute",
|
||||
"createAccountAttributes",
|
||||
"getAccountAttributesByAccount",
|
||||
"createOrUpdateCardAttribute",
|
||||
"getCardAttributeById",
|
||||
"getCardAttributesFromProvider",
|
||||
"createAccountApplication",
|
||||
"getAllAccountApplication",
|
||||
"getAccountApplicationById",
|
||||
"updateAccountApplicationStatus",
|
||||
"getOrCreateProductCollection",
|
||||
"getProductCollection",
|
||||
"getOrCreateProductCollectionItem",
|
||||
"getProductCollectionItem",
|
||||
"getProductCollectionItemsTree",
|
||||
"createMeeting",
|
||||
"getMeetings",
|
||||
"getMeeting",
|
||||
"createOrUpdateKycCheck",
|
||||
"createOrUpdateKycDocument",
|
||||
"createOrUpdateKycMedia",
|
||||
"createOrUpdateKycStatus",
|
||||
"getKycChecks",
|
||||
"getKycDocuments",
|
||||
"getKycMedias",
|
||||
"getKycStatuses",
|
||||
"createMessage",
|
||||
"makeHistoricalPayment",
|
||||
// new removed comments
|
||||
"validateChallengeAnswer",
|
||||
"getBankLegacy",
|
||||
"getBanksLegacy",
|
||||
"getBankAccountsForUserLegacy",
|
||||
"updateUserAccountViewsOld",
|
||||
"getBankAccountLegacy",
|
||||
"getBankAccountByIban",
|
||||
"getBankAccountByRouting",
|
||||
"getBankAccounts",
|
||||
"getCoreBankAccountsLegacy",
|
||||
"getBankAccountsHeldLegacy",
|
||||
"checkBankAccountExistsLegacy",
|
||||
"getCounterpartyByCounterpartyIdLegacy",
|
||||
"getCounterpartiesLegacy",
|
||||
"getTransactionsLegacy",
|
||||
"getTransactionLegacy",
|
||||
"getPhysicalCardsForBankLegacy",
|
||||
"createPhysicalCardLegacy",
|
||||
"createBankAccountLegacy",
|
||||
"getBranchLegacy",
|
||||
"getAtmLegacy",
|
||||
"getCustomerByCustomerIdLegacy",
|
||||
)
|
||||
|
||||
private val mirror: ru.Mirror = ru.runtimeMirror(getClass().getClassLoader)
|
||||
private val clazz: ru.ClassSymbol = ru.typeOf[Connector].typeSymbol.asClass
|
||||
private val classMirror: ru.ClassMirror = mirror.reflectClass(clazz)
|
||||
private val nameSignature = ru.typeOf[Connector].decls
|
||||
.filter(_.isMethod)
|
||||
.filter(it => genMethodNames.contains(it.name.toString))
|
||||
.filter(it => {
|
||||
it.typeSignature.paramLists(0).find(_.asTerm.info =:= ru.typeOf[Option[CallContext]]).isDefined
|
||||
})
|
||||
.map(it => {
|
||||
val (methodName, typeSignature) = (it.name.toString, it.typeSignature)
|
||||
methodName match {
|
||||
// case name if(name.matches("(get|check).*")) => GetGenerator(methodName, typeSignature)
|
||||
// case name if(name.matches("(create|make).*")) => PostGenerator(methodName, typeSignature)
|
||||
case _ => PostGenerator(methodName, typeSignature)//throw new NotImplementedError(s" not support method name: $methodName")
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
// private val types: Iterable[ru.Type] = symbols.map(_.typeSignature)
|
||||
// println(symbols)
|
||||
println("-------------------")
|
||||
nameSignature.map(_.toString).foreach(println(_))
|
||||
println("===================")
|
||||
|
||||
val path = new File(getClass.getResource("").toURI.toString.replaceFirst("target/.*", "").replace("file:", ""), "src/main/scala/code/bankconnectors/rest/RestConnector_vMar2019.scala")
|
||||
val source = FileUtils.readFileToString(path)
|
||||
val start = "//---------------- dynamic start -------------------please don't modify this line"
|
||||
val end = "//---------------- dynamic end ---------------------please don't modify this line"
|
||||
val placeHolderInSource = s"""(?s)$start.+$end"""
|
||||
val insertCode =
|
||||
s"""$start
|
||||
|// ---------- create on ${new Date()}
|
||||
|${nameSignature.map(_.toString).mkString}
|
||||
|$end """.stripMargin
|
||||
val newSource = source.replaceFirst(placeHolderInSource, insertCode)
|
||||
FileUtils.writeStringToFile(path, newSource)
|
||||
|
||||
// to check whether example is correct.
|
||||
private val tp: ru.Type = ReflectUtils.getTypeByName("com.openbankproject.commons.dto.InBoundGetProductCollectionItemsTree")
|
||||
|
||||
println(createDocExample(tp))
|
||||
buildMethods(commonMethodNames,
|
||||
"src/main/scala/code/bankconnectors/rest/RestConnector_vMar2019.scala",
|
||||
methodName => s"""sendRequest[InBound](getUrl(callContext, "$methodName"), HttpMethods.POST, req, callContext)""")
|
||||
}
|
||||
|
||||
case class GetGenerator(methodName: String, tp: Type) {
|
||||
private[this] def paramAnResult = tp.toString
|
||||
.replaceAll("(\\w+\\.)+", "")
|
||||
.replaceFirst("\\)", "): ")
|
||||
.replaceFirst("""\btype\b""", "`type`")
|
||||
.replace("cardAttributeType: Value", "cardAttributeType: CardAttributeType.Value") // scala enum is bad for Reflection
|
||||
.replace("productAttributeType: Value", "productAttributeType: ProductAttributeType.Value") // scala enum is bad for Reflection
|
||||
.replace("accountAttributeType: Value", "accountAttributeType: AccountAttributeType.Value") // scala enum is bad for Reflection
|
||||
.replaceFirst("""callContext:\s*Option\[CallContext\]""", "@CacheKeyOmit callContext: Option[CallContext]")
|
||||
|
||||
private[this] val params = tp.paramLists(0).filterNot(_.asTerm.info =:= ru.typeOf[Option[CallContext]]).map(_.name.toString)
|
||||
|
||||
private[this] val description = methodName.replace("Future", "").replaceAll("([a-z])([A-Z])", "$1 $2").capitalize
|
||||
private[this] val resultType = tp.resultType.toString.replaceAll("(\\w+\\.)+", "")
|
||||
|
||||
private[this] val isReturnBox = resultType.startsWith("Box[")
|
||||
|
||||
private[this] val cachMethodName = if(isReturnBox) "memoizeSyncWithProvider" else "memoizeWithProvider"
|
||||
|
||||
private[this] val outBoundExample = {
|
||||
var typeName = s"com.openbankproject.commons.dto.OutBound${methodName.capitalize}"
|
||||
if(!ReflectUtils.isTypeExists(typeName)) typeName += "Future"
|
||||
val outBoundType = ReflectUtils.getTypeByName(typeName)
|
||||
createDocExample(outBoundType).replaceAll("(?m)^(\\S)", " $1")
|
||||
}
|
||||
private[this] val inBoundExample = {
|
||||
var typeName = s"com.openbankproject.commons.dto.InBound${methodName.capitalize}"
|
||||
if(!ReflectUtils.isTypeExists(typeName)) typeName += "Future"
|
||||
val inBoundType = ReflectUtils.getTypeByName(typeName)
|
||||
createDocExample(inBoundType).replaceAll("(?m)^(\\S)", " $1")
|
||||
}
|
||||
|
||||
val signature = s"$methodName$paramAnResult"
|
||||
|
||||
val pathVariables = tp.paramLists(0) //For a method or poly type, a list of its value parameter sections.
|
||||
.filterNot(_.info =:= ru.typeOf[Option[CallContext]])
|
||||
.map { it =>
|
||||
// make sure if param signature is: queryParams: List[OBPQueryParam] , the param name must be queryParams
|
||||
val paramName = if(it.info <:< typeOf[Seq[OBPQueryParam]]) "queryParams" else it.name.toString
|
||||
val paramValue = it.name.toString
|
||||
s""", ("$paramName", $paramValue)"""
|
||||
}.mkString
|
||||
|
||||
val urlDemo = s"/$methodName" + params.map(it => s"/$it/{$it}").mkString
|
||||
val jsonType = {
|
||||
val typeName = s"com.openbankproject.commons.dto.InBound${methodName.capitalize}"
|
||||
if(ReflectUtils.isTypeExists(typeName)) {
|
||||
s"InBound${methodName.capitalize}"
|
||||
}
|
||||
else {
|
||||
s"InBound${methodName.capitalize}Future"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val dataType = if (resultType.startsWith("Future[Box[")) {
|
||||
resultType.replaceFirst("""Future\[Box\[\((.+), Option\[CallContext\]\)\]\]""", "$1").replaceFirst("(\\])|$", "Commons$1")
|
||||
} else if (resultType.startsWith("OBPReturnType[Box[")) {
|
||||
resultType.replaceFirst("""OBPReturnType\[Box\[(.+)\]\]""", "$1").replaceFirst("(\\])|$", "Commons$1")
|
||||
} else if (isReturnBox) {
|
||||
//Box[(InboundAdapterInfoInternal, Option[CallContext])]
|
||||
resultType.replaceFirst("""Box\[\((.+), Option\[CallContext\]\)\]""", "$1").replaceFirst("(\\])|$", "Commons$1")
|
||||
} else {
|
||||
throw new NotImplementedError(s"this return type not implemented: $resultType")
|
||||
}
|
||||
val returnEntityType = dataType.replaceFirst("Commons$", "").replaceAll(".*\\[|\\].*", "")
|
||||
|
||||
val lastMapStatement = if (isReturnBox || resultType.startsWith("Future[Box[")) {
|
||||
"""| boxedResult.map { result =>
|
||||
| (result.data, buildCallContext(result.inboundAdapterCallContext, callContext))
|
||||
| }
|
||||
""".stripMargin
|
||||
} else {
|
||||
"""| boxedResult match {
|
||||
| case Full(result) => (Full(result.data), buildCallContext(result.inboundAdapterCallContext, callContext))
|
||||
| case result: EmptyBox => (result, callContext) // Empty and Failure all match this case
|
||||
| }
|
||||
""".stripMargin
|
||||
}
|
||||
|
||||
override def toString =
|
||||
s"""
|
||||
|messageDocs += MessageDoc(
|
||||
| process = "obp.$methodName",
|
||||
| messageFormat = messageFormat,
|
||||
| description = "$description",
|
||||
| outboundTopic = None,
|
||||
| inboundTopic = None,
|
||||
| exampleOutboundMessage = (
|
||||
| $outBoundExample
|
||||
| ),
|
||||
| exampleInboundMessage = (
|
||||
| $inBoundExample
|
||||
| ),
|
||||
| adapterImplementation = Some(AdapterImplementation("- Core", 1))
|
||||
| )
|
||||
| // url example: $urlDemo
|
||||
| override def $signature = saveConnectorMetric {
|
||||
| /**
|
||||
| * Please note that "var cacheKey = (randomUUID().toString, randomUUID().toString, randomUUID().toString)"
|
||||
| * is just a temporary value filed with UUID values in order to prevent any ambiguity.
|
||||
| * The real value will be assigned by Macro during compile time at this line of a code:
|
||||
| * https://github.com/OpenBankProject/scala-macros/blob/master/macros/src/main/scala/com/tesobe/CacheKeyFromArgumentsMacro.scala#L49
|
||||
| */
|
||||
| var cacheKey = (randomUUID().toString, randomUUID().toString, randomUUID().toString)
|
||||
| CacheKeyFromArguments.buildCacheKey {
|
||||
| Caching.${cachMethodName}(Some(cacheKey.toString()))(banksTTL second){
|
||||
| val url = ""//getUrl(callContext, "$methodName" $pathVariables)
|
||||
| sendGetRequest[$jsonType](url, callContext)
|
||||
| .map { boxedResult =>
|
||||
| $lastMapStatement
|
||||
| }
|
||||
| }
|
||||
| }
|
||||
| }("$methodName")
|
||||
""".stripMargin
|
||||
}
|
||||
|
||||
case class PostGenerator(methodName: String, tp: Type) {
|
||||
private[this] def paramAnResult = tp.toString
|
||||
.replaceAll("(\\w+\\.)+", "")
|
||||
.replaceFirst("\\)", "): ")
|
||||
.replace("cardAttributeType: Value", "cardAttributeType: CardAttributeType.Value") // scala enum is bad for Reflection
|
||||
.replace("productAttributeType: Value", "productAttributeType: ProductAttributeType.Value") // scala enum is bad for Reflection
|
||||
.replace("accountAttributeType: Value", "accountAttributeType: AccountAttributeType.Value") // scala enum is bad for Reflection
|
||||
.replaceFirst("""\btype\b""", "`type`")
|
||||
|
||||
private[this] val params = tp.paramLists(0).filterNot(_.asTerm.info =:= ru.typeOf[Option[CallContext]]).map(_.name.toString).mkString(", ", ", ", "").replaceFirst("""\btype\b""", "`type`")
|
||||
private[this] val description = methodName.replaceAll("([a-z])([A-Z])", "$1 $2").capitalize
|
||||
|
||||
private[this] val entityName = methodName.replaceFirst("^[a-z]+(OrUpdate)?", "")
|
||||
|
||||
private[this] val resultType = tp.resultType.toString.replaceAll("(\\w+\\.)+", "")
|
||||
|
||||
private[this] val isOBPReturnType = resultType.startsWith("OBPReturnType[")
|
||||
|
||||
private[this] val outBoundExample = {
|
||||
var typeName = s"com.openbankproject.commons.dto.OutBound${methodName.capitalize}"
|
||||
val outBoundType = ReflectUtils.getTypeByName(typeName)
|
||||
createDocExample(outBoundType).replaceAll("(?m)^(\\S)", " $1")
|
||||
}
|
||||
private[this] val inBoundExample = {
|
||||
var typeName = s"com.openbankproject.commons.dto.InBound${methodName.capitalize}"
|
||||
val inBoundType = ReflectUtils.getTypeByName(typeName)
|
||||
createDocExample(inBoundType).replaceAll("(?m)^(\\S)", " $1")
|
||||
}
|
||||
|
||||
val signature = s"$methodName$paramAnResult"
|
||||
val urlDemo = s"/$methodName"
|
||||
|
||||
val lastMapStatement = if (isOBPReturnType) {
|
||||
"""|boxedResult match {
|
||||
| case Full(result) => (Full(result.data), buildCallContext(result.inboundAdapterCallContext, callContext))
|
||||
| case result: EmptyBox => (result, callContext) // Empty and Failure all match this case
|
||||
| }
|
||||
""".stripMargin
|
||||
} else {
|
||||
"""|boxedResult.map { result =>
|
||||
| (result.data, buildCallContext(result.inboundAdapterCallContext, callContext))
|
||||
| }
|
||||
""".stripMargin
|
||||
}
|
||||
val httpMethod = APIUtil.getRequestTypeByMethodName(methodName) match {
|
||||
case "get" => "HttpMethods.GET"
|
||||
case "post" => "HttpMethods.POST"
|
||||
case "put" => "HttpMethods.PUT"
|
||||
case "delete" => "HttpMethods.DELETE"
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the parameters name as a String from `typeSignature` object.
|
||||
* eg: it will return
|
||||
* , bankId, accountId, accountType, accountLabel, currency, initialBalance, accountHolderName, branchId, accountRoutingScheme, accountRoutingAddress
|
||||
*/
|
||||
private[this] val parametersNamesString = tp.paramLists(0)//paramLists will return all the curry parameters set.
|
||||
.filterNot(_.asTerm.info =:= ru.typeOf[Option[CallContext]]) // remove the `CallContext` field.
|
||||
.map(_.name.toString)//get all parameters name
|
||||
.map(it => if(it =="type") "`type`" else it)//This is special case for `type`, it is the keyword in scala.
|
||||
.map(it => if(it == "queryParams") "OBPQueryParam.getLimit(queryParams), OBPQueryParam.getOffset(queryParams), OBPQueryParam.getFromDate(queryParams), OBPQueryParam.getToDate(queryParams)" else it)
|
||||
match {
|
||||
case Nil => ""
|
||||
case list:List[String] => list.mkString(", ", ", ", "")
|
||||
}
|
||||
|
||||
val inboundDataFieldType = ReflectUtils.getTypeByName(s"com.openbankproject.commons.dto.InBound${methodName.capitalize}")
|
||||
.member(TermName("data")).asMethod
|
||||
.returnType.toString.replaceAll(
|
||||
"""(\w+\.)+(\w+\.Value)|(\w+\.)+(\w+)""", "$2$4"
|
||||
)
|
||||
|
||||
override def toString =
|
||||
s"""
|
||||
| messageDocs += ${methodName}Doc
|
||||
| def ${methodName}Doc = MessageDoc(
|
||||
| process = "obp.$methodName",
|
||||
| messageFormat = messageFormat,
|
||||
| description = "$description",
|
||||
| outboundTopic = None,
|
||||
| inboundTopic = None,
|
||||
| exampleOutboundMessage = (
|
||||
| $outBoundExample
|
||||
| ),
|
||||
| exampleInboundMessage = (
|
||||
| $inBoundExample
|
||||
| ),
|
||||
| adapterImplementation = Some(AdapterImplementation("- Core", 1))
|
||||
| )
|
||||
| // url example: $urlDemo
|
||||
| override def $signature = {
|
||||
| import com.openbankproject.commons.dto.{OutBound${methodName.capitalize} => OutBound, InBound${methodName.capitalize} => InBound}
|
||||
| val url = getUrl(callContext, "$methodName")
|
||||
| val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull $parametersNamesString)
|
||||
| val result: OBPReturnType[Box[$inboundDataFieldType]] = sendRequest[InBound](url, $httpMethod, req, callContext).map(convertToTuple(callContext))
|
||||
| result
|
||||
| }
|
||||
""".stripMargin
|
||||
}
|
||||
|
||||
@ -9595,16 +9595,6 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable
|
||||
|
||||
//-----helper methods
|
||||
|
||||
private[this] def convertToTuple[T](callContext: Option[CallContext]) (inbound: Box[InBoundTrait[T]]): (Box[T], Option[CallContext]) = {
|
||||
val boxedResult = inbound match {
|
||||
case Full(in) if (in.status.hasNoError) => Full(in.data)
|
||||
case Full(inbound) if (inbound.status.hasError) =>
|
||||
Failure("INTERNAL-"+ inbound.status.errorCode+". + CoreBank-Status:" + inbound.status.backendMessages)
|
||||
case failureOrEmpty: Failure => failureOrEmpty
|
||||
}
|
||||
(boxedResult, callContext)
|
||||
}
|
||||
|
||||
//TODO hongwei confirm the third valu: OutboundAdapterCallContext#adapterAuthInfo
|
||||
private[this] def buildCallContext(inboundAdapterCallContext: InboundAdapterCallContext, callContext: Option[CallContext]): Option[CallContext] =
|
||||
for (cc <- callContext)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,82 @@
|
||||
package code.bankconnectors.storedprocedure
|
||||
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
|
||||
import code.api.util.APIUtil.MessageDoc
|
||||
import code.bankconnectors.ConnectorBuilderUtil.{getClass, _}
|
||||
import com.openbankproject.commons.model.Status
|
||||
import com.openbankproject.commons.util.Functions
|
||||
import net.liftweb.json
|
||||
import net.liftweb.json.JsonAST.JValue
|
||||
import net.liftweb.json.{Formats, JString, MappingException, Serializer, TypeInfo}
|
||||
import code.api.ResourceDocs1_4_0.MessageDocsSwaggerDefinitions.successStatus
|
||||
import code.api.util.APIUtil
|
||||
import code.api.util.CustomJsonFormats.formats
|
||||
import com.openbankproject.commons.model.Status
|
||||
import net.liftweb.util.StringHelpers
|
||||
import org.apache.commons.io.FileUtils
|
||||
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
|
||||
/**
|
||||
* create ms sql server stored procedure according messageDocs.
|
||||
*/
|
||||
object MSsqlStoredProcedureBuilder {
|
||||
specialMethods // this line just for modify "MappedWebUiPropsProvider"
|
||||
object StatusSerializer extends Serializer[Status] {
|
||||
|
||||
override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), Status] = Functions.doNothing
|
||||
|
||||
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = {
|
||||
case x: Status => json.Extraction.decompose(successStatus)(formats)
|
||||
}
|
||||
}
|
||||
|
||||
def main(args: Array[String]): Unit = {
|
||||
implicit val customFormats = formats + StatusSerializer
|
||||
val messageDocs: ArrayBuffer[MessageDoc] = StoredProcedureConnector_vDec2019.messageDocs
|
||||
def toProcedureName(processName: String) = StringHelpers.snakify(processName.replace("obp.", ""))
|
||||
def toJson(any: Any) = json.prettyRender(json.Extraction.decompose(any))
|
||||
val procedureNameToInbound = messageDocs.map(doc => {
|
||||
val procedureName = toProcedureName(doc.process)
|
||||
val outBoundExample = toJson(doc.exampleOutboundMessage)
|
||||
val inBoundExample = toJson(doc.exampleInboundMessage)
|
||||
buildProcedure(procedureName, outBoundExample, inBoundExample)
|
||||
}).mkString(s"-- auto generated MS sql server procedures script, create on ${APIUtil.DateWithSecondsFormat.format(new Date())}", " \n \n", "")
|
||||
|
||||
val path = new File(getClass.getResource("").toURI.toString.replaceFirst("target/.*", "").replace("file:", ""),
|
||||
"src/main/scala/code/bankconnectors/storedprocedure/MSsqlStoredProcedure.sql")
|
||||
val source = FileUtils.write(path, procedureNameToInbound, "utf-8")
|
||||
}
|
||||
|
||||
def buildProcedure(processName: String, outBoundExample: String, inBoundExample: String) = {
|
||||
s"""
|
||||
|
|
||||
|-- drop procedure $processName
|
||||
|DROP PROCEDURE IF EXISTS $processName;
|
||||
|GO
|
||||
|-- create procedure $processName
|
||||
|CREATE PROCEDURE $processName
|
||||
| @out_bound_json NVARCHAR(MAX),
|
||||
| @in_bound_json NVARCHAR(MAX) OUT
|
||||
| AS
|
||||
| SET nocount on
|
||||
|
|
||||
|-- replace the follow example to real logic
|
||||
|/*
|
||||
|this is example of parameter @out_bound_json
|
||||
| N'${outBoundExample.replaceAll("(?m)^", " ").trim()}'
|
||||
|*/
|
||||
|
|
||||
|-- return example value
|
||||
| SELECT @in_bound_json = (
|
||||
| SELECT
|
||||
| N'${inBoundExample.replaceAll("(?m)^", " ").trim()}'
|
||||
| );
|
||||
|GO
|
||||
|
|
||||
|""".stripMargin
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,374 +1,14 @@
|
||||
package code.bankconnectors.storedprocedure
|
||||
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
|
||||
import code.api.util.APIUtil.AdapterImplementation
|
||||
import code.api.util.CallContext
|
||||
import code.api.util.CodeGenerateUtils.createDocExample
|
||||
import code.bankconnectors.Connector
|
||||
import com.openbankproject.commons.util.ReflectUtils
|
||||
import code.bankconnectors.ConnectorBuilderUtil._
|
||||
import net.liftweb.util.StringHelpers
|
||||
import org.apache.commons.io.FileUtils
|
||||
|
||||
import scala.collection.immutable.List
|
||||
import scala.language.postfixOps
|
||||
import scala.reflect.runtime.universe._
|
||||
import scala.reflect.runtime.{universe => ru}
|
||||
import scala.util.Random
|
||||
|
||||
object StoredProcedureConnectorBuilder extends App {
|
||||
// rewrite method code.webuiprops.MappedWebUiPropsProvider#getWebUiPropsValue, avoid access DB cause dataSource not found exception
|
||||
{
|
||||
import javassist.ClassPool
|
||||
val pool = ClassPool.getDefault
|
||||
val ct = pool.getCtClass("code.webuiprops.MappedWebUiPropsProvider$")
|
||||
val m = ct.getDeclaredMethod("getWebUiPropsValue")
|
||||
m.insertBefore("""return ""; """)
|
||||
ct.toClass
|
||||
}
|
||||
|
||||
val genMethodNames = List(
|
||||
"getAdapterInfo",
|
||||
"getChallengeThreshold",
|
||||
"getChargeLevel",
|
||||
"createChallenge",
|
||||
"getBank",
|
||||
"getBanks",
|
||||
"getBankAccountsForUser",
|
||||
"getUser",
|
||||
"getBankAccount",
|
||||
"getBankAccount",
|
||||
"getBankAccountsBalances",
|
||||
"getCoreBankAccounts",
|
||||
"getBankAccountsHeld",
|
||||
"checkBankAccountExists",
|
||||
"getCounterparty",
|
||||
"getCounterpartyTrait",
|
||||
"getCounterpartyByCounterpartyId",
|
||||
"getCounterpartyByIban",
|
||||
"getCounterparties",
|
||||
"getTransactions",
|
||||
"getTransactionsCore",
|
||||
"getTransaction",
|
||||
"getPhysicalCards",
|
||||
"getPhysicalCardForBank",
|
||||
"deletePhysicalCardForBank",
|
||||
"getPhysicalCardsForBank",
|
||||
"createPhysicalCard",
|
||||
"updatePhysicalCard",
|
||||
"makePayment",
|
||||
"makePaymentv200",
|
||||
"makePaymentv210",
|
||||
"makePaymentImpl",
|
||||
"createTransactionRequest",
|
||||
"createTransactionRequestv200",
|
||||
"createTransactionRequestv210",
|
||||
"createTransactionRequestImpl",
|
||||
"createTransactionRequestImpl210",
|
||||
"getTransactionRequests",
|
||||
"getTransactionRequests210",
|
||||
"getTransactionRequestsImpl",
|
||||
"getTransactionRequestsImpl210",
|
||||
"getTransactionRequestImpl",
|
||||
"getTransactionRequestTypesImpl",
|
||||
"createTransactionAfterChallenge",
|
||||
"createTransactionAfterChallengev200",
|
||||
"createTransactionAfterChallengeV210",
|
||||
"updateBankAccount",
|
||||
"createBankAccount",
|
||||
"getProducts",
|
||||
"getProduct",
|
||||
"createOrUpdateBank",
|
||||
"createOrUpdateProduct",
|
||||
"getBranch",
|
||||
"getBranches",
|
||||
"getAtm",
|
||||
"getAtms",
|
||||
"createTransactionAfterChallengev300",
|
||||
"makePaymentv300",
|
||||
"createTransactionRequestv300",
|
||||
"createCounterparty",
|
||||
"checkCustomerNumberAvailable",
|
||||
"createCustomer",
|
||||
"updateCustomerScaData",
|
||||
"updateCustomerCreditData",
|
||||
"updateCustomerGeneralData",
|
||||
"getCustomersByUserId",
|
||||
"getCustomerByCustomerId",
|
||||
"getCustomerByCustomerNumber",
|
||||
"getCustomerAddress",
|
||||
"createCustomerAddress",
|
||||
"updateCustomerAddress",
|
||||
"deleteCustomerAddress",
|
||||
"createTaxResidence",
|
||||
"getTaxResidence",
|
||||
"deleteTaxResidence",
|
||||
"getCustomers",
|
||||
"getCheckbookOrders",
|
||||
"getStatusOfCreditCardOrder",
|
||||
"createUserAuthContext",
|
||||
"createUserAuthContextUpdate",
|
||||
"deleteUserAuthContexts",
|
||||
"deleteUserAuthContextById",
|
||||
"getUserAuthContexts",
|
||||
"createOrUpdateProductAttribute",
|
||||
"getProductAttributeById",
|
||||
"getProductAttributesByBankAndCode",
|
||||
"deleteProductAttribute",
|
||||
"getAccountAttributeById",
|
||||
"createOrUpdateAccountAttribute",
|
||||
"createAccountAttributes",
|
||||
"getAccountAttributesByAccount",
|
||||
"createOrUpdateCardAttribute",
|
||||
"getCardAttributeById",
|
||||
"getCardAttributesFromProvider",
|
||||
"createAccountApplication",
|
||||
"getAllAccountApplication",
|
||||
"getAccountApplicationById",
|
||||
"updateAccountApplicationStatus",
|
||||
"getOrCreateProductCollection",
|
||||
"getProductCollection",
|
||||
"getOrCreateProductCollectionItem",
|
||||
"getProductCollectionItem",
|
||||
"getProductCollectionItemsTree",
|
||||
"createMeeting",
|
||||
"getMeetings",
|
||||
"getMeeting",
|
||||
"createOrUpdateKycCheck",
|
||||
"createOrUpdateKycDocument",
|
||||
"createOrUpdateKycMedia",
|
||||
"createOrUpdateKycStatus",
|
||||
"getKycChecks",
|
||||
"getKycDocuments",
|
||||
"getKycMedias",
|
||||
"getKycStatuses",
|
||||
"createMessage",
|
||||
"makeHistoricalPayment",
|
||||
"validateChallengeAnswer",
|
||||
"getBankLegacy",
|
||||
"getBanksLegacy",
|
||||
"getBankAccountsForUserLegacy",
|
||||
"getBankAccountLegacy",
|
||||
"getBankAccountByIban",
|
||||
"getBankAccountByRouting",
|
||||
"getBankAccounts",
|
||||
"getCoreBankAccountsLegacy",
|
||||
"getBankAccountsHeldLegacy",
|
||||
"checkBankAccountExistsLegacy",
|
||||
"getCounterpartyByCounterpartyIdLegacy",
|
||||
"getCounterpartiesLegacy",
|
||||
"getTransactionsLegacy",
|
||||
"getTransactionLegacy",
|
||||
"getPhysicalCardsForBankLegacy",
|
||||
"createPhysicalCardLegacy",
|
||||
"createBankAccountLegacy",
|
||||
"getBranchLegacy",
|
||||
"getAtmLegacy",
|
||||
"getCustomerByCustomerIdLegacy",
|
||||
|
||||
//** not support methods:
|
||||
//"getStatus",
|
||||
//"getChargeValue",
|
||||
//"saveTransactionRequestTransaction",
|
||||
//"saveTransactionRequestTransactionImpl",
|
||||
//"saveTransactionRequestChallenge",
|
||||
//"saveTransactionRequestChallengeImpl",
|
||||
//"saveTransactionRequestStatusImpl",
|
||||
//"getTransactionRequestStatuses",
|
||||
//"getTransactionRequestStatusesImpl",
|
||||
// "getTransactionRequestTypes", // final method cant be override
|
||||
//"answerTransactionRequestChallenge",
|
||||
// "createBankAndAccount",
|
||||
// "createSandboxBankAccount",
|
||||
// "setAccountHolder",
|
||||
// "accountExists",
|
||||
// "removeAccount",
|
||||
// "getMatchingTransactionCount",
|
||||
// "createImportedTransaction",
|
||||
// "updateAccountBalance",
|
||||
// "setBankAccountLastUpdated",
|
||||
// "updateAccountLabel",
|
||||
// "updateAccount",
|
||||
// "createOrUpdateBranch",
|
||||
// "createOrUpdateAtm",
|
||||
// "createOrUpdateFXRate",
|
||||
// "accountOwnerExists",
|
||||
// "createViews",
|
||||
// "getCurrentFxRate",
|
||||
// "getCurrentFxRateCached",
|
||||
// "getTransactionRequestTypeCharge",
|
||||
// "UpdateUserAccoutViewsByUsername",
|
||||
// "getTransactionRequestTypeCharges",
|
||||
//"updateUserAccountViewsOld",
|
||||
|
||||
// "getEmptyBankAccount", //not useful!
|
||||
// "getCounterpartyFromTransaction", //not useful!
|
||||
// "getCounterpartiesFromTransaction",//not useful!
|
||||
)
|
||||
|
||||
private val mirror: ru.Mirror = ru.runtimeMirror(getClass().getClassLoader)
|
||||
private val clazz: ru.ClassSymbol = ru.typeOf[Connector].typeSymbol.asClass
|
||||
private val classMirror: ru.ClassMirror = mirror.reflectClass(clazz)
|
||||
|
||||
/*
|
||||
find missing OutBound types
|
||||
val a = ru.typeOf[Connector].decls
|
||||
.filter(_.isMethod)
|
||||
.filter(it => genMethodNames.contains(it.name.toString))
|
||||
.map(_.name.toString)
|
||||
.map(it => s"com.openbankproject.commons.dto.OutBound${it.capitalize}")
|
||||
.filter(it => {
|
||||
try {
|
||||
ReflectUtils.getTypeByName(it)
|
||||
false
|
||||
} catch {
|
||||
case _: Throwable => true
|
||||
}
|
||||
}).foreach(it => println(it.replace("com.openbankproject.commons.dto.OutBound", "")))
|
||||
*/
|
||||
|
||||
private val nameSignature = ru.typeOf[Connector].decls
|
||||
.filter(_.isMethod)
|
||||
.filter(it => genMethodNames.contains(it.name.toString))
|
||||
.map(it => {
|
||||
val (methodName, typeSignature) = (it.name.toString, it.typeSignature)
|
||||
MethodBodyGenerator(methodName, typeSignature)
|
||||
})
|
||||
|
||||
|
||||
// private val types: Iterable[ru.Type] = symbols.map(_.typeSignature)
|
||||
// println(symbols)
|
||||
println("-------------------")
|
||||
nameSignature.map(_.toString).foreach(println(_))
|
||||
println("===================")
|
||||
|
||||
val path = new File(getClass.getResource("").toURI.toString.replaceFirst("target/.*", "").replace("file:", ""), "src/main/scala/code/bankconnectors/storedprocedure/StoredProcedureConnector_vDec2019.scala")
|
||||
val source = FileUtils.readFileToString(path, "utf-8")
|
||||
val start = "//---------------- dynamic start -------------------please don't modify this line"
|
||||
val end = "//---------------- dynamic end ---------------------please don't modify this line"
|
||||
val placeHolderInSource = s"""(?s)$start.+$end"""
|
||||
val insertCode =
|
||||
s"""$start
|
||||
|// ---------- create on ${new Date()}
|
||||
|${nameSignature.map(_.toString).mkString}
|
||||
|$end """.stripMargin
|
||||
val newSource = source.replaceFirst(placeHolderInSource, insertCode)
|
||||
FileUtils.writeStringToFile(path, newSource, "utf-8")
|
||||
|
||||
// to check whether example is correct.
|
||||
private val tp: ru.Type = ReflectUtils.getTypeByName("com.openbankproject.commons.dto.InBoundGetProductCollectionItemsTree")
|
||||
|
||||
println(createDocExample(tp))
|
||||
buildMethods(commonMethodNames,
|
||||
"src/main/scala/code/bankconnectors/storedprocedure/StoredProcedureConnector_vDec2019.scala",
|
||||
methodName => s"""sendRequest[InBound]("${StringHelpers.snakify(methodName)}", req, callContext)""")
|
||||
}
|
||||
|
||||
|
||||
case class MethodBodyGenerator(methodName: String, tp: Type) {
|
||||
private[this] def paramAnResult = tp.toString
|
||||
.replaceAll("(\\w+\\.)+", "")
|
||||
.replaceFirst("\\)", "): ")
|
||||
.replace("cardAttributeType: Value", "cardAttributeType: CardAttributeType.Value") // scala enum is bad for Reflection
|
||||
.replace("productAttributeType: Value", "productAttributeType: ProductAttributeType.Value") // scala enum is bad for Reflection
|
||||
.replace("accountAttributeType: Value", "accountAttributeType: AccountAttributeType.Value") // scala enum is bad for Reflection
|
||||
.replaceFirst("""\btype\b""", "`type`")
|
||||
|
||||
private[this] val params = tp.paramLists(0).filterNot(_.asTerm.info =:= ru.typeOf[Option[CallContext]]).map(_.name.toString).mkString(", ", ", ", "").replaceFirst("""\btype\b""", "`type`")
|
||||
|
||||
private val procedureName = StringHelpers.snakify(methodName)
|
||||
|
||||
private[this] val description = s"""
|
||||
|| |${methodName.replaceAll("([a-z])([A-Z])", "$1 $2").capitalize}
|
||||
|| |
|
||||
|| |The connector name is: stored_procedure_vDec2019
|
||||
|| |The MS SQL Server stored procedure name is: $procedureName
|
||||
"""
|
||||
|
||||
|
||||
private[this] val entityName = methodName.replaceFirst("^[a-z]+(OrUpdate)?", "")
|
||||
|
||||
private[this] val resultType = tp.resultType.toString.replaceAll("(\\w+\\.)+", "")
|
||||
|
||||
private[this] val isOBPReturnType = resultType.startsWith("OBPReturnType[")
|
||||
|
||||
private[this] val outBoundExample = {
|
||||
var typeName = s"com.openbankproject.commons.dto.OutBound${methodName.capitalize}"
|
||||
val outBoundType = ReflectUtils.getTypeByName(typeName)
|
||||
createDocExample(outBoundType).replaceAll("(?m)^(\\S)", " $1")
|
||||
}
|
||||
private[this] val inBoundExample = {
|
||||
var typeName = s"com.openbankproject.commons.dto.InBound${methodName.capitalize}"
|
||||
val inBoundType = ReflectUtils.getTypeByName(typeName)
|
||||
createDocExample(inBoundType).replaceAll("(?m)^(\\S)", " $1")
|
||||
}
|
||||
|
||||
val signature = s"$methodName$paramAnResult"
|
||||
val urlDemo = s"/$methodName"
|
||||
|
||||
val lastMapStatement = if (isOBPReturnType) {
|
||||
"""|boxedResult match {
|
||||
| case Full(result) => (Full(result.data), buildCallContext(result.inboundAdapterCallContext, callContext))
|
||||
| case result: EmptyBox => (result, callContext) // Empty and Failure all match this case
|
||||
| }
|
||||
""".stripMargin
|
||||
} else {
|
||||
"""|boxedResult.map { result =>
|
||||
| (result.data, buildCallContext(result.inboundAdapterCallContext, callContext))
|
||||
| }
|
||||
""".stripMargin
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all the parameters name as a String from `typeSignature` object.
|
||||
* eg: it will return
|
||||
* , bankId, accountId, accountType, accountLabel, currency, initialBalance, accountHolderName, branchId, accountRoutingScheme, accountRoutingAddress
|
||||
*/
|
||||
private[this] val parametersNamesString = tp.paramLists(0)//paramLists will return all the curry parameters set.
|
||||
.filterNot(_.asTerm.info =:= ru.typeOf[Option[CallContext]]) // remove the `CallContext` field.
|
||||
.map(_.name.toString)//get all parameters name
|
||||
.map(it => if(it =="type") "`type`" else it)//This is special case for `type`, it is the keyword in scala.
|
||||
.map(it => if(it == "queryParams") "OBPQueryParam.getLimit(queryParams), OBPQueryParam.getOffset(queryParams), OBPQueryParam.getFromDate(queryParams), OBPQueryParam.getToDate(queryParams)" else it)
|
||||
match {
|
||||
case Nil => ""
|
||||
case list:List[String] => list.mkString(", ", ", ", "")
|
||||
}
|
||||
|
||||
val inboundDataFieldType = ReflectUtils.getTypeByName(s"com.openbankproject.commons.dto.InBound${methodName.capitalize}")
|
||||
.member(TermName("data")).asMethod
|
||||
.returnType.toString.replaceAll(
|
||||
"""(\w+\.)+(\w+\.Value)|(\w+\.)+(\w+)""", "$2$4"
|
||||
)
|
||||
|
||||
val callContextVal: String = if(tp.paramLists(0).find(_.asTerm.info =:= ru.typeOf[Option[CallContext]]).isEmpty) {
|
||||
"val callContext: Option[CallContext] = None"
|
||||
} else ""
|
||||
|
||||
val randomNum = Random.nextInt(100)
|
||||
override def toString =
|
||||
s"""
|
||||
| messageDocs += ${methodName}Doc$randomNum
|
||||
| private def ${methodName}Doc$randomNum = MessageDoc(
|
||||
| process = "obp.$methodName",
|
||||
| messageFormat = messageFormat,
|
||||
| description = \"\"\"${description}\"\"\".stripMargin,
|
||||
| outboundTopic = None,
|
||||
| inboundTopic = None,
|
||||
| exampleOutboundMessage = (
|
||||
| $outBoundExample
|
||||
| ),
|
||||
| exampleInboundMessage = (
|
||||
| $inBoundExample
|
||||
| ),
|
||||
| adapterImplementation = Some(AdapterImplementation("- Core", 1))
|
||||
| )
|
||||
| // stored procedure name: $procedureName
|
||||
| override def $signature = {
|
||||
| import com.openbankproject.commons.dto.{OutBound${methodName.capitalize} => OutBound, InBound${methodName.capitalize} => InBound}
|
||||
| val procedureName = "$procedureName"
|
||||
| $callContextVal
|
||||
| val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull $parametersNamesString)
|
||||
| val result: OBPReturnType[Box[$inboundDataFieldType]] = sendRequest[InBound](procedureName, req, callContext).map(convertToTuple(callContext))
|
||||
| result
|
||||
| }
|
||||
""".stripMargin
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -124,8 +124,6 @@ object StoredProceduresMockedData {
|
||||
create()
|
||||
case (Full(mapper), Full(connector)) if(mapper == connector && mapper == "org.postgresql.Driver") =>
|
||||
create()
|
||||
case (_, _) if thereIsTheProcedure =>
|
||||
drop()
|
||||
case _ =>
|
||||
""
|
||||
}
|
||||
|
||||
@ -30,10 +30,10 @@ import java.util.Date
|
||||
|
||||
import code.api.util.APIUtil
|
||||
import code.api.util.APIUtil.{MessageDoc}
|
||||
import code.fx.FXRate
|
||||
import com.openbankproject.commons.model.FXRate
|
||||
import code.model._
|
||||
import code.model.dataAccess.MappedBankAccountData
|
||||
import code.transactionrequests.TransactionRequestTypeCharge
|
||||
import com.openbankproject.commons.model.TransactionRequestTypeCharge
|
||||
import com.openbankproject.commons.model.{CounterpartyTrait, _}
|
||||
import net.liftweb.json.JsonAST.JValue
|
||||
import net.liftweb.mapper.By
|
||||
|
||||
@ -33,7 +33,8 @@ import code.api.util._
|
||||
import code.api.v2_1_0._
|
||||
import code.bankconnectors._
|
||||
import code.branches.Branches.Branch
|
||||
import code.fx.{FXRate, fx}
|
||||
import code.fx.fx
|
||||
import com.openbankproject.commons.model.FXRate
|
||||
import code.kafka.KafkaHelper
|
||||
import code.management.ImporterAPI.ImporterTransaction
|
||||
import code.metadata.comments.Comments
|
||||
@ -48,7 +49,8 @@ import com.openbankproject.commons.model.Product
|
||||
import code.transaction.MappedTransaction
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestTypes._
|
||||
import code.transactionrequests.TransactionRequests._
|
||||
import code.transactionrequests.{TransactionRequestTypeCharge, TransactionRequests}
|
||||
import code.transactionrequests.TransactionRequests
|
||||
import com.openbankproject.commons.model.TransactionRequestTypeCharge
|
||||
import code.util.Helper.MdcLoggable
|
||||
import code.util.{Helper, TTLCache}
|
||||
import code.views.Views
|
||||
@ -1165,7 +1167,7 @@ trait KafkaMappedConnector_vMar2017 extends Connector with KafkaHelper with MdcL
|
||||
case Full(f) => Full(TransactionRequestTypeCharge2(f))
|
||||
case _ =>
|
||||
for {
|
||||
fromAccount <- getBankAccount(bankId, accountId)
|
||||
fromAccount <- getBankAccountOld(bankId, accountId)
|
||||
fromAccountCurrency <- tryo{ fromAccount.currency }
|
||||
} yield {
|
||||
TransactionRequestTypeCharge2(InboundTransactionRequestTypeCharge(
|
||||
@ -1330,7 +1332,7 @@ trait KafkaMappedConnector_vMar2017 extends Connector with KafkaHelper with MdcL
|
||||
val viewsDeleted = Views.views.vend.removeAllViews(bankId, accountId)
|
||||
|
||||
//delete account
|
||||
val account = getBankAccount(bankId, accountId)
|
||||
val account = getBankAccountOld(bankId, accountId)
|
||||
|
||||
val accountDeleted = account match {
|
||||
case acc => true //acc.delete_! //TODO
|
||||
@ -1370,7 +1372,7 @@ trait KafkaMappedConnector_vMar2017 extends Connector with KafkaHelper with MdcL
|
||||
private def createAccountIfNotExisting(bankId: BankId, accountId: AccountId, accountNumber: String,
|
||||
accountType: String, accountLabel: String, currency: String,
|
||||
balanceInSmallestCurrencyUnits: Long, accountHolderName: String) : BankAccount = {
|
||||
getBankAccount(bankId, accountId) match {
|
||||
getBankAccountOld(bankId, accountId) match {
|
||||
case Full(a) =>
|
||||
logger.info(s"account with id $accountId at bank with id $bankId already exists. No need to create a new one.")
|
||||
a
|
||||
@ -1420,7 +1422,7 @@ trait KafkaMappedConnector_vMar2017 extends Connector with KafkaHelper with MdcL
|
||||
|
||||
//this will be Full(true) if everything went well
|
||||
val result = for {
|
||||
acc <- getBankAccount(bankId, accountId)
|
||||
acc <- getBankAccountOld(bankId, accountId)
|
||||
(bank, _)<- getBankLegacy(bankId, None)
|
||||
} yield {
|
||||
//acc.balance = newBalance
|
||||
@ -1512,7 +1514,7 @@ trait KafkaMappedConnector_vMar2017 extends Connector with KafkaHelper with MdcL
|
||||
bankId <- getBankByNationalIdentifier(bankNationalIdentifier).map(_.bankId)
|
||||
account <- getAccountByNumber(bankId, accountNumber)
|
||||
} yield {
|
||||
val acc = getBankAccount(bankId, account.accountId)
|
||||
val acc = getBankAccountOld(bankId, account.accountId)
|
||||
acc match {
|
||||
case a => true //a.lastUpdate = updateDate //TODO
|
||||
// case _ => logger.warn("can't set bank account.lastUpdated because the account was not found"); false
|
||||
@ -1529,7 +1531,7 @@ trait KafkaMappedConnector_vMar2017 extends Connector with KafkaHelper with MdcL
|
||||
override def updateAccountLabel(bankId: BankId, accountId: AccountId, label: String) = {
|
||||
//this will be Full(true) if everything went well
|
||||
val result = for {
|
||||
acc <- getBankAccount(bankId, accountId)
|
||||
acc <- getBankAccountOld(bankId, accountId)
|
||||
(bank, _)<- getBankLegacy(bankId, None)
|
||||
d <- MappedBankAccountData.find(By(MappedBankAccountData.accountId, accountId.value), By(MappedBankAccountData.bankId, bank.bankId.value))
|
||||
} yield {
|
||||
@ -1595,7 +1597,7 @@ trait KafkaMappedConnector_vMar2017 extends Connector with KafkaHelper with MdcL
|
||||
for {
|
||||
counterpartyId <- tryo{r.counterpartyId}
|
||||
counterpartyName <- tryo{r.counterpartyName}
|
||||
thisAccount <- getBankAccount(BankId(r.bankId), AccountId(r.accountId))
|
||||
thisAccount <- getBankAccountOld(BankId(r.bankId), AccountId(r.accountId))
|
||||
//creates a dummy OtherBankAccount without an OtherBankAccountMetadata, which results in one being generated (in OtherBankAccount init)
|
||||
dummyOtherBankAccount <- tryo{createCounterparty(counterpartyId, counterpartyName, thisAccount, None)}
|
||||
//and create the proper OtherBankAccount with the correct "id" attribute set to the metadataId of the OtherBankAccountMetadata object
|
||||
|
||||
@ -1,32 +1,11 @@
|
||||
package code.bankconnectors.vMay2019
|
||||
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
import java.util.regex.Matcher
|
||||
|
||||
import code.api.util.ApiTag.ResourceDocTag
|
||||
import code.api.util.{ApiTag, CallContext, OBPQueryParam}
|
||||
import code.bankconnectors.Connector
|
||||
import com.openbankproject.commons.util.ReflectUtils
|
||||
import org.apache.commons.io.FileUtils
|
||||
import org.apache.commons.lang3.StringUtils._
|
||||
import code.bankconnectors.ConnectorBuilderUtil._
|
||||
|
||||
import scala.collection.immutable.List
|
||||
import scala.language.postfixOps
|
||||
import scala.reflect.runtime.universe._
|
||||
import scala.reflect.runtime.{universe => ru}
|
||||
import code.api.util.CodeGenerateUtils.createDocExample
|
||||
import javassist.ClassPool
|
||||
|
||||
object KafkaConnectorBuilder extends App {
|
||||
// rewrite method code.webuiprops.MappedWebUiPropsProvider#getWebUiPropsValue, avoid access DB cause dataSource not found exception
|
||||
{
|
||||
val pool = ClassPool.getDefault
|
||||
val ct = pool.getCtClass("code.webuiprops.MappedWebUiPropsProvider$")
|
||||
val m = ct.getDeclaredMethod("getWebUiPropsValue")
|
||||
m.insertBefore("""return ""; """)
|
||||
ct.toClass
|
||||
}
|
||||
|
||||
val genMethodNames = List(
|
||||
"getAdapterInfo",
|
||||
@ -42,175 +21,9 @@ object KafkaConnectorBuilder extends App {
|
||||
"getCustomerByCustomerNumber"
|
||||
)
|
||||
|
||||
private val mirror: ru.Mirror = ru.runtimeMirror(getClass().getClassLoader)
|
||||
private val clazz: ru.ClassSymbol = ru.typeOf[Connector].typeSymbol.asClass
|
||||
private val classMirror: ru.ClassMirror = mirror.reflectClass(clazz)
|
||||
private val nameSignature = ru.typeOf[Connector].decls
|
||||
.filter(_.isMethod)
|
||||
.filter(it => genMethodNames.contains(it.name.toString))
|
||||
.filter(it => {
|
||||
it.typeSignature.paramLists(0).find(_.asTerm.info =:= ru.typeOf[Option[CallContext]]).isDefined
|
||||
})
|
||||
.map(it => (it.name.toString, it.typeSignature))
|
||||
.map{
|
||||
case (methodName, typeSignature) if(methodName.matches("^(get|check).+")) => GetGenerator(methodName, typeSignature)
|
||||
case other => new CommonGenerator(other._1, other._2)
|
||||
}
|
||||
|
||||
if(genMethodNames.size > nameSignature.size) {
|
||||
val foundMehotdNames = nameSignature.map(_.methodName).toList
|
||||
val notFoundMethodNames = genMethodNames.diff(foundMehotdNames)
|
||||
throw new IllegalArgumentException(s"some method not found, please check typo: ${notFoundMethodNames.mkString(", ")}")
|
||||
}
|
||||
|
||||
// private val types: Iterable[ru.Type] = symbols.map(_.typeSignature)
|
||||
// println(symbols)
|
||||
println("-------------------")
|
||||
nameSignature.map(_.toString).foreach(println(_))
|
||||
println("===================")
|
||||
|
||||
val path = new File(getClass.getResource("").toURI.toString.replaceFirst("target/.*", "").replace("file:", ""), "src/main/scala/code/bankconnectors/vMay2019/KafkaMappedConnector_vMay2019.scala")
|
||||
val source = FileUtils.readFileToString(path)
|
||||
val start = "//---------------- dynamic start -------------------please don't modify this line"
|
||||
val end = "//---------------- dynamic end ---------------------please don't modify this line"
|
||||
val placeHolderInSource = s"""(?s)$start.+$end"""
|
||||
val insertCode =
|
||||
s"""
|
||||
|$start
|
||||
|// ---------- create on ${new Date()}
|
||||
|${nameSignature.map(_.toString).mkString}
|
||||
|$end
|
||||
""".stripMargin
|
||||
val newSource = source.replaceFirst(placeHolderInSource, Matcher.quoteReplacement(insertCode))
|
||||
FileUtils.writeStringToFile(path, newSource)
|
||||
|
||||
// to check whether example is correct.
|
||||
private val tp: ru.Type = ReflectUtils.getTypeByName("com.openbankproject.commons.dto.InBoundGetProductCollectionItemsTree")
|
||||
|
||||
println(createDocExample(tp))
|
||||
}
|
||||
|
||||
class CommonGenerator(val methodName: String, tp: Type) {
|
||||
protected[this] def paramAnResult = tp.toString
|
||||
.replaceAll("""(\w+\.)+(\w+\.Value)""", "$2")
|
||||
.replaceAll("""(\w+\.){2,}""", "")
|
||||
.replaceFirst("\\)", "): ")
|
||||
.replaceFirst("""\btype\b""", "`type`")
|
||||
|
||||
val queryParamsListName = tp.paramLists(0).find(symbol => symbol.info <:< typeOf[List[OBPQueryParam]]).map(_.name.toString)
|
||||
|
||||
private[this] val params: String = tp.paramLists(0)
|
||||
.filterNot(_.asTerm.info =:= ru.typeOf[Option[CallContext]])
|
||||
.map(_.name.toString)
|
||||
.map(it => if(it =="type") "`type`" else it)
|
||||
match {
|
||||
case Nil => ""
|
||||
case list:List[String] => {
|
||||
val paramNames = list.mkString(", ", ", ", "")
|
||||
queryParamsListName match {
|
||||
// deal with queryParams: List[OBPQueryParam], convert to four parameters
|
||||
case Some(queryParams) => paramNames.replaceFirst(
|
||||
s"""\\b(${queryParams})\\b""",
|
||||
"OBPQueryParam.getLimit($1), OBPQueryParam.getOffset($1), OBPQueryParam.getFromDate($1), OBPQueryParam.getToDate($1)"
|
||||
)
|
||||
case scala.None => paramNames
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private[this] val description = methodName.replace("Future", "").replaceAll("([a-z])([A-Z])", "$1 $2").capitalize
|
||||
|
||||
private[this] val outBoundExample = {
|
||||
var typeName = s"com.openbankproject.commons.dto.OutBound${methodName.capitalize}"
|
||||
if(!ReflectUtils.isTypeExists(typeName)) typeName += "Future"
|
||||
val outBoundType = ReflectUtils.getTypeByName(typeName)
|
||||
createDocExample(outBoundType).replaceAll("(?m)^(\\S)", " $1")
|
||||
}
|
||||
private[this] val inBoundExample = {
|
||||
var typeName = s"com.openbankproject.commons.dto.InBound${methodName.capitalize}"
|
||||
if(!ReflectUtils.isTypeExists(typeName)) typeName += "Future"
|
||||
val inBoundType = ReflectUtils.getTypeByName(typeName)
|
||||
createDocExample(inBoundType).replaceAll("(?m)^(\\S)", " $1")
|
||||
}
|
||||
|
||||
val signature = s"$methodName$paramAnResult"
|
||||
|
||||
val outboundName = s"OutBound${methodName.capitalize}"
|
||||
val inboundName = s"InBound${methodName.capitalize}"
|
||||
|
||||
val tagValues = ReflectUtils.getType(ApiTag).decls
|
||||
.filter(it => it.isMethod && it.asMethod.returnType <:< typeOf[ResourceDocTag])
|
||||
.map(_.asMethod)
|
||||
.filter(method => method.paramLists.isEmpty)
|
||||
.map(method => ReflectUtils.invokeMethod(ApiTag, method))
|
||||
.map(_.asInstanceOf[ResourceDocTag])
|
||||
.map(_.tag)
|
||||
.map(it => (it.replaceAll("""\W""", "").toLowerCase, it))
|
||||
.toMap
|
||||
|
||||
val tag = tagValues.filter(it => methodName.toLowerCase().contains(it._1)).map(_._2).toList.sortBy(_.size).lastOption.getOrElse("- Core")
|
||||
|
||||
val queryParamList = params.replaceFirst("""\b(.+?):\s*List[OBPQueryParam]""", "OBPQueryParam.getLimit($1), OBPQueryParam.getOffset($1), OBPQueryParam.getFromDate($1), OBPQueryParam.getToDate(queryParams)")
|
||||
|
||||
protected[this] def methodBody: String =
|
||||
s"""{
|
||||
| import com.openbankproject.commons.dto.{${outboundName} => OutBound, ${inboundName} => InBound}
|
||||
|
|
||||
| val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).get ${params})
|
||||
| logger.debug(s"Kafka ${methodName} Req is: $$req")
|
||||
| processRequest[InBound](req) map (convertToTuple(callContext))
|
||||
| }
|
||||
""".stripMargin
|
||||
|
||||
override def toString =
|
||||
s"""
|
||||
| messageDocs += MessageDoc(
|
||||
| process = s"obp.$${nameOf($methodName _)}",
|
||||
| messageFormat = messageFormat,
|
||||
| description = "$description",
|
||||
| outboundTopic = Some(Topics.createTopicByClassName(${outboundName}.getClass.getSimpleName).request),
|
||||
| inboundTopic = Some(Topics.createTopicByClassName(${outboundName}.getClass.getSimpleName).response),
|
||||
| exampleOutboundMessage = (
|
||||
| $outBoundExample
|
||||
| ),
|
||||
| exampleInboundMessage = (
|
||||
| $inBoundExample
|
||||
| ),
|
||||
| adapterImplementation = Some(AdapterImplementation("${tag}", 1))
|
||||
| )
|
||||
| override def $signature = ${methodBody}
|
||||
""".stripMargin
|
||||
}
|
||||
|
||||
case class GetGenerator(override val methodName: String, tp: Type) extends CommonGenerator(methodName, tp) {
|
||||
private[this] val resultType = tp.resultType.toString.replaceAll("(\\w+\\.)+", "")
|
||||
|
||||
private[this] val isReturnBox = resultType.startsWith("Box[")
|
||||
|
||||
private[this] val cachMethodName = if(isReturnBox) "memoizeSyncWithProvider" else "memoizeWithProvider"
|
||||
|
||||
private[this] val timeoutFieldName = uncapitalize(methodName.replaceFirst("^[a-z]+", "")) + "TTL"
|
||||
private[this] val cacheTimeout = ReflectUtils.findMethod(ru.typeOf[KafkaMappedConnector_vMay2019], timeoutFieldName)(_ => true)
|
||||
.map(_.name.toString)
|
||||
.getOrElse("accountTTL")
|
||||
|
||||
override def paramAnResult = super.paramAnResult
|
||||
.replaceFirst("""callContext:\s*Option\[CallContext\]""", "@CacheKeyOmit callContext: Option[CallContext]")
|
||||
|
||||
override protected[this] def methodBody: String =
|
||||
s"""saveConnectorMetric {
|
||||
| /**
|
||||
| * Please note that "var cacheKey = (randomUUID().toString, randomUUID().toString, randomUUID().toString)"
|
||||
| * is just a temporary value filed with UUID values in order to prevent any ambiguity.
|
||||
| * The real value will be assigned by Macro during compile time at this line of a code:
|
||||
| * https://github.com/OpenBankProject/scala-macros/blob/master/macros/src/main/scala/com/tesobe/CacheKeyFromArgumentsMacro.scala#L49
|
||||
| */
|
||||
| var cacheKey = (randomUUID().toString, randomUUID().toString, randomUUID().toString)
|
||||
| CacheKeyFromArguments.buildCacheKey {
|
||||
| Caching.${cachMethodName}(Some(cacheKey.toString()))(${cacheTimeout} second) ${super.methodBody.replaceAll("(?m)^ ", " ")}
|
||||
| }
|
||||
| }("$methodName")
|
||||
""".stripMargin
|
||||
generateMethods(commonMethodNames,
|
||||
"src/main/scala/code/bankconnectors/vMay2019/KafkaMappedConnector_vMay2019.scala",
|
||||
"processRequest[InBound](req)", true)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1152,19 +1152,6 @@ trait KafkaMappedConnector_vMay2019 extends Connector with KafkaHelper with MdcL
|
||||
|
||||
|
||||
//---------------- dynamic end ---------------------please don't modify this line
|
||||
|
||||
//-----helper methods
|
||||
|
||||
private[this] def convertToTuple[T](callContext: Option[CallContext]) (inbound: Box[InBoundTrait[T]]): (Box[T], Option[CallContext]) = {
|
||||
val boxedResult = inbound match {
|
||||
case Full(in) if (in.status.hasNoError) => Full(in.data)
|
||||
case Full(inbound) if (inbound.status.hasError) =>
|
||||
Failure("INTERNAL-"+ inbound.status.errorCode+". + CoreBank-Status:" + inbound.status.backendMessages)
|
||||
case failureOrEmpty: Failure => failureOrEmpty
|
||||
}
|
||||
(boxedResult, callContext)
|
||||
}
|
||||
|
||||
}
|
||||
object KafkaMappedConnector_vMay2019 extends KafkaMappedConnector_vMay2019{
|
||||
|
||||
|
||||
@ -1,35 +1,13 @@
|
||||
package code.bankconnectors.vSept2018
|
||||
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
import java.util.regex.Matcher
|
||||
|
||||
import code.api.util.ApiTag.ResourceDocTag
|
||||
import code.api.util.{ApiTag, CallContext, OBPQueryParam}
|
||||
import code.bankconnectors.Connector
|
||||
import com.openbankproject.commons.util.ReflectUtils
|
||||
import org.apache.commons.io.FileUtils
|
||||
import org.apache.commons.lang3.StringUtils._
|
||||
import code.bankconnectors.ConnectorBuilderUtil._
|
||||
|
||||
import scala.collection.immutable.List
|
||||
import scala.language.postfixOps
|
||||
import scala.reflect.runtime.universe._
|
||||
import scala.reflect.runtime.{universe => ru}
|
||||
|
||||
import code.api.util.CodeGenerateUtils.createDocExample
|
||||
|
||||
object KafkaConnectorBuilder extends App {
|
||||
// rewrite method code.webuiprops.MappedWebUiPropsProvider#getWebUiPropsValue, avoid access DB cause dataSource not found exception
|
||||
{
|
||||
import javassist.ClassPool
|
||||
val pool = ClassPool.getDefault
|
||||
val ct = pool.getCtClass("code.webuiprops.MappedWebUiPropsProvider$")
|
||||
val m = ct.getDeclaredMethod("getWebUiPropsValue")
|
||||
m.insertBefore("""return ""; """)
|
||||
ct.toClass
|
||||
}
|
||||
|
||||
val needToGenerateMethodsNames = List(
|
||||
val genMethodNames = List(
|
||||
// "getKycChecks",
|
||||
// "getKycDocuments",
|
||||
// "getKycMedias",
|
||||
@ -42,223 +20,12 @@ object KafkaConnectorBuilder extends App {
|
||||
"createBankAccount",
|
||||
)
|
||||
|
||||
private val mirror: ru.Mirror = ru.runtimeMirror(getClass().getClassLoader)
|
||||
private val clazz: ru.ClassSymbol = ru.typeOf[Connector].typeSymbol.asClass
|
||||
private val classMirror: ru.ClassMirror = mirror.reflectClass(clazz)
|
||||
private val generatedMethods: Iterable[CommonGenerator] = ru.typeOf[Connector].decls//this will return all Connector.scala direct(no inherited) declared members,eg: method, val
|
||||
.filter(_.isMethod) //Note: filter by method type.
|
||||
.filter(directlyDeclaredMember => needToGenerateMethodsNames.contains(directlyDeclaredMember.name.toString))// Find the method according to the `genMethodNames` List.
|
||||
.filter(directlyDeclaredMember => {
|
||||
directlyDeclaredMember.typeSignature.paramLists(0).find(_.asTerm.info =:= ru.typeOf[Option[CallContext]]).isDefined //Just find the method, which has the `CallContext` as parameter
|
||||
})
|
||||
.map(directlyDeclaredMember => (directlyDeclaredMember.name.toString, directlyDeclaredMember.typeSignature)) //eg: (name =createBankAccount), (typeSignature = all parameters, return type info)
|
||||
.map{
|
||||
case (methodName, typeSignature) if(methodName.matches("^(get|check).+")) => GetGenerator(methodName, typeSignature)
|
||||
//Not finished yet, need to prepare create,delete Generator too.
|
||||
case (methodName, typeSignature) => new CommonGenerator(methodName, typeSignature)
|
||||
}
|
||||
|
||||
//If there are more methods in the `needToGenerateMethodsNames` than `generatedMethods`, it mean some methods names are wrong...
|
||||
//This will throw the Exception back directly
|
||||
if(needToGenerateMethodsNames.size > generatedMethods.size) {
|
||||
val generatedMethodsNames = generatedMethods.map(_.methodName).toList
|
||||
val invalidMethodNames = needToGenerateMethodsNames.filterNot(generatedMethodsNames.contains(_))
|
||||
throw new IllegalArgumentException(s"Some methods names are invalid, please check following methods typo: ${invalidMethodNames.mkString(", ")}")
|
||||
}
|
||||
|
||||
println("-------------------")
|
||||
// generatedMethods.map(_.toString).foreach(println(_))
|
||||
println("===================")
|
||||
|
||||
val path = new File(getClass.getResource("").toURI.toString.replaceFirst("target/.*", "").replace("file:", ""), "src/main/scala/code/bankconnectors/vSept2018/KafkaMappedConnector_vSept2018.scala")
|
||||
val source = FileUtils.readFileToString(path)
|
||||
val start = "//---------------- dynamic start -------------------please don't modify this line"
|
||||
val end = "//---------------- dynamic end ---------------------please don't modify this line"
|
||||
val placeHolderInSource = s"""(?s)$start.+$end"""
|
||||
val insertCode =
|
||||
s"""
|
||||
|$start
|
||||
|// ---------- create on ${new Date()}
|
||||
|${generatedMethods.map(_.toString).mkString}
|
||||
|$end
|
||||
""".stripMargin
|
||||
val newSource = source.replaceFirst(placeHolderInSource, Matcher.quoteReplacement(insertCode))
|
||||
FileUtils.writeStringToFile(path, newSource)
|
||||
|
||||
// to check whether example is correct.
|
||||
private val tp: ru.Type = ReflectUtils.getTypeByName("com.openbankproject.commons.dto.InBoundGetProductCollectionItemsTree")
|
||||
|
||||
println(createDocExample(tp))
|
||||
}
|
||||
|
||||
/**
|
||||
* We will generate all the kafka connector code in to toString method:
|
||||
* eg: if we use `createBankAccount` as an example:
|
||||
* toString will return `messageDocs` and `override def createBankAccount`
|
||||
*
|
||||
* @param methodName eg: createBankAccount
|
||||
* @param typeSignature eg: all the parameters and return type information are all in this filed.
|
||||
*/
|
||||
class CommonGenerator(val methodName: String, typeSignature: Type) {
|
||||
/**
|
||||
* typeSignature.toString -->
|
||||
* (bankId: com.openbankproject.commons.model.BankId, accountId: com.openbankproject.commons.model.AccountId, accountType: String,
|
||||
* accountLabel: String, currency: String, initialBalance: BigDecimal, accountHolderName: String, branchId: String, accountRoutingScheme: String,
|
||||
* accountRoutingAddress: String, callContext: Option[code.api.util.CallContext])
|
||||
* code.api.util.APIUtil.OBPReturnType[net.liftweb.common.Box[com.openbankproject.commons.model.BankAccount]]
|
||||
*
|
||||
* .replaceAll("(\\w+\\.)+", "")--> this will clean the package path, only keep the Class Name.
|
||||
* (bankId: BankId, accountId: AccountId, accountType: String, accountLabel: String, currency: String, initialBalance: BigDecimal,
|
||||
* accountHolderName: String, branchId: String, accountRoutingScheme: String, accountRoutingAddress: String, callContext: Option[CallContext])
|
||||
* OBPReturnType[Box[BankAccount]]
|
||||
*
|
||||
* .replaceFirst("\\)", "): ") --> this will add the `:` before the returnType.
|
||||
* (bankId: BankId, accountId: AccountId, accountType: String, accountLabel: String, currency: String, initialBalance: BigDecimal,
|
||||
* accountHolderName: String, branchId: String, accountRoutingScheme: String, accountRoutingAddress: String, callContext: Option[CallContext]):
|
||||
* OBPReturnType[Box[BankAccount]]
|
||||
*
|
||||
* .replaceFirst("""\btype\b""", "`type`") --> type is key word of scala, it must be escaped as a parameter
|
||||
* (bankId: BankId, accountId: AccountId, accountType: String, accountLabel: String, currency: String, initialBalance: BigDecimal,
|
||||
* accountHolderName: String, branchId: String, accountRoutingScheme: String, accountRoutingAddress: String, callContext: Option[CallContext]):
|
||||
* OBPReturnType[Box[BankAccount]]
|
||||
*
|
||||
*/
|
||||
protected[this] def cleanParametersAndReturnTpyeString = typeSignature.toString
|
||||
.replaceAll("(\\w+\\.)+", "")
|
||||
.replaceFirst("\\)", "): ")
|
||||
.replaceFirst("""\btype\b""", "`type`")
|
||||
|
||||
/**
|
||||
* Get all the parameters name as a String from `typeSignature` object.
|
||||
* eg: it will return
|
||||
* , bankId, accountId, accountType, accountLabel, currency, initialBalance, accountHolderName, branchId, accountRoutingScheme, accountRoutingAddress
|
||||
*/
|
||||
private[this] val parametersNamesString = typeSignature.paramLists(0)//paramLists will return all the curry parameters set.
|
||||
.filterNot(_.asTerm.info =:= ru.typeOf[Option[CallContext]]) // remove the `CallContext` field.
|
||||
.map(_.name.toString)//get all parameters name
|
||||
.map(it => if(it =="type") "`type`" else it)//This is special case for `type`, it is the keyword in scala.
|
||||
match {
|
||||
case Nil => ""
|
||||
case list:List[String] => list.mkString(", ", ", ", "")
|
||||
}
|
||||
|
||||
/**
|
||||
* get the messageDocDescription field from the connector method name:
|
||||
*
|
||||
* eg:
|
||||
* createBankAccountFuture --> Create Bank Account
|
||||
* createBankAccount-->Create Bank Account
|
||||
*/
|
||||
private[this] val messageDocDescription = methodName
|
||||
.replace("Future", "")
|
||||
.replaceAll("([a-z])([A-Z])", "$1 $2") //createBankAccount-->create Bank Account
|
||||
.capitalize // create Bank Account --> Create Bank Account
|
||||
|
||||
|
||||
/**
|
||||
* this val really depends on the OutBound classes under path `com.openbankproject.commons.dto`.
|
||||
* Need prepare the OutBound classes before create this.
|
||||
*/
|
||||
private[this] val outBoundExample = {
|
||||
val fullyQualifiedClassName = s"com.openbankproject.commons.dto.OutBound${methodName.capitalize}" // com.openbankproject.commons.dto.OutBoundCreateBankAccount
|
||||
val outBoundType = if(ReflectUtils.isTypeExists(fullyQualifiedClassName))
|
||||
ReflectUtils.getTypeByName(fullyQualifiedClassName)
|
||||
else
|
||||
throw new RuntimeException(s"OutBound${methodName.capitalize} class is not existing in `com.openbankproject.commons.dto` path. Please create it first. ")
|
||||
createDocExample(outBoundType).replaceAll("(?m)^(\\S)", " $1")
|
||||
}
|
||||
|
||||
|
||||
private[this] val inBoundExample = {
|
||||
val fullyQualifiedClassName = s"com.openbankproject.commons.dto.InBound${methodName.capitalize}"
|
||||
|
||||
val inBoundType = if(ReflectUtils.isTypeExists(fullyQualifiedClassName))
|
||||
ReflectUtils.getTypeByName(fullyQualifiedClassName)
|
||||
else
|
||||
throw new RuntimeException(s"InBound${methodName.capitalize} class is not existing in `com.openbankproject.commons.dto` path. Please create it first. ")
|
||||
|
||||
createDocExample(inBoundType).replaceAll("(?m)^(\\S)", " $1")
|
||||
}
|
||||
|
||||
val signature = s"$methodName$cleanParametersAndReturnTpyeString"
|
||||
|
||||
val outboundName = s"OutBound${methodName.capitalize}"
|
||||
val inboundName = s"InBound${methodName.capitalize}"
|
||||
|
||||
val tagValues = ReflectUtils.getType(ApiTag).decls
|
||||
.filter(it => it.isMethod && it.asMethod.returnType <:< typeOf[ResourceDocTag])
|
||||
.map(_.asMethod)
|
||||
.filter(method => method.paramLists.isEmpty)
|
||||
.map(method => ReflectUtils.invokeMethod(ApiTag, method))
|
||||
.map(_.asInstanceOf[ResourceDocTag])
|
||||
.map(_.tag)
|
||||
.map(it => (it.replaceAll("""\W""", "").toLowerCase, it))
|
||||
.toMap
|
||||
|
||||
val tag = tagValues.filter(it => methodName.toLowerCase().contains(it._1)).map(_._2).toList.sortBy(_.size).lastOption.getOrElse("- Core")
|
||||
|
||||
|
||||
protected[this] def methodBody: String =
|
||||
s"""{
|
||||
| import com.openbankproject.commons.dto.{${outboundName} => OutBound, ${inboundName} => InBound}
|
||||
|
|
||||
| val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).get ${parametersNamesString})
|
||||
| logger.debug(s"Kafka ${methodName} Req is: $$req")
|
||||
| processRequest[InBound](req) map (convertToTuple(callContext))
|
||||
| }
|
||||
""".stripMargin
|
||||
|
||||
override def toString =
|
||||
s"""
|
||||
| messageDocs += MessageDoc(
|
||||
| process = "obp.$methodName",
|
||||
| messageFormat = messageFormat,
|
||||
| description = "$messageDocDescription",
|
||||
| outboundTopic = Some(Topics.createTopicByClassName(${outboundName}.getClass.getSimpleName).request),
|
||||
| inboundTopic = Some(Topics.createTopicByClassName(${outboundName}.getClass.getSimpleName).response),
|
||||
| exampleOutboundMessage = (
|
||||
| $outBoundExample
|
||||
| ),
|
||||
| exampleInboundMessage = (
|
||||
| $inBoundExample
|
||||
| ),
|
||||
| adapterImplementation = Some(AdapterImplementation("${tag}", 1))
|
||||
| )
|
||||
| override def $signature = ${methodBody}
|
||||
""".stripMargin
|
||||
}
|
||||
|
||||
case class GetGenerator(override val methodName: String, typeSignature: Type) extends CommonGenerator(methodName, typeSignature) {
|
||||
private[this] val resultType = typeSignature.resultType.toString.replaceAll("(\\w+\\.)+", "")
|
||||
|
||||
private[this] val isReturnBox = resultType.startsWith("Box[")
|
||||
|
||||
private[this] val cachMethodName = if(isReturnBox) "memoizeSyncWithProvider" else "memoizeWithProvider"
|
||||
|
||||
private[this] val timeoutFieldName = uncapitalize(methodName.replaceFirst("^[a-z]+", "")) + "TTL"
|
||||
private[this] val cacheTimeout = ReflectUtils.findMethod(ru.typeOf[KafkaMappedConnector_vSept2018], timeoutFieldName)(_ => true)
|
||||
.map(_.name.toString)
|
||||
.getOrElse("accountTTL")
|
||||
|
||||
override def cleanParametersAndReturnTpyeString = super.cleanParametersAndReturnTpyeString
|
||||
.replaceFirst("""callContext:\s*Option\[CallContext\]""", "@CacheKeyOmit callContext: Option[CallContext]")
|
||||
|
||||
override protected[this] def methodBody: String =
|
||||
s"""saveConnectorMetric {
|
||||
| /**
|
||||
| * Please note that "var cacheKey = (randomUUID().toString, randomUUID().toString, randomUUID().toString)"
|
||||
| * is just a temporary value filed with UUID values in order to prevent any ambiguity.
|
||||
| * The real value will be assigned by Macro during compile time at this line of a code:
|
||||
| * https://github.com/OpenBankProject/scala-macros/blob/master/macros/src/main/scala/com/tesobe/CacheKeyFromArgumentsMacro.scala#L49
|
||||
| */
|
||||
| var cacheKey = (randomUUID().toString, randomUUID().toString, randomUUID().toString)
|
||||
| CacheKeyFromArguments.buildCacheKey {
|
||||
| Caching.${cachMethodName}(Some(cacheKey.toString()))(${cacheTimeout} second) ${super.methodBody.replaceAll("(?m)^ ", " ")}
|
||||
| }
|
||||
| }("$methodName")
|
||||
""".stripMargin
|
||||
generateMethods(genMethodNames,
|
||||
"src/main/scala/code/bankconnectors/vSept2018/KafkaMappedConnector_vSept2018.scala",
|
||||
"processRequest[InBound](req)", true)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -3864,29 +3864,6 @@ trait KafkaMappedConnector_vSept2018 extends Connector with KafkaHelper with Mdc
|
||||
|
||||
|
||||
//---------------- dynamic end ---------------------please don't modify this line
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----helper methods
|
||||
|
||||
private[this] def convertToTuple[T](callContext: Option[CallContext]) (inbound: Box[InBoundTrait[T]]): (Box[T], Option[CallContext]) = {
|
||||
val boxedResult = inbound match {
|
||||
case Full(in) if (in.status.hasNoError) => Full(in.data)
|
||||
case Full(inbound) if (inbound.status.hasError) =>
|
||||
Failure("INTERNAL-"+ inbound.status.errorCode+". + CoreBank-Status:" + inbound.status.backendMessages)
|
||||
case failureOrEmpty: Failure => failureOrEmpty
|
||||
}
|
||||
(boxedResult, callContext)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import java.util.Date
|
||||
|
||||
import net.liftweb.common.Box
|
||||
import net.liftweb.util.SimpleInjector
|
||||
import com.openbankproject.commons.model.DirectDebitTrait
|
||||
|
||||
|
||||
object DirectDebits extends SimpleInjector {
|
||||
@ -24,17 +25,3 @@ trait DirectDebitProvider {
|
||||
def getDirectDebitsByCustomer(customerId: String) : List[DirectDebitTrait]
|
||||
def getDirectDebitsByUser(userId: String) : List[DirectDebitTrait]
|
||||
}
|
||||
|
||||
trait DirectDebitTrait {
|
||||
def directDebitId: String
|
||||
def bankId: String
|
||||
def accountId: String
|
||||
def customerId: String
|
||||
def userId: String
|
||||
def counterpartyId: String
|
||||
def dateSigned: Date
|
||||
def dateCancelled: Date
|
||||
def dateStarts: Date
|
||||
def dateExpires: Date
|
||||
def active: Boolean
|
||||
}
|
||||
@ -4,6 +4,7 @@ import java.util.Date
|
||||
|
||||
import code.api.util.APIUtil
|
||||
import code.util.UUIDString
|
||||
import com.openbankproject.commons.model.DirectDebitTrait
|
||||
import net.liftweb.common.Box
|
||||
import net.liftweb.mapper._
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ package code.fx
|
||||
import java.util.Date
|
||||
|
||||
import code.util.UUIDString
|
||||
import com.openbankproject.commons.model.BankId
|
||||
import com.openbankproject.commons.model.{BankId, FXRate}
|
||||
import net.liftweb.mapper.{MappedStringForeignKey, _}
|
||||
|
||||
class MappedFXRate extends FXRate with LongKeyedMapper[MappedFXRate] with IdPK {
|
||||
@ -42,17 +42,4 @@ class MappedFXRate extends FXRate with LongKeyedMapper[MappedFXRate] with IdPK {
|
||||
|
||||
object MappedFXRate extends MappedFXRate with LongKeyedMetaMapper[MappedFXRate] {}
|
||||
|
||||
trait FXRate {
|
||||
|
||||
def bankId : BankId
|
||||
|
||||
def fromCurrencyCode: String
|
||||
|
||||
def toCurrencyCode: String
|
||||
|
||||
def conversionValue: Double
|
||||
|
||||
def inverseConversionValue: Double
|
||||
|
||||
def effectiveDate: Date
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ object ImporterAPI extends RestHelper with MdcLoggable {
|
||||
}
|
||||
|
||||
val thisBank = Connector.connector.vend.getBankLegacy(t.bankId, None).map(_._1)
|
||||
val thisAcc = Connector.connector.vend.getBankAccount(t.bankId, t.accountId)
|
||||
val thisAcc = Connector.connector.vend.getBankAccountOld(t.bankId, t.accountId)
|
||||
val thisAccJson = JObject(List(JField("holder",
|
||||
JObject(List(
|
||||
JField("holder", JString(thisAcc.map(_.accountHolder).getOrElse(""))),
|
||||
|
||||
@ -485,7 +485,7 @@ case class BankAccountExtended(val bankAccount: BankAccount) extends MdcLoggable
|
||||
object BankAccountX {
|
||||
|
||||
def apply(bankId: BankId, accountId: AccountId) : Box[BankAccount] = {
|
||||
Connector.connector.vend.getBankAccount(bankId, accountId)
|
||||
Connector.connector.vend.getBankAccountOld(bankId, accountId)
|
||||
}
|
||||
|
||||
def apply(bankId: BankId, accountId: AccountId, callContext: Option[CallContext]) : Box[(BankAccount,Option[CallContext])] = {
|
||||
@ -532,9 +532,9 @@ object BankAccountX {
|
||||
val incomingAccountId= AccountId(Constant.INCOMING_ACCOUNT_ID)
|
||||
val outgoingAccountId= AccountId(Constant.OUTGOING_ACCOUNT_ID)
|
||||
if (isOutgoingAccount){
|
||||
LocalMappedConnector.getBankAccount(defaultBankId,outgoingAccountId)
|
||||
LocalMappedConnector.getBankAccountOld(defaultBankId,outgoingAccountId)
|
||||
} else{
|
||||
LocalMappedConnector.getBankAccount(defaultBankId,incomingAccountId)
|
||||
LocalMappedConnector.getBankAccountOld(defaultBankId,incomingAccountId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,7 +319,7 @@ trait OBPDataImport extends MdcLoggable {
|
||||
val duplicateNumbers = numbers diff numbers.distinct
|
||||
|
||||
val existing = data.accounts.flatMap(acc => {
|
||||
Connector.connector.vend.getBankAccount(BankId(acc.bank), AccountId(acc.id))
|
||||
Connector.connector.vend.getBankAccountOld(BankId(acc.bank), AccountId(acc.id))
|
||||
})
|
||||
|
||||
if(!banksNotSpecifiedInImport.isEmpty) {
|
||||
|
||||
@ -218,7 +218,7 @@ class MappedTransaction extends LongKeyedMapper[MappedTransaction] with IdPK wit
|
||||
} yield transaction
|
||||
case _ =>
|
||||
for {
|
||||
acc <- LocalMappedConnector.getBankAccount(theBankId, theAccountId)
|
||||
acc <- LocalMappedConnector.getBankAccountOld(theBankId, theAccountId)
|
||||
transaction <- toTransaction(acc)
|
||||
} yield transaction
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import code.model._
|
||||
import code.transactionrequests.TransactionRequests.{TransactionRequestTypes, _}
|
||||
import code.util.{AccountIdString, UUIDString}
|
||||
import com.openbankproject.commons.model._
|
||||
import com.openbankproject.commons.model.enums.TransactionRequestStatus
|
||||
import net.liftweb.common.{Box, Failure, Full, Logger}
|
||||
import net.liftweb.json
|
||||
import net.liftweb.json.JsonAST.{JField, JObject, JString}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package code.transactionrequests
|
||||
|
||||
import code.util.{UUIDString}
|
||||
import code.util.UUIDString
|
||||
import com.openbankproject.commons.model.TransactionRequestTypeCharge
|
||||
import net.liftweb.mapper._
|
||||
|
||||
class MappedTransactionRequestTypeCharge extends TransactionRequestTypeCharge with LongKeyedMapper[MappedTransactionRequestTypeCharge] with IdPK with CreatedUpdated{
|
||||
@ -47,16 +48,3 @@ case class TransactionRequestTypeChargeMock(
|
||||
}
|
||||
|
||||
|
||||
trait TransactionRequestTypeCharge {
|
||||
|
||||
def transactionRequestTypeId: String
|
||||
|
||||
def bankId: String
|
||||
|
||||
def chargeCurrency: String
|
||||
|
||||
def chargeAmount: String
|
||||
|
||||
def chargeSummary: String
|
||||
}
|
||||
|
||||
|
||||
@ -14,11 +14,6 @@ object TransactionRequests extends SimpleInjector {
|
||||
type PaymentServiceTypes = Value
|
||||
val payments, bulk_payments, periodic_payments = Value
|
||||
}
|
||||
|
||||
object TransactionRequestStatus extends Enumeration {
|
||||
type TransactionRequestStatus = Value
|
||||
val INITIATED, PENDING, NEXT_CHALLENGE_PENDING, FAILED, COMPLETED, FORWARDED, REJECTED = Value
|
||||
}
|
||||
|
||||
object TransactionChallengeTypes extends Enumeration {
|
||||
type TransactionChallengeTypes = Value
|
||||
|
||||
@ -8,7 +8,8 @@ import code.api.v1_4_0.JSONFactory1_4_0._
|
||||
import code.bankconnectors.Connector
|
||||
import code.setup.DefaultUsers
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestTypes._
|
||||
import code.transactionrequests.TransactionRequests.{TransactionChallengeTypes, TransactionRequestStatus}
|
||||
import code.transactionrequests.TransactionRequests.TransactionChallengeTypes
|
||||
import com.openbankproject.commons.model.enums.TransactionRequestStatus
|
||||
import net.liftweb.json.JsonAST.JString
|
||||
import net.liftweb.json.Serialization.write
|
||||
import org.scalatest.Tag
|
||||
|
||||
@ -9,7 +9,7 @@ import code.api.v1_4_0.JSONFactory1_4_0.{ChallengeAnswerJSON, TransactionRequest
|
||||
import code.bankconnectors.Connector
|
||||
import code.fx.fx
|
||||
import code.setup.DefaultUsers
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestStatus
|
||||
import com.openbankproject.commons.model.enums.TransactionRequestStatus
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestTypes._
|
||||
import net.liftweb.json.JsonAST.JString
|
||||
import net.liftweb.json.Serialization.write
|
||||
|
||||
@ -15,7 +15,7 @@ import code.bankconnectors.Connector
|
||||
import code.fx.fx
|
||||
import code.model.BankAccountX
|
||||
import code.setup.{APIResponse, DefaultUsers}
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestStatus
|
||||
import com.openbankproject.commons.model.enums.TransactionRequestStatus
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestTypes._
|
||||
import com.openbankproject.commons.model.{AccountId, BankAccount, TransactionRequestId}
|
||||
import net.liftweb.json.Serialization.write
|
||||
|
||||
@ -16,7 +16,7 @@ import code.bankconnectors.Connector
|
||||
import code.fx.fx
|
||||
import code.model.BankAccountX
|
||||
import code.setup.{APIResponse, DefaultUsers}
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestStatus
|
||||
import com.openbankproject.commons.model.enums.TransactionRequestStatus
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestTypes._
|
||||
import com.github.dwickern.macros.NameOf.nameOf
|
||||
import com.openbankproject.commons.model._
|
||||
|
||||
@ -75,7 +75,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
|
||||
newBank.nationalIdentifier should equal(bankNationalIdentifier)
|
||||
|
||||
And("An account should now exist, with the correct parameters")
|
||||
val foundAccountBox = Connector.connector.vend.getBankAccount(newBank.bankId, returnedAccount.accountId)
|
||||
val foundAccountBox = Connector.connector.vend.getBankAccountOld(newBank.bankId, returnedAccount.accountId)
|
||||
foundAccountBox.isDefined should equal(true)
|
||||
val foundAccount = foundAccountBox.openOrThrowException(attemptedToOpenAnEmptyBox)
|
||||
|
||||
@ -109,7 +109,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
|
||||
allBanksAfter(0).nationalIdentifier should equal(existingBank.nationalIdentifier)
|
||||
|
||||
And("An account should now exist, with the correct parameters")
|
||||
val foundAccountBox = Connector.connector.vend.getBankAccount(existingBank.bankId, returnedAccount.accountId)
|
||||
val foundAccountBox = Connector.connector.vend.getBankAccountOld(existingBank.bankId, returnedAccount.accountId)
|
||||
foundAccountBox.isDefined should equal(true)
|
||||
val foundAccount = foundAccountBox.openOrThrowException(attemptedToOpenAnEmptyBox)
|
||||
|
||||
@ -143,7 +143,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
|
||||
)
|
||||
|
||||
Then("No account is created")
|
||||
Connector.connector.vend.getBankAccount(bankId, accountId).isDefined should equal(false)
|
||||
Connector.connector.vend.getBankAccountOld(bankId, accountId).isDefined should equal(false)
|
||||
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
|
||||
"","","" ) //added field in V220
|
||||
|
||||
Then("An account with the proper parameters should be created")
|
||||
val createdAccBox = Connector.connector.vend.getBankAccount(bankId, accountId)
|
||||
val createdAccBox = Connector.connector.vend.getBankAccountOld(bankId, accountId)
|
||||
createdAccBox.isDefined should be(true)
|
||||
val createdAcc = createdAccBox.openOrThrowException(attemptedToOpenAnEmptyBox)
|
||||
|
||||
@ -179,7 +179,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
|
||||
"","", "")//added field in V220
|
||||
|
||||
Then("An account with the proper parameters should be created")
|
||||
val createdAccBox = Connector.connector.vend.getBankAccount(bankId, accountId)
|
||||
val createdAccBox = Connector.connector.vend.getBankAccountOld(bankId, accountId)
|
||||
createdAccBox.isDefined should be(true)
|
||||
val createdAcc = createdAccBox.openOrThrowException(attemptedToOpenAnEmptyBox)
|
||||
|
||||
|
||||
@ -209,7 +209,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
|
||||
|
||||
|
||||
And("The account should have its balance set to the 'new_balance' value of the most recently completed transaction")
|
||||
val account = Connector.connector.vend.getBankAccount(f.account.bankId, f.account.accountId).openOrThrowException(attemptedToOpenAnEmptyBox)
|
||||
val account = Connector.connector.vend.getBankAccountOld(f.account.bankId, f.account.accountId).openOrThrowException(attemptedToOpenAnEmptyBox)
|
||||
account.balance.toString should equal(f.t2NewBalance) //t2 has a later completed date than t1
|
||||
|
||||
And("The account should have accountLastUpdate set to the current time")
|
||||
@ -244,7 +244,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
|
||||
tsAfter.foreach(checkTransactionOkay)
|
||||
|
||||
And("The account should have its balance set to the 'new_balance' value of the most recently completed transaction")
|
||||
val account = Connector.connector.vend.getBankAccount(f.account.bankId, f.account.accountId).openOrThrowException(attemptedToOpenAnEmptyBox)
|
||||
val account = Connector.connector.vend.getBankAccountOld(f.account.bankId, f.account.accountId).openOrThrowException(attemptedToOpenAnEmptyBox)
|
||||
account.balance.toString should equal(f.t1NewBalance)
|
||||
|
||||
And("The account should have accountLastUpdate set to the current time")
|
||||
@ -267,7 +267,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
|
||||
tsBefore.foreach(checkTransactionOkay)
|
||||
|
||||
//remember lastUpdate time
|
||||
var account = Connector.connector.vend.getBankAccount(f.account.bankId, f.account.accountId).openOrThrowException(attemptedToOpenAnEmptyBox)
|
||||
var account = Connector.connector.vend.getBankAccountOld(f.account.bankId, f.account.accountId).openOrThrowException(attemptedToOpenAnEmptyBox)
|
||||
val oldTime = if(account.lastUpdate != null) account.lastUpdate.getTime else 0
|
||||
|
||||
When("We try to add those transactions again")
|
||||
@ -283,7 +283,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
|
||||
tsAfter.foreach(checkTransactionOkay)
|
||||
|
||||
And("The account should have accountLastUpdate set to the current time (different from first insertion)")
|
||||
account = Connector.connector.vend.getBankAccount(f.account.bankId, f.account.accountId).openOrThrowException(attemptedToOpenAnEmptyBox)
|
||||
account = Connector.connector.vend.getBankAccountOld(f.account.bankId, f.account.accountId).openOrThrowException(attemptedToOpenAnEmptyBox)
|
||||
val dt = (account.lastUpdate.getTime - oldTime)
|
||||
dt > 0 should equal(true)
|
||||
}
|
||||
|
||||
@ -266,7 +266,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Match
|
||||
def verifyAccountCreated(account : SandboxAccountImport) = {
|
||||
val accId = AccountId(account.id)
|
||||
val bankId = BankId(account.bank)
|
||||
val foundAccountBox = Connector.connector.vend.getBankAccount(bankId, accId)
|
||||
val foundAccountBox = Connector.connector.vend.getBankAccountOld(bankId, accId)
|
||||
foundAccountBox.isDefined should equal(true)
|
||||
|
||||
val foundAccount = foundAccountBox.openOrThrowException(attemptedToOpenAnEmptyBox)
|
||||
@ -901,7 +901,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Match
|
||||
getResponse(List(accountWithEmptyId)).code should equal(FAILED)
|
||||
|
||||
//no account should exist with an empty id
|
||||
Connector.connector.vend.getBankAccount(BankId(account1AtBank1.bank), AccountId("")).isDefined should equal(false)
|
||||
Connector.connector.vend.getBankAccountOld(BankId(account1AtBank1.bank), AccountId("")).isDefined should equal(false)
|
||||
|
||||
getResponse(List(acc1AtBank1Json)).code should equal(SUCCESS)
|
||||
|
||||
@ -924,7 +924,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Match
|
||||
getResponse(List(account1AtBank1Json, accountWithSameId)).code should equal(FAILED)
|
||||
|
||||
//no accounts should have been created
|
||||
Connector.connector.vend.getBankAccount(BankId(account1AtBank1.bank), AccountId(account1AtBank1.id)).isDefined should equal(false)
|
||||
Connector.connector.vend.getBankAccountOld(BankId(account1AtBank1.bank), AccountId(account1AtBank1.id)).isDefined should equal(false)
|
||||
|
||||
val accountIdTwo = "2"
|
||||
accountIdTwo should not equal(account1AtBank1.id)
|
||||
@ -934,8 +934,8 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Match
|
||||
getResponse(List(account1AtBank1Json, accountWithDifferentId)).code should equal(SUCCESS)
|
||||
|
||||
//two accounts should have been created
|
||||
Connector.connector.vend.getBankAccount(BankId(account1AtBank1.bank), AccountId(account1AtBank1.id)).isDefined should equal(true)
|
||||
Connector.connector.vend.getBankAccount(BankId(account1AtBank1.bank), AccountId(accountIdTwo)).isDefined should equal(true)
|
||||
Connector.connector.vend.getBankAccountOld(BankId(account1AtBank1.bank), AccountId(account1AtBank1.id)).isDefined should equal(true)
|
||||
Connector.connector.vend.getBankAccountOld(BankId(account1AtBank1.bank), AccountId(accountIdTwo)).isDefined should equal(true)
|
||||
|
||||
}
|
||||
|
||||
@ -956,7 +956,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Match
|
||||
getResponse(List(account1AtBank1Json, Extraction.decompose(otherAccount))).code should equal(FAILED)
|
||||
|
||||
//and the other account should not have been created
|
||||
Connector.connector.vend.getBankAccount(BankId(otherAccount.bank), AccountId(otherAccount.id)).isDefined should equal(false)
|
||||
Connector.connector.vend.getBankAccountOld(BankId(otherAccount.bank), AccountId(otherAccount.id)).isDefined should equal(false)
|
||||
}
|
||||
|
||||
it should "not allow an account to have a bankId not specified in the imported banks" in {
|
||||
@ -977,7 +977,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Match
|
||||
getResponse(List(badBankAccount)).code should equal(FAILED)
|
||||
|
||||
//no account should have been created
|
||||
Connector.connector.vend.getBankAccount(BankId(badBankId), AccountId(account1AtBank1.id)).isDefined should equal(false)
|
||||
Connector.connector.vend.getBankAccountOld(BankId(badBankId), AccountId(account1AtBank1.id)).isDefined should equal(false)
|
||||
}
|
||||
|
||||
it should "not allow an account to be created without an owner" in {
|
||||
@ -1018,14 +1018,14 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Match
|
||||
getResponse(List(Extraction.decompose(accountWithInvalidOwner))).code should equal(FAILED)
|
||||
|
||||
//it should not have been created
|
||||
Connector.connector.vend.getBankAccount(BankId(accountWithInvalidOwner.bank), AccountId(accountWithInvalidOwner.id)).isDefined should equal(false)
|
||||
Connector.connector.vend.getBankAccountOld(BankId(accountWithInvalidOwner.bank), AccountId(accountWithInvalidOwner.id)).isDefined should equal(false)
|
||||
|
||||
//a mix of valid an invalid owners should also not work
|
||||
val accountWithSomeValidSomeInvalidOwners = accountWithInvalidOwner.copy(owners = List(accountWithInvalidOwner.owners + user1.user_name))
|
||||
getResponse(List(Extraction.decompose(accountWithSomeValidSomeInvalidOwners))).code should equal(FAILED)
|
||||
|
||||
//it should not have been created
|
||||
Connector.connector.vend.getBankAccount(BankId(accountWithSomeValidSomeInvalidOwners.bank), AccountId(accountWithSomeValidSomeInvalidOwners.id)).isDefined should equal(false)
|
||||
Connector.connector.vend.getBankAccountOld(BankId(accountWithSomeValidSomeInvalidOwners.bank), AccountId(accountWithSomeValidSomeInvalidOwners.id)).isDefined should equal(false)
|
||||
|
||||
}
|
||||
|
||||
@ -1048,15 +1048,15 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Match
|
||||
getResponse(List(acc1Json, sameNumberJson)).code should equal(FAILED)
|
||||
|
||||
//no accounts should have been created
|
||||
Connector.connector.vend.getBankAccount(BankId(acc1.bank), AccountId(acc1.id)).isDefined should equal(false)
|
||||
Connector.connector.vend.getBankAccount(BankId(acc1.bank), AccountId(acc2.id)).isDefined should equal(false)
|
||||
Connector.connector.vend.getBankAccountOld(BankId(acc1.bank), AccountId(acc1.id)).isDefined should equal(false)
|
||||
Connector.connector.vend.getBankAccountOld(BankId(acc1.bank), AccountId(acc2.id)).isDefined should equal(false)
|
||||
|
||||
//check it works with the normal different number
|
||||
getResponse(List(acc1Json, acc2Json)).code should equal(SUCCESS)
|
||||
|
||||
//and the accounts should be created
|
||||
Connector.connector.vend.getBankAccount(BankId(acc1.bank), AccountId(acc1.id)).isDefined should equal(true)
|
||||
Connector.connector.vend.getBankAccount(BankId(acc1.bank), AccountId(acc2.id)).isDefined should equal(true)
|
||||
Connector.connector.vend.getBankAccountOld(BankId(acc1.bank), AccountId(acc1.id)).isDefined should equal(true)
|
||||
Connector.connector.vend.getBankAccountOld(BankId(acc1.bank), AccountId(acc2.id)).isDefined should equal(true)
|
||||
}
|
||||
|
||||
it should "require transactions to have non-empty ids" in {
|
||||
|
||||
@ -149,29 +149,29 @@ class JsonUtilsTest extends FlatSpec with Matchers {
|
||||
| "noPerson": "[3]",
|
||||
|}
|
||||
|""".stripMargin)
|
||||
|
||||
val expectedZson = json.parse(
|
||||
"""
|
||||
|{
|
||||
| "firstPerson":{
|
||||
| "name":"Shuang",
|
||||
| "age":10
|
||||
| },
|
||||
| "secondName":"Sean",
|
||||
| "secondHobby":"coding"
|
||||
|}
|
||||
|""".stripMargin)
|
||||
|
||||
"get Array type json given index, when exists" should "get given item" taggedAs JsonUtilsTag in {
|
||||
val resultJson = buildJson(arrayRoot, arrayRootSchema)
|
||||
|
||||
val str1 = json.prettyRender(resultJson)
|
||||
println(str1)
|
||||
val str2 = json.prettyRender(expectedZson)
|
||||
|
||||
val expectedJson = json.parse(
|
||||
"""
|
||||
|{
|
||||
| "firstPerson":{
|
||||
| "name":"Shuang",
|
||||
| "age":10
|
||||
| },
|
||||
| "secondName":"Sean",
|
||||
| "secondHobby":"coding"
|
||||
|}
|
||||
|""".stripMargin)
|
||||
|
||||
val str2 = json.prettyRender(expectedJson)
|
||||
str1 shouldEqual str2
|
||||
}
|
||||
|
||||
val zsonList = json.parse(
|
||||
val jsonList = json.parse(
|
||||
"""
|
||||
|[
|
||||
| {
|
||||
@ -202,7 +202,7 @@ class JsonUtilsTest extends FlatSpec with Matchers {
|
||||
| }
|
||||
|]
|
||||
|""".stripMargin)
|
||||
val zsonListSchema = json.parse(
|
||||
val jsonListSchema = json.parse(
|
||||
"""
|
||||
|{
|
||||
| "inboundAdapterCallContext$default":{
|
||||
@ -292,7 +292,7 @@ class JsonUtilsTest extends FlatSpec with Matchers {
|
||||
|}
|
||||
|""".stripMargin)
|
||||
"list type fields" should "properly be convert" taggedAs JsonUtilsTag in {
|
||||
val resultJson = buildJson(zsonList, zsonListSchema)
|
||||
val resultJson = buildJson(jsonList, jsonListSchema)
|
||||
|
||||
val str1 = json.prettyRender(resultJson)
|
||||
val str2 = json.prettyRender(expectListResult)
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<groupId>com.tesobe</groupId>
|
||||
<artifactId>obp-parent</artifactId>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
<version>1.4.4</version>
|
||||
<version>1.5.0</version>
|
||||
</parent>
|
||||
<artifactId>obp-commons</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@ -28,7 +28,7 @@ package com.openbankproject.commons.dto
|
||||
|
||||
import java.util.Date
|
||||
|
||||
import com.openbankproject.commons.model.enums.{CardAttributeType, DynamicEntityOperation}
|
||||
import com.openbankproject.commons.model.enums.{CardAttributeType, CustomerAttributeType, DynamicEntityOperation, StrongCustomerAuthentication, TransactionAttributeType, TransactionRequestStatus}
|
||||
import com.openbankproject.commons.model.enums.StrongCustomerAuthentication.SCA
|
||||
import com.openbankproject.commons.model.{enums, _}
|
||||
import net.liftweb.json.{JObject, JValue}
|
||||
@ -77,6 +77,13 @@ case class OutBoundGetBankAccountsForUser(outboundAdapterCallContext: OutboundAd
|
||||
case class InBoundGetBankAccountsForUser(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[InboundAccountCommons]) extends InBoundTrait[List[InboundAccountCommons]]
|
||||
|
||||
|
||||
case class OutBoundGetBankAccountOld(
|
||||
bankId: BankId,
|
||||
accountId: AccountId) extends TopicTrait
|
||||
case class InBoundGetBankAccountOld(status: Status, data: BankAccountCommons) extends InBoundTrait[BankAccountCommons] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetBankAccount(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
bankId: BankId,
|
||||
accountId: AccountId) extends TopicTrait
|
||||
@ -440,9 +447,11 @@ case class OutBoundGetMeeting(outboundAdapterCallContext: OutboundAdapterCallCon
|
||||
meetingId: String) extends TopicTrait
|
||||
case class InBoundGetMeeting(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: MeetingCommons) extends InBoundTrait[MeetingCommons]
|
||||
|
||||
case class OutBoundGetUser(outboundAdapterCallContext: OutboundAdapterCallContext, name: String, password: String) extends TopicTrait
|
||||
case class OutBoundGetUser(name: String, password: String) extends TopicTrait
|
||||
|
||||
case class InBoundGetUser(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: InboundUser) extends InBoundTrait[InboundUser]
|
||||
case class InBoundGetUser(status: Status, data: InboundUser) extends InBoundTrait[InboundUser] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
|
||||
//create bound case classes
|
||||
@ -482,42 +491,12 @@ case class OutBoundGetBankAccountsHeld(outboundAdapterCallContext: OutboundAdapt
|
||||
case class InBoundGetBankAccountsHeld(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[AccountHeld]) extends InBoundTrait[List[AccountHeld]]
|
||||
|
||||
|
||||
case class OutBoundGetEmptyBankAccount(outboundAdapterCallContext: OutboundAdapterCallContext) extends TopicTrait
|
||||
case class InBoundGetEmptyBankAccount(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: BankAccountCommons) extends InBoundTrait[BankAccountCommons]
|
||||
|
||||
|
||||
case class OutBoundGetCounterpartyFromTransaction(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
bankId: BankId,
|
||||
accountId: AccountId,
|
||||
counterpartyId: String) extends TopicTrait
|
||||
case class InBoundGetCounterpartyFromTransaction(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: Counterparty) extends InBoundTrait[Counterparty]
|
||||
|
||||
|
||||
case class OutBoundGetCounterpartiesFromTransaction(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
bankId: BankId,
|
||||
accountId: AccountId) extends TopicTrait
|
||||
case class InBoundGetCounterpartiesFromTransaction(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[Counterparty]) extends InBoundTrait[List[Counterparty]]
|
||||
|
||||
|
||||
case class OutBoundGetCounterparty(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
thisBankId: BankId,
|
||||
thisAccountId: AccountId,
|
||||
couterpartyId: String) extends TopicTrait
|
||||
case class InBoundGetCounterparty(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: Counterparty) extends InBoundTrait[Counterparty]
|
||||
|
||||
|
||||
case class OutBoundGetCounterparties(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
thisBankId: BankId,
|
||||
thisAccountId: AccountId,
|
||||
viewId: ViewId) extends TopicTrait
|
||||
case class InBoundGetCounterparties(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[CounterpartyTraitCommons]) extends InBoundTrait[List[CounterpartyTraitCommons]]
|
||||
|
||||
case class OutBoundGetPhysicalCards(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
user: User) extends TopicTrait
|
||||
case class InBoundGetPhysicalCards(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[PhysicalCard]) extends InBoundTrait[List[PhysicalCard]]
|
||||
|
||||
|
||||
|
||||
|
||||
case class OutBoundMakeHistoricalPayment(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
fromAccount: BankAccount,
|
||||
@ -714,196 +693,11 @@ case class OutBoundCreatePhysicalCard(outboundAdapterCallContext: OutboundAdapte
|
||||
case class InBoundCreatePhysicalCard(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: PhysicalCard) extends InBoundTrait[PhysicalCard]
|
||||
|
||||
|
||||
case class OutBoundMakePayment(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
initiator: User,
|
||||
fromAccountUID: BankIdAccountId,
|
||||
toAccountUID: BankIdAccountId,
|
||||
amt: BigDecimal,
|
||||
description: String,
|
||||
transactionRequestType: TransactionRequestType) extends TopicTrait
|
||||
case class InBoundMakePayment(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TransactionId) extends InBoundTrait[TransactionId]
|
||||
|
||||
|
||||
case class OutBoundMakePaymentv200(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
fromAccount: BankAccount,
|
||||
toAccount: BankAccount,
|
||||
transactionRequestCommonBody: TransactionRequestCommonBodyJSON,
|
||||
amount: BigDecimal,
|
||||
description: String,
|
||||
transactionRequestType: TransactionRequestType,
|
||||
chargePolicy: String) extends TopicTrait
|
||||
case class InBoundMakePaymentv200(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TransactionId) extends InBoundTrait[TransactionId]
|
||||
|
||||
|
||||
case class OutBoundMakePaymentImpl(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
fromAccount: BankAccount,
|
||||
toAccount: BankAccount,
|
||||
transactionRequestCommonBody: TransactionRequestCommonBodyJSON,
|
||||
amt: BigDecimal,
|
||||
description: String,
|
||||
transactionRequestType: TransactionRequestType,
|
||||
chargePolicy: String) extends TopicTrait
|
||||
case class InBoundMakePaymentImpl(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TransactionId) extends InBoundTrait[TransactionId]
|
||||
|
||||
|
||||
case class OutBoundCreateTransactionRequest(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
initiator: User,
|
||||
fromAccount: BankAccount,
|
||||
toAccount: BankAccount,
|
||||
transactionRequestType: TransactionRequestType,
|
||||
body: TransactionRequestBody) extends TopicTrait
|
||||
case class InBoundCreateTransactionRequest(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TransactionRequest) extends InBoundTrait[TransactionRequest]
|
||||
|
||||
|
||||
case class OutBoundCreateTransactionRequestv200(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
initiator: User,
|
||||
fromAccount: BankAccount,
|
||||
toAccount: BankAccount,
|
||||
transactionRequestType: TransactionRequestType,
|
||||
body: TransactionRequestBody) extends TopicTrait
|
||||
case class InBoundCreateTransactionRequestv200(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TransactionRequest) extends InBoundTrait[TransactionRequest]
|
||||
|
||||
|
||||
case class OutBoundCreateTransactionRequestImpl(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
transactionRequestId: TransactionRequestId,
|
||||
transactionRequestType: TransactionRequestType,
|
||||
fromAccount: BankAccount,
|
||||
counterparty: BankAccount,
|
||||
body: TransactionRequestBody,
|
||||
status: String,
|
||||
charge: TransactionRequestCharge) extends TopicTrait
|
||||
case class InBoundCreateTransactionRequestImpl(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TransactionRequest) extends InBoundTrait[TransactionRequest]
|
||||
|
||||
|
||||
case class OutBoundCreateTransactionRequestImpl210(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
transactionRequestId: TransactionRequestId,
|
||||
transactionRequestType: TransactionRequestType,
|
||||
fromAccount: BankAccount,
|
||||
toAccount: BankAccount,
|
||||
transactionRequestCommonBody: TransactionRequestCommonBodyJSON,
|
||||
details: String,
|
||||
status: String,
|
||||
charge: TransactionRequestCharge,
|
||||
chargePolicy: String) extends TopicTrait
|
||||
case class InBoundCreateTransactionRequestImpl210(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TransactionRequest) extends InBoundTrait[TransactionRequest]
|
||||
|
||||
|
||||
case class OutBoundGetTransactionRequests(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
initiator: User,
|
||||
fromAccount: BankAccount) extends TopicTrait
|
||||
case class InBoundGetTransactionRequests(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[TransactionRequest]) extends InBoundTrait[List[TransactionRequest]]
|
||||
|
||||
|
||||
case class OutBoundGetTransactionRequestStatuses(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
) extends TopicTrait
|
||||
case class InBoundGetTransactionRequestStatuses(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TransactionRequestStatusCommons) extends InBoundTrait[TransactionRequestStatusCommons]
|
||||
|
||||
|
||||
case class OutBoundGetTransactionRequestStatusesImpl(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
) extends TopicTrait
|
||||
case class InBoundGetTransactionRequestStatusesImpl(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TransactionRequestStatusCommons) extends InBoundTrait[TransactionRequestStatusCommons]
|
||||
|
||||
|
||||
case class OutBoundGetTransactionRequestsImpl(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
fromAccount: BankAccount) extends TopicTrait
|
||||
case class InBoundGetTransactionRequestsImpl(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[TransactionRequest]) extends InBoundTrait[List[TransactionRequest]]
|
||||
|
||||
|
||||
case class OutBoundGetTransactionRequestsImpl210(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
fromAccount: BankAccount) extends TopicTrait
|
||||
case class InBoundGetTransactionRequestsImpl210(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[TransactionRequest]) extends InBoundTrait[List[TransactionRequest]]
|
||||
|
||||
|
||||
case class OutBoundGetTransactionRequestImpl(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
transactionRequestId: TransactionRequestId) extends TopicTrait
|
||||
case class InBoundGetTransactionRequestImpl(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TransactionRequest) extends InBoundTrait[TransactionRequest]
|
||||
|
||||
|
||||
case class OutBoundGetTransactionRequestTypes(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
initiator: User,
|
||||
fromAccount: BankAccount) extends TopicTrait
|
||||
case class InBoundGetTransactionRequestTypes(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[TransactionRequestType]) extends InBoundTrait[List[TransactionRequestType]]
|
||||
|
||||
|
||||
case class OutBoundGetTransactionRequestTypesImpl(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
fromAccount: BankAccount) extends TopicTrait
|
||||
case class InBoundGetTransactionRequestTypesImpl(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[TransactionRequestType]) extends InBoundTrait[List[TransactionRequestType]]
|
||||
|
||||
|
||||
case class OutBoundCreateTransactionAfterChallenge(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
initiator: User,
|
||||
transReqId: TransactionRequestId) extends TopicTrait
|
||||
case class InBoundCreateTransactionAfterChallenge(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TransactionRequest) extends InBoundTrait[TransactionRequest]
|
||||
|
||||
|
||||
case class OutBoundCreateTransactionAfterChallengev200(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
fromAccount: BankAccount,
|
||||
toAccount: BankAccount,
|
||||
transactionRequest: TransactionRequest) extends TopicTrait
|
||||
case class InBoundCreateTransactionAfterChallengev200(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TransactionRequest) extends InBoundTrait[TransactionRequest]
|
||||
|
||||
|
||||
case class OutBoundCreateBankAndAccount(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
bankName: String,
|
||||
bankNationalIdentifier: String,
|
||||
accountNumber: String,
|
||||
accountType: String,
|
||||
accountLabel: String,
|
||||
currency: String,
|
||||
accountHolderName: String,
|
||||
branchId: String,
|
||||
accountRoutingScheme: String,
|
||||
accountRoutingAddress: String) extends TopicTrait
|
||||
case class InBoundCreateBankAndAccount(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: (BankCommons, BankAccountCommons))
|
||||
|
||||
|
||||
case class OutBoundGetProducts(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
bankId: BankId, params: Map[String, List[String]]) extends TopicTrait
|
||||
case class InBoundGetProducts(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[ProductCommons]) extends InBoundTrait[List[ProductCommons]]
|
||||
|
||||
|
||||
case class OutBoundGetProduct(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
bankId: BankId,
|
||||
productCode: ProductCode) extends TopicTrait
|
||||
case class InBoundGetProduct(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: ProductCommons) extends InBoundTrait[ProductCommons]
|
||||
|
||||
|
||||
case class OutBoundCreateOrUpdateBank(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
bankId: String,
|
||||
fullBankName: String,
|
||||
shortBankName: String,
|
||||
logoURL: String,
|
||||
websiteURL: String,
|
||||
swiftBIC: String,
|
||||
national_identifier: String,
|
||||
bankRoutingScheme: String,
|
||||
bankRoutingAddress: String) extends TopicTrait
|
||||
case class InBoundCreateOrUpdateBank(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: BankCommons) extends InBoundTrait[BankCommons]
|
||||
|
||||
|
||||
case class OutBoundCreateOrUpdateProduct(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
bankId: String,
|
||||
code: String,
|
||||
parentProductCode: Option[String],
|
||||
name: String,
|
||||
category: String,
|
||||
family: String,
|
||||
superFamily: String,
|
||||
moreInfoUrl: String,
|
||||
details: String,
|
||||
description: String,
|
||||
metaLicenceId: String,
|
||||
metaLicenceName: String) extends TopicTrait
|
||||
case class InBoundCreateOrUpdateProduct(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: ProductCommons) extends InBoundTrait[ProductCommons]
|
||||
|
||||
|
||||
case class OutBoundGetTransactionRequestTypeCharge(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
bankId: BankId,
|
||||
accountId: AccountId,
|
||||
viewId: ViewId,
|
||||
transactionRequestType: TransactionRequestType) extends TopicTrait
|
||||
|
||||
|
||||
case class OutBoundGetCustomerByCustomerId(outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
customerId: String) extends TopicTrait
|
||||
case class InBoundGetCustomerByCustomerId(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: CustomerCommons) extends InBoundTrait[CustomerCommons]
|
||||
@ -1087,17 +881,6 @@ case class OutBoundGetTransactionLegacy (outboundAdapterCallContext: OutboundAda
|
||||
case class InBoundGetTransactionLegacy (inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TransactionCommons) extends InBoundTrait[TransactionCommons]
|
||||
|
||||
|
||||
case class OutBoundGetPhysicalCardsForBankLegacy (outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
bank: Bank,
|
||||
user: User,
|
||||
limit: Int,
|
||||
offset: Int,
|
||||
fromDate: String,
|
||||
toDate: String
|
||||
) extends TopicTrait
|
||||
case class InBoundGetPhysicalCardsForBankLegacy (inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data:List[PhysicalCard]) extends InBoundTrait[List[PhysicalCard]]
|
||||
|
||||
|
||||
case class OutBoundCreatePhysicalCardLegacy (outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
bankCardNumber: String,
|
||||
nameOnCard: String,
|
||||
@ -1136,18 +919,6 @@ case class OutBoundCreateBankAccountLegacy (outboundAdapterCallContext: Outbound
|
||||
case class InBoundCreateBankAccountLegacy (inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: BankAccountCommons) extends InBoundTrait[BankAccountCommons]
|
||||
|
||||
|
||||
case class OutBoundGetBranchLegacy (outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
bankId: BankId,
|
||||
branchId: BranchId) extends TopicTrait
|
||||
case class InBoundGetBranchLegacy (inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: BranchTCommons) extends InBoundTrait[BranchTCommons]
|
||||
|
||||
|
||||
case class OutBoundGetAtmLegacy (outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
bankId: BankId,
|
||||
atmId: AtmId) extends TopicTrait
|
||||
case class InBoundGetAtmLegacy (inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: AtmTCommons) extends InBoundTrait[AtmTCommons]
|
||||
|
||||
|
||||
case class OutBoundGetCustomerByCustomerIdLegacy (outboundAdapterCallContext: OutboundAdapterCallContext,
|
||||
customerId: String) extends TopicTrait
|
||||
case class InBoundGetCustomerByCustomerIdLegacy (inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: CustomerCommons) extends InBoundTrait[CustomerCommons]
|
||||
@ -1174,4 +945,335 @@ case class OutBoundDynamicEntityProcessDoc (outboundAdapterCallContext: Outbound
|
||||
entityName: String,
|
||||
requestBody: Option[FooBar],
|
||||
entityId: Option[String]) extends TopicTrait
|
||||
case class InBoundDynamicEntityProcessDoc (inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: FooBar) extends InBoundTrait[FooBar]
|
||||
case class InBoundDynamicEntityProcessDoc (inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: FooBar) extends InBoundTrait[FooBar]
|
||||
|
||||
|
||||
// --------------------- some special connector methods corresponding InBound and OutBound
|
||||
case class OutBoundCreateChallenges(outboundAdapterCallContext: OutboundAdapterCallContext, bankId: BankId, accountId: AccountId, userIds: List[String], transactionRequestType: TransactionRequestType, transactionRequestId: String, scaMethod: Option[StrongCustomerAuthentication.SCA]) extends TopicTrait
|
||||
case class InBoundCreateChallenges(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[String]) extends InBoundTrait[List[String]]
|
||||
|
||||
case class OutBoundGetEmptyBankAccount() extends TopicTrait
|
||||
case class InBoundGetEmptyBankAccount(status: Status, data: BankAccountCommons) extends InBoundTrait[BankAccountCommons] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetCounterpartyFromTransaction(bankId: BankId, accountId: AccountId, counterpartyId: String) extends TopicTrait
|
||||
case class InBoundGetCounterpartyFromTransaction(status: Status, data: Counterparty) extends InBoundTrait[Counterparty] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetCounterpartiesFromTransaction(bankId: BankId, accountId: AccountId) extends TopicTrait
|
||||
case class InBoundGetCounterpartiesFromTransaction(status: Status, data: List[Counterparty]) extends InBoundTrait[List[Counterparty]] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetCounterparty(thisBankId: BankId, thisAccountId: AccountId, couterpartyId: String) extends TopicTrait
|
||||
case class InBoundGetCounterparty(status: Status, data: Counterparty) extends InBoundTrait[Counterparty] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetPhysicalCards(user: User) extends TopicTrait
|
||||
case class InBoundGetPhysicalCards(status: Status, data: List[PhysicalCard]) extends InBoundTrait[List[PhysicalCard]] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetPhysicalCardsForBankLegacy(bank: Bank, user: User,
|
||||
limit: Int,
|
||||
offset: Int,
|
||||
fromDate: String,
|
||||
toDate: String) extends TopicTrait
|
||||
case class InBoundGetPhysicalCardsForBankLegacy(status: Status, data: List[PhysicalCard]) extends InBoundTrait[List[PhysicalCard]] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundMakePayment(initiator: User, fromAccountUID: BankIdAccountId, toAccountUID: BankIdAccountId, amt: BigDecimal, description: String, transactionRequestType: TransactionRequestType) extends TopicTrait
|
||||
case class InBoundMakePayment(status: Status, data: TransactionId) extends InBoundTrait[TransactionId] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundMakePaymentv200(fromAccount: BankAccount, toAccount: BankAccount, transactionRequestCommonBody: TransactionRequestCommonBodyJSON, amount: BigDecimal, description: String, transactionRequestType: TransactionRequestType, chargePolicy: String) extends TopicTrait
|
||||
case class InBoundMakePaymentv200(status: Status, data: TransactionId) extends InBoundTrait[TransactionId] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundMakePaymentImpl(fromAccount: BankAccount, toAccount: BankAccount, transactionRequestCommonBody: TransactionRequestCommonBodyJSON, amt: BigDecimal, description: String, transactionRequestType: TransactionRequestType, chargePolicy: String) extends TopicTrait
|
||||
case class InBoundMakePaymentImpl(status: Status, data: TransactionId) extends InBoundTrait[TransactionId] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundCreateTransactionRequest(initiator: User, fromAccount: BankAccount, toAccount: BankAccount, transactionRequestType: TransactionRequestType, body: TransactionRequestBody) extends TopicTrait
|
||||
case class InBoundCreateTransactionRequest(status: Status, data: TransactionRequest) extends InBoundTrait[TransactionRequest] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundCreateTransactionRequestv200(initiator: User, fromAccount: BankAccount, toAccount: BankAccount, transactionRequestType: TransactionRequestType, body: TransactionRequestBody) extends TopicTrait
|
||||
case class InBoundCreateTransactionRequestv200(status: Status, data: TransactionRequest) extends InBoundTrait[TransactionRequest] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetStatus(challengeThresholdAmount: BigDecimal, transactionRequestCommonBodyAmount: BigDecimal, transactionRequestType: TransactionRequestType) extends TopicTrait
|
||||
case class InBoundGetStatus(status: Status, statusValue: String) extends InBoundTrait[TransactionRequestStatus.Value] {
|
||||
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
override val data: TransactionRequestStatus.Value = TransactionRequestStatus.withName(statusValue)
|
||||
}
|
||||
|
||||
case class OutBoundGetChargeValue(chargeLevelAmount: BigDecimal, transactionRequestCommonBodyAmount: BigDecimal) extends TopicTrait
|
||||
case class InBoundGetChargeValue(status: Status, data: String) extends InBoundTrait[String] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundCreateTransactionRequestv400(outboundAdapterCallContext: OutboundAdapterCallContext, initiator: User, viewId: ViewId, fromAccount: BankAccount, toAccount: BankAccount, transactionRequestType: TransactionRequestType, transactionRequestCommonBody: TransactionRequestCommonBodyJSON, detailsPlain: String, chargePolicy: String, challengeType: Option[String], scaMethod: Option[StrongCustomerAuthentication.SCA]) extends TopicTrait
|
||||
case class InBoundCreateTransactionRequestv400(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TransactionRequest) extends InBoundTrait[TransactionRequest]
|
||||
|
||||
case class OutBoundCreateTransactionRequestImpl(transactionRequestId: TransactionRequestId, transactionRequestType: TransactionRequestType, fromAccount: BankAccount, counterparty: BankAccount, body: TransactionRequestBody, status: String, charge: TransactionRequestCharge) extends TopicTrait
|
||||
case class InBoundCreateTransactionRequestImpl(status: Status, data: TransactionRequest) extends InBoundTrait[TransactionRequest] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundCreateTransactionRequestImpl210(transactionRequestId: TransactionRequestId, transactionRequestType: TransactionRequestType, fromAccount: BankAccount, toAccount: BankAccount, transactionRequestCommonBody: TransactionRequestCommonBodyJSON, details: String, status: String, charge: TransactionRequestCharge, chargePolicy: String) extends TopicTrait
|
||||
case class InBoundCreateTransactionRequestImpl210(status: Status, data: TransactionRequest) extends InBoundTrait[TransactionRequest] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundSaveTransactionRequestTransaction(transactionRequestId: TransactionRequestId, transactionId: TransactionId) extends TopicTrait
|
||||
case class InBoundSaveTransactionRequestTransaction(status: Status, data: Boolean) extends InBoundTrait[Boolean] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundSaveTransactionRequestTransactionImpl(transactionRequestId: TransactionRequestId, transactionId: TransactionId) extends TopicTrait
|
||||
case class InBoundSaveTransactionRequestTransactionImpl(status: Status, data: Boolean) extends InBoundTrait[Boolean] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundSaveTransactionRequestChallenge(transactionRequestId: TransactionRequestId, challenge: TransactionRequestChallenge) extends TopicTrait
|
||||
case class InBoundSaveTransactionRequestChallenge(status: Status, data: Boolean) extends InBoundTrait[Boolean] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundSaveTransactionRequestChallengeImpl(transactionRequestId: TransactionRequestId, challenge: TransactionRequestChallenge) extends TopicTrait
|
||||
case class InBoundSaveTransactionRequestChallengeImpl(status: Status, data: Boolean) extends InBoundTrait[Boolean] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundSaveTransactionRequestStatusImpl(transactionRequestId: TransactionRequestId, status: String) extends TopicTrait
|
||||
case class InBoundSaveTransactionRequestStatusImpl(status: Status, data: Boolean) extends InBoundTrait[Boolean] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetTransactionRequests(initiator: User, fromAccount: BankAccount) extends TopicTrait
|
||||
case class InBoundGetTransactionRequests(status: Status, data: List[TransactionRequest]) extends InBoundTrait[List[TransactionRequest]] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetTransactionRequestStatuses() extends TopicTrait
|
||||
case class InBoundGetTransactionRequestStatuses(status: Status, data: TransactionRequestStatusCommons) extends InBoundTrait[TransactionRequestStatusCommons] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetTransactionRequestStatusesImpl() extends TopicTrait
|
||||
case class InBoundGetTransactionRequestStatusesImpl(status: Status, data: TransactionRequestStatusCommons) extends InBoundTrait[TransactionRequestStatusCommons] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetTransactionRequestsImpl(fromAccount: BankAccount) extends TopicTrait
|
||||
case class InBoundGetTransactionRequestsImpl(status: Status, data: List[TransactionRequest]) extends InBoundTrait[List[TransactionRequest]] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetTransactionRequestsImpl210(fromAccount: BankAccount) extends TopicTrait
|
||||
case class InBoundGetTransactionRequestsImpl210(status: Status, data: List[TransactionRequest]) extends InBoundTrait[List[TransactionRequest]] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetTransactionRequestTypes(initiator: User, fromAccount: BankAccount) extends TopicTrait
|
||||
case class InBoundGetTransactionRequestTypes(status: Status, data: List[TransactionRequestType]) extends InBoundTrait[List[TransactionRequestType]] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetTransactionRequestTypesImpl(fromAccount: BankAccount) extends TopicTrait
|
||||
case class InBoundGetTransactionRequestTypesImpl(status: Status, data: List[TransactionRequestType]) extends InBoundTrait[List[TransactionRequestType]] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundCreateTransactionAfterChallenge(initiator: User, transReqId: TransactionRequestId) extends TopicTrait
|
||||
case class InBoundCreateTransactionAfterChallenge(status: Status, data: TransactionRequest) extends InBoundTrait[TransactionRequest] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundCreateTransactionAfterChallengev200(fromAccount: BankAccount, toAccount: BankAccount, transactionRequest: TransactionRequest) extends TopicTrait
|
||||
case class InBoundCreateTransactionAfterChallengev200(status: Status, data: TransactionRequest) extends InBoundTrait[TransactionRequest] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundAddBankAccount(outboundAdapterCallContext: OutboundAdapterCallContext, bankId: BankId, accountType: String, accountLabel: String, currency: String, initialBalance: BigDecimal, accountHolderName: String, branchId: String, accountRoutingScheme: String, accountRoutingAddress: String) extends TopicTrait
|
||||
case class InBoundAddBankAccount(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: BankAccountCommons) extends InBoundTrait[BankAccountCommons]
|
||||
|
||||
case class BankAndBankAccount(bank: BankCommons, account: BankAccountCommons)
|
||||
case class OutBoundCreateBankAndAccount(bankName: String, bankNationalIdentifier: String, accountNumber: String, accountType: String, accountLabel: String, currency: String, accountHolderName: String, branchId: String, accountRoutingScheme: String, accountRoutingAddress: String) extends TopicTrait
|
||||
case class InBoundCreateBankAndAccount(status: Status, value: BankAndBankAccount) extends InBoundTrait[(Bank, BankAccount)] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
override val data: (Bank, BankAccount) = (value.bank, value.account)
|
||||
}
|
||||
|
||||
case class OutBoundCreateSandboxBankAccount(bankId: BankId, accountId: AccountId, accountNumber: String, accountType: String, accountLabel: String, currency: String, initialBalance: BigDecimal, accountHolderName: String, branchId: String, accountRoutingScheme: String, accountRoutingAddress: String) extends TopicTrait
|
||||
case class InBoundCreateSandboxBankAccount(status: Status, data: BankAccountCommons) extends InBoundTrait[BankAccountCommons] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundAccountExists(bankId: BankId, accountNumber: String) extends TopicTrait
|
||||
case class InBoundAccountExists(status: Status, data: Boolean) extends InBoundTrait[Boolean] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundRemoveAccount(bankId: BankId, accountId: AccountId) extends TopicTrait
|
||||
case class InBoundRemoveAccount(status: Status, data: Boolean) extends InBoundTrait[Boolean] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetMatchingTransactionCount(bankNationalIdentifier: String, accountNumber: String, amount: String, completed: Date, otherAccountHolder: String) extends TopicTrait
|
||||
case class InBoundGetMatchingTransactionCount(status: Status, data: Int) extends InBoundTrait[Int] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundUpdateAccountBalance(bankId: BankId, accountId: AccountId, newBalance: BigDecimal) extends TopicTrait
|
||||
case class InBoundUpdateAccountBalance(status: Status, data: Boolean) extends InBoundTrait[Boolean] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundSetBankAccountLastUpdated(bankNationalIdentifier: String, accountNumber: String, updateDate: Date) extends TopicTrait
|
||||
case class InBoundSetBankAccountLastUpdated(status: Status, data: Boolean) extends InBoundTrait[Boolean] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundUpdateAccountLabel(bankId: BankId, accountId: AccountId, label: String) extends TopicTrait
|
||||
case class InBoundUpdateAccountLabel(status: Status, data: Boolean) extends InBoundTrait[Boolean] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundUpdateAccount(bankId: BankId, accountId: AccountId, label: String) extends TopicTrait
|
||||
case class InBoundUpdateAccount(status: Status, data: Boolean) extends InBoundTrait[Boolean] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class GetProductsParam(name: String, value: List[String])
|
||||
|
||||
object GetProductsParam {
|
||||
implicit def mapToParam(params: Map[String,List[String]]) = params.map { pair=>
|
||||
val (key, value) = pair
|
||||
GetProductsParam(key, value)
|
||||
}.toList
|
||||
}
|
||||
|
||||
case class OutBoundGetProducts(bankId: BankId, params: List[GetProductsParam]) extends TopicTrait
|
||||
|
||||
case class InBoundGetProducts(status: Status, data: List[ProductCommons]) extends InBoundTrait[List[ProductCommons]] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetProduct(bankId: BankId, productCode: ProductCode) extends TopicTrait
|
||||
case class InBoundGetProduct(status: Status, data: ProductCommons) extends InBoundTrait[ProductCommons] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
|
||||
case class OutBoundCreateOrUpdateBranch(branch: BranchT) extends TopicTrait
|
||||
case class InBoundCreateOrUpdateBranch(status: Status, data: BranchTCommons) extends InBoundTrait[BranchTCommons] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundCreateOrUpdateBank(bankId: String, fullBankName: String, shortBankName: String, logoURL: String, websiteURL: String, swiftBIC: String, national_identifier: String, bankRoutingScheme: String, bankRoutingAddress: String) extends TopicTrait
|
||||
case class InBoundCreateOrUpdateBank(status: Status, data: BankCommons) extends InBoundTrait[BankCommons] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundCreateOrUpdateAtm(atm: AtmT) extends TopicTrait
|
||||
case class InBoundCreateOrUpdateAtm(status: Status, data: AtmTCommons) extends InBoundTrait[AtmTCommons] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundCreateOrUpdateProduct(bankId: String, code: String, parentProductCode: Option[String], name: String, category: String, family: String, superFamily: String, moreInfoUrl: String, details: String, description: String, metaLicenceId: String, metaLicenceName: String) extends TopicTrait
|
||||
case class InBoundCreateOrUpdateProduct(status: Status, data: ProductCommons) extends InBoundTrait[ProductCommons] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundCreateOrUpdateFXRate(bankId: String, fromCurrencyCode: String, toCurrencyCode: String, conversionValue: Double, inverseConversionValue: Double, effectiveDate: Date) extends TopicTrait
|
||||
case class InBoundCreateOrUpdateFXRate(status: Status, data: FXRateCommons) extends InBoundTrait[FXRateCommons] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetBranchLegacy(bankId: BankId, branchId: BranchId) extends TopicTrait
|
||||
case class InBoundGetBranchLegacy(status: Status, data: BranchTCommons) extends InBoundTrait[BranchTCommons] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetAtmLegacy(bankId: BankId, atmId: AtmId) extends TopicTrait
|
||||
case class InBoundGetAtmLegacy(status: Status, data: AtmTCommons) extends InBoundTrait[AtmTCommons] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundAccountOwnerExists(user: User, bankId: BankId, accountId: AccountId) extends TopicTrait
|
||||
case class InBoundAccountOwnerExists(status: Status, data: Boolean) extends InBoundTrait[Boolean] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetCurrentFxRate(bankId: BankId, fromCurrencyCode: String, toCurrencyCode: String) extends TopicTrait
|
||||
case class InBoundGetCurrentFxRate(status: Status, data: FXRateCommons) extends InBoundTrait[FXRateCommons] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetCurrentFxRateCached(bankId: BankId, fromCurrencyCode: String, toCurrencyCode: String) extends TopicTrait
|
||||
case class InBoundGetCurrentFxRateCached(status: Status, data: FXRateCommons) extends InBoundTrait[FXRateCommons] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetTransactionRequestTypeCharge(bankId: BankId, accountId: AccountId, viewId: ViewId, transactionRequestType: TransactionRequestType) extends TopicTrait
|
||||
case class InBoundGetTransactionRequestTypeCharge(status: Status, data: TransactionRequestTypeChargeCommons) extends InBoundTrait[TransactionRequestTypeChargeCommons] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetTransactionRequestTypeCharges(bankId: BankId, accountId: AccountId, viewId: ViewId, transactionRequestTypes: List[TransactionRequestType]) extends TopicTrait
|
||||
case class InBoundGetTransactionRequestTypeCharges(status: Status, data: List[TransactionRequestTypeChargeCommons]) extends InBoundTrait[List[TransactionRequestTypeChargeCommons]] {
|
||||
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
|
||||
}
|
||||
|
||||
case class OutBoundGetCustomersByCustomerPhoneNumber(outboundAdapterCallContext: OutboundAdapterCallContext, bankId: BankId, phoneNumber: String) extends TopicTrait
|
||||
case class InBoundGetCustomersByCustomerPhoneNumber(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[CustomerCommons]) extends InBoundTrait[List[CustomerCommons]]
|
||||
|
||||
case class OutBoundGetTransactionAttributeById(outboundAdapterCallContext: OutboundAdapterCallContext, transactionAttributeId: String) extends TopicTrait
|
||||
case class InBoundGetTransactionAttributeById(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TransactionAttributeCommons) extends InBoundTrait[TransactionAttributeCommons]
|
||||
|
||||
case class OutBoundCreateOrUpdateCustomerAttribute(outboundAdapterCallContext: OutboundAdapterCallContext, bankId: BankId, customerId: CustomerId, customerAttributeId: Option[String], name: String, attributeType: CustomerAttributeType.Value, value: String) extends TopicTrait
|
||||
case class InBoundCreateOrUpdateCustomerAttribute(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: CustomerAttributeCommons) extends InBoundTrait[CustomerAttributeCommons]
|
||||
|
||||
|
||||
case class OutBoundCreateOrUpdateTransactionAttribute(outboundAdapterCallContext: OutboundAdapterCallContext, bankId: BankId, transactionId: TransactionId, transactionAttributeId: Option[String], name: String, attributeType: TransactionAttributeType.Value, value: String) extends TopicTrait
|
||||
case class InBoundCreateOrUpdateTransactionAttribute(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: TransactionAttributeCommons) extends InBoundTrait[TransactionAttributeCommons]
|
||||
|
||||
case class OutBoundGetCustomerAttributes(outboundAdapterCallContext: OutboundAdapterCallContext, bankId: BankId, customerId: CustomerId) extends TopicTrait
|
||||
case class InBoundGetCustomerAttributes(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[CustomerAttributeCommons]) extends InBoundTrait[List[CustomerAttributeCommons]]
|
||||
|
||||
case class OutBoundGetCustomerIdsByAttributeNameValues(outboundAdapterCallContext: OutboundAdapterCallContext, bankId: BankId, nameValues: Map[String,List[String]]) extends TopicTrait
|
||||
case class InBoundGetCustomerIdsByAttributeNameValues(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[String]) extends InBoundTrait[List[String]]
|
||||
|
||||
case class CustomerAndAttribute(customer: CustomerCommons, attributes: List[CustomerAttributeCommons])
|
||||
case class OutBoundGetCustomerAttributesForCustomers(outboundAdapterCallContext: OutboundAdapterCallContext, customers: List[Customer]) extends TopicTrait
|
||||
case class InBoundGetCustomerAttributesForCustomers(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, value: List[CustomerAndAttribute]) extends InBoundTrait[List[(Customer, List[CustomerAttribute])]] {
|
||||
override val data: List[(Customer, List[CustomerAttribute])] = value.map(it => (it.customer, it.attributes))
|
||||
}
|
||||
|
||||
case class OutBoundGetTransactionIdsByAttributeNameValues(outboundAdapterCallContext: OutboundAdapterCallContext, bankId: BankId, nameValues: Map[String,List[String]]) extends TopicTrait
|
||||
case class InBoundGetTransactionIdsByAttributeNameValues(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[String]) extends InBoundTrait[List[String]]
|
||||
|
||||
case class OutBoundGetTransactionAttributes(outboundAdapterCallContext: OutboundAdapterCallContext, bankId: BankId, transactionId: TransactionId) extends TopicTrait
|
||||
case class InBoundGetTransactionAttributes(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[TransactionAttributeCommons]) extends InBoundTrait[List[TransactionAttributeCommons]]
|
||||
|
||||
case class OutBoundGetCustomerAttributeById(outboundAdapterCallContext: OutboundAdapterCallContext, customerAttributeId: String) extends TopicTrait
|
||||
case class InBoundGetCustomerAttributeById(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: CustomerAttributeCommons) extends InBoundTrait[CustomerAttributeCommons]
|
||||
|
||||
case class OutBoundCreateDirectDebit(outboundAdapterCallContext: OutboundAdapterCallContext, bankId: String, accountId: String, customerId: String, userId: String, counterpartyId: String, dateSigned: Date, dateStarts: Date, dateExpires: Option[Date]) extends TopicTrait
|
||||
case class InBoundCreateDirectDebit(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: DirectDebitTraitCommons) extends InBoundTrait[DirectDebitTraitCommons]
|
||||
|
||||
case class OutBoundDeleteCustomerAttribute(outboundAdapterCallContext: OutboundAdapterCallContext, customerAttributeId: String) extends TopicTrait
|
||||
case class InBoundDeleteCustomerAttribute(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: Boolean) extends InBoundTrait[Boolean]
|
||||
// --------------------- some special connector methods corresponding InBound and OutBound -- end --
|
||||
@ -418,7 +418,67 @@ case class CustomerMessageCommons(
|
||||
) extends CustomerMessage
|
||||
object CustomerMessageCommons extends Converter[CustomerMessage, CustomerMessageCommons]
|
||||
|
||||
case class CustomerAttributeCommons (
|
||||
override val bankId: BankId,
|
||||
override val customerId: CustomerId,
|
||||
override val customerAttributeId: String,
|
||||
override val attributeType: CustomerAttributeType.Value,
|
||||
override val name: String,
|
||||
override val value: String,
|
||||
) extends CustomerAttribute
|
||||
object CustomerAttributeCommons extends Converter[CustomerAttribute, CustomerAttributeCommons]
|
||||
|
||||
case class TransactionAttributeCommons (
|
||||
override val bankId: BankId,
|
||||
override val transactionId: TransactionId,
|
||||
override val transactionAttributeId: String,
|
||||
override val attributeType: TransactionAttributeType.Value,
|
||||
override val name: String,
|
||||
override val value: String,
|
||||
) extends TransactionAttribute
|
||||
object TransactionAttributeCommons extends Converter[TransactionAttribute, TransactionAttributeCommons]
|
||||
|
||||
case class FXRateCommons (
|
||||
override val bankId : BankId,
|
||||
override val fromCurrencyCode: String,
|
||||
override val toCurrencyCode: String,
|
||||
override val conversionValue: Double,
|
||||
override val inverseConversionValue: Double,
|
||||
override val effectiveDate: Date
|
||||
) extends FXRate
|
||||
object FXRateCommons extends Converter[FXRate, FXRateCommons]
|
||||
|
||||
|
||||
case class TransactionRequestTypeChargeCommons (
|
||||
override val transactionRequestTypeId: String,
|
||||
override val bankId: String,
|
||||
override val chargeCurrency: String,
|
||||
override val chargeAmount: String,
|
||||
override val chargeSummary: String
|
||||
) extends TransactionRequestTypeCharge
|
||||
object TransactionRequestTypeChargeCommons extends Converter[TransactionRequestTypeCharge, TransactionRequestTypeChargeCommons]
|
||||
|
||||
case class DirectDebitTraitCommons (
|
||||
override val directDebitId: String,
|
||||
override val bankId: String,
|
||||
override val accountId: String,
|
||||
override val customerId: String,
|
||||
override val userId: String,
|
||||
override val counterpartyId: String,
|
||||
override val dateSigned: Date,
|
||||
override val dateCancelled: Date,
|
||||
override val dateStarts: Date,
|
||||
override val dateExpires: Date,
|
||||
override val active: Boolean
|
||||
) extends DirectDebitTrait
|
||||
object DirectDebitTraitCommons extends Converter[DirectDebitTrait, DirectDebitTraitCommons]
|
||||
|
||||
case class TransactionStatusCommons(
|
||||
override val transactionId : String,
|
||||
override val transactionStatus: String,
|
||||
override val transactionTimestamp: String
|
||||
) extends TransactionStatus
|
||||
object TransactionStatusCommons extends Converter[TransactionStatus, TransactionStatusCommons]
|
||||
|
||||
//----------------obp-api moved to here case classes
|
||||
|
||||
|
||||
@ -404,6 +404,37 @@ trait TransactionAttribute {
|
||||
def value: String
|
||||
}
|
||||
|
||||
trait FXRate {
|
||||
def bankId : BankId
|
||||
def fromCurrencyCode: String
|
||||
def toCurrencyCode: String
|
||||
def conversionValue: Double
|
||||
def inverseConversionValue: Double
|
||||
def effectiveDate: Date
|
||||
}
|
||||
|
||||
trait TransactionRequestTypeCharge {
|
||||
def transactionRequestTypeId: String
|
||||
def bankId: String
|
||||
def chargeCurrency: String
|
||||
def chargeAmount: String
|
||||
def chargeSummary: String
|
||||
}
|
||||
|
||||
trait DirectDebitTrait {
|
||||
def directDebitId: String
|
||||
def bankId: String
|
||||
def accountId: String
|
||||
def customerId: String
|
||||
def userId: String
|
||||
def counterpartyId: String
|
||||
def dateSigned: Date
|
||||
def dateCancelled: Date
|
||||
def dateStarts: Date
|
||||
def dateExpires: Date
|
||||
def active: Boolean
|
||||
}
|
||||
|
||||
//---------------------------------------- trait dependents of case class
|
||||
|
||||
@deprecated("Use Lobby instead which contains detailed fields, not this string","24 July 2017")
|
||||
|
||||
@ -130,4 +130,9 @@ object AttributeCategory extends OBPEnumeration[AttributeCategory]{
|
||||
object Account extends Value
|
||||
object Transaction extends Value
|
||||
object Card extends Value
|
||||
}
|
||||
|
||||
object TransactionRequestStatus extends Enumeration {
|
||||
type TransactionRequestStatus = Value
|
||||
val INITIATED, PENDING, NEXT_CHALLENGE_PENDING, FAILED, COMPLETED, FORWARDED, REJECTED = Value
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
package com.openbankproject.commons.util
|
||||
|
||||
import net.liftweb.json.{Formats, JValue, Serializer, TypeInfo}
|
||||
import net.liftweb.json._
|
||||
|
||||
trait JsonAble {
|
||||
def toJValue: JValue
|
||||
@ -16,4 +16,19 @@ object JsonAbleSerializer extends Serializer[JsonAble] {
|
||||
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = {
|
||||
case JsonAble(jValue) => jValue
|
||||
}
|
||||
}
|
||||
|
||||
object EnumValueSerializer extends Serializer[EnumValue] {
|
||||
private val IntervalClass = classOf[EnumValue]
|
||||
|
||||
override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), EnumValue] = {
|
||||
case (TypeInfo(clazz, _), json) if(IntervalClass.isAssignableFrom(clazz)) => json match {
|
||||
case JString(s) => OBPEnumeration.withName(clazz.asInstanceOf[Class[EnumValue]], s)
|
||||
case x => throw new MappingException(s"Can't convert $x to $clazz")
|
||||
}
|
||||
}
|
||||
|
||||
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = {
|
||||
case x: EnumValue => JString(x.toString())
|
||||
}
|
||||
}
|
||||
@ -16,7 +16,7 @@ import scala.reflect.runtime.{universe => ru}
|
||||
* }
|
||||
* }}}
|
||||
*/
|
||||
trait EnumValue {
|
||||
trait EnumValue{
|
||||
override def toString: String = this.getClass.getSimpleName.replaceFirst("\\$$", "")
|
||||
}
|
||||
|
||||
|
||||
@ -246,8 +246,8 @@ object ReflectUtils {
|
||||
* @param mirror : has the default this.mirror
|
||||
* @return
|
||||
*/
|
||||
def getTypeByName(fullName: String, mirror: ru.Mirror = this.mirror): ru.Type =
|
||||
mirror.staticClass(fullName).asType.toType
|
||||
def getTypeByName(fullName: String, mirror: ru.Mirror = this.mirror): ru.Type =
|
||||
mirror.staticClass(fullName).asType.toType
|
||||
|
||||
/**
|
||||
* Check if the class is existing in the java path or not.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user