fix some RestConnectorBuilder errors, but not finished

This commit is contained in:
shuang 2019-08-26 16:00:47 +08:00
parent 7db5a6d317
commit c837a4a8a7
8 changed files with 88 additions and 62 deletions

View File

@ -26,7 +26,6 @@
<dependency>
<groupId>com.tesobe</groupId>
<artifactId>obp-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.github.everit-org.json-schema</groupId>

View File

@ -170,7 +170,7 @@ object CodeGenerateUtils {
} else if (pre <:< ru.typeOf[AccountAttributeType.type]) {
"AccountAttributeType.INTEGER"
} else if (valName == "scaMethod") {
"code.api.util.StrongCustomerAuthentication.SMS"
"Some(code.api.util.StrongCustomerAuthentication.SMS)"
} else {
createDocExample(symbol.info, Some(valName), fieldName, Some(tp))
}

View File

@ -1658,7 +1658,7 @@ trait Connector extends MdcLoggable with CustomJsonFormats{
productCode: ProductCode,
productAttributeId: Option[String],
name: String,
attributType: ProductAttributeType.Value,
productAttributeType: ProductAttributeType.Value,
value: String,
callContext: Option[CallContext]
): OBPReturnType[Box[ProductAttribute]] = Future{(Failure(setUnimplementedError), callContext)}
@ -1689,7 +1689,7 @@ trait Connector extends MdcLoggable with CustomJsonFormats{
productCode: ProductCode,
productAttributeId: Option[String],
name: String,
attributType: AccountAttributeType.Value,
accountAttributeType: AccountAttributeType.Value,
value: String,
callContext: Option[CallContext]
): OBPReturnType[Box[AccountAttribute]] = Future{(Failure(setUnimplementedError), callContext)}
@ -1711,7 +1711,7 @@ trait Connector extends MdcLoggable with CustomJsonFormats{
cardId: Option[String],
cardAttributeId: Option[String],
name: String,
attributeType: CardAttributeType.Value,
cardAttributeType: CardAttributeType.Value,
value: String,
callContext: Option[CallContext]
): OBPReturnType[Box[CardAttribute]] = Future{(Failure(setUnimplementedError), callContext)}

View File

@ -31,49 +31,49 @@ object RestConnectorBuilder extends App {
"getChallengeThreshold",
"getChargeLevel",
"createChallenge",
// "validateChallengeAnswer",
// "getBankLegacy",
// "validateChallengeAnswer",
// "getBankLegacy",
"getBank",
// "getBanksLegacy",
// "getBanksLegacy",
"getBanks",
// "getBankAccountsForUserLegacy",
// "getBankAccountsForUserLegacy",
"getBankAccountsForUser",
"getUser",
// "updateUserAccountViewsOld",
// "updateUserAccountViewsOld",
"getBankAccount",
// "getBankAccountLegacy",
// "getBankAccountLegacy",
"getBankAccount",
// "getBankAccountByIban", *********
// "getBankAccountByRouting",
// "getBankAccounts",
// "getBankAccountByIban", *********
// "getBankAccountByRouting",
// "getBankAccounts",
"getBankAccountsBalances",
// "getCoreBankAccountsLegacy",
// "getCoreBankAccountsLegacy",
"getCoreBankAccounts",
// "getBankAccountsHeldLegacy",
// "getBankAccountsHeldLegacy",
"getBankAccountsHeld",
// "checkBankAccountExistsLegacy",
// "checkBankAccountExistsLegacy",
"checkBankAccountExists",
// "getEmptyBankAccount", //not useful!
// "getCounterpartyFromTransaction", //not useful!
// "getCounterpartiesFromTransaction",//not useful!
// "getEmptyBankAccount", //not useful!
// "getCounterpartyFromTransaction", //not useful!
// "getCounterpartiesFromTransaction",//not useful!
"getCounterparty",
"getCounterpartyTrait",
// "getCounterpartyByCounterpartyIdLegacy",
// "getCounterpartyByCounterpartyIdLegacy",
"getCounterpartyByCounterpartyId",
"getCounterpartyByIban",
// "getCounterpartiesLegacy",
// "getCounterpartiesLegacy",
"getCounterparties",
// "getTransactionsLegacy",
// "getTransactionsLegacy",
"getTransactions",
"getTransactionsCore",
// "getTransactionLegacy",
// "getTransactionLegacy",
"getTransaction",
"getPhysicalCards",
"getPhysicalCardForBank",
"deletePhysicalCardForBank",
// "getPhysicalCardsForBankLegacy",
// "getPhysicalCardsForBankLegacy",
"getPhysicalCardsForBank",
// "createPhysicalCardLegacy",
// "createPhysicalCardLegacy",
"createPhysicalCard",
"updatePhysicalCard",
"makePayment",
@ -108,7 +108,7 @@ object RestConnectorBuilder extends App {
"updateBankAccount",
"createBankAndAccount",
"createBankAccount",
// "createBankAccountLegacy",
// "createBankAccountLegacy",
"createSandboxBankAccount",
"setAccountHolder",
"accountExists",
@ -126,10 +126,10 @@ object RestConnectorBuilder extends App {
"createOrUpdateAtm",
"createOrUpdateProduct",
"createOrUpdateFXRate",
// "getBranchLegacy",
// "getBranchLegacy",
"getBranch",
"getBranches",
// "getAtmLegacy",
// "getAtmLegacy",
"getAtm",
"getAtms",
"accountOwnerExists",
@ -149,7 +149,7 @@ object RestConnectorBuilder extends App {
"updateCustomerCreditData",
"updateCustomerGeneralData",
"getCustomersByUserId",
// "getCustomerByCustomerIdLegacy",
// "getCustomerByCustomerIdLegacy",
"getCustomerByCustomerId",
"getCustomerByCustomerNumber",
"getCustomerAddress",
@ -212,7 +212,7 @@ object RestConnectorBuilder extends App {
// "getKycMedias",
// "getKycStatuses",
// "createBankAccount",
// "createCustomer",
// "createCustomer",
// "createMeeting",
// "createMessage"
)
@ -229,8 +229,8 @@ object RestConnectorBuilder extends App {
.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 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")
}
@ -269,6 +269,9 @@ case class GetGenerator(methodName: String, tp: Type) {
.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)
@ -383,6 +386,9 @@ 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`")
@ -427,6 +433,7 @@ case class PostGenerator(methodName: String, tp: Type) {
case v if(v.matches("(delete|remove).+")) => "HttpMethods.DELETE"
case _ => "HttpMethods.POST"
}
/**
* Get all the parameters name as a String from `typeSignature` object.
* eg: it will return

View File

@ -170,7 +170,6 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable
//---------------- dynamic start -------------------please don't modify this line
//---------------- dynamic end ---------------------please don't modify this line
@ -178,7 +177,10 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable
//In RestConnector, we use the headers to propagate the parameters to Adapter. The parameters come from the CallContext.outboundAdapterAuthInfo.userAuthContext
//We can set them from UserOauthContext or the http request headers.
@ -196,7 +198,7 @@ trait RestConnector_vMar2019 extends Connector with KafkaHelper with MdcLoggable
* @tparam T
* @return
*/
private[this] implicit def convertFuture[T](future: Future[T]): T = Await.result(future, 1.minute)
//private[this] implicit def convertFuture[T](future: Future[T]): T = Await.result(future, 1.minute)
//TODO please modify this baseUrl to your remote api server base url of this connector
private[this] val baseUrl = "http://localhost:8080/restConnector"

View File

@ -329,7 +329,7 @@ case class OutBoundCreateOrUpdateProductAttribute(outboundAdapterCallContext: Ou
productCode: ProductCode,
productAttributeId: Option[String],
name: String,
attributType: ProductAttributeType.Value,
productAttributeType: ProductAttributeType.Value,
value: String) extends TopicTrait
case class InBoundCreateOrUpdateProductAttribute(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: ProductAttributeCommons) extends InBoundTrait[ProductAttributeCommons]
@ -351,7 +351,7 @@ case class OutBoundCreateOrUpdateAccountAttribute(outboundAdapterCallContext: Ou
productCode: ProductCode,
productAttributeId: Option[String],
name: String,
attributType: AccountAttributeType.Value,
accountAttributeType: AccountAttributeType.Value,
value: String) extends TopicTrait
case class InBoundCreateOrUpdateAccountAttribute(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: AccountAttributeCommons) extends InBoundTrait[AccountAttributeCommons]
@ -403,7 +403,7 @@ case class InBoundGetProductCollectionItem(inboundAdapterCallContext: InboundAda
case class OutBoundGetProductCollectionItemsTree(outboundAdapterCallContext: OutboundAdapterCallContext,
collectionCode: String,
bankId: String) extends TopicTrait
case class InBoundGetProductCollectionItemsTree(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[(ProductCollectionItemCommons, ProductCommons, List[ProductAttributeCommons])])
case class InBoundGetProductCollectionItemsTree(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[(ProductCollectionItemCommons, ProductCommons, List[ProductAttributeCommons])])extends InBoundTrait[List[(ProductCollectionItemCommons, ProductCommons, List[ProductAttributeCommons])]]
case class OutBoundCreateMeeting(outboundAdapterCallContext: OutboundAdapterCallContext,
@ -439,7 +439,13 @@ case class InBoundGetUser(inboundAdapterCallContext: InboundAdapterCallContext,
//create bound case classes
case class OutBoundCreateChallenge(outboundAdapterCallContext: OutboundAdapterCallContext, bankId: BankId, accountId: AccountId, userId: String, transactionRequestType: TransactionRequestType, transactionRequestId: String, scaMethod: Option[Any]) extends TopicTrait
case class OutBoundCreateChallenge(outboundAdapterCallContext: OutboundAdapterCallContext,
bankId: BankId,
accountId: AccountId,
userId: String,
transactionRequestType: TransactionRequestType,
transactionRequestId: String,
scaMethod: Option[Any]) extends TopicTrait
case class InBoundCreateChallenge(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: String) extends InBoundTrait[String]
@ -533,7 +539,7 @@ case class OutBoundCreateOrUpdateCardAttribute(outboundAdapterCallContext: Outbo
cardId: Option[String],
cardAttributeId: Option[String],
name: String,
attributeType: CardAttributeType.Value,
cardAttributeType: CardAttributeType.Value,
value: String
) extends TopicTrait
case class InBoundCreateOrUpdateCardAttribute(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: CardAttributeCommons) extends InBoundTrait[CardAttributeCommons]
@ -668,29 +674,36 @@ case class InBoundGetPhysicalCardForBank(inboundAdapterCallContext: InboundAdapt
case class OutBoundGetPhysicalCardsForBank(outboundAdapterCallContext: OutboundAdapterCallContext,
bank: Bank,
user: User) extends TopicTrait
user: User,
limit: Int,
offset: Int,
fromDate: String,
toDate: String) extends TopicTrait
case class InBoundGetPhysicalCardsForBank(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[PhysicalCard]) extends InBoundTrait[List[PhysicalCard]]
//bankCardNumber, nameOnCard, cardType, issueNumber, serialNumber, validFrom, expires, enabled, cancelled, onHotList, technology, networks, allows, accountId, bankId, replacement, pinResets, collected, posted, customerId
case class OutBoundCreatePhysicalCard(outboundAdapterCallContext: OutboundAdapterCallContext,
bankCardNumber: String,
nameOnCard: String,
issueNumber: String,
serialNumber: String,
validFrom: Date,
expires: Date,
enabled: Boolean,
cancelled: Boolean,
onHotList: Boolean,
technology: String,
networks: List[String],
allows: List[String],
accountId: String,
bankId: String,
replacement: Option[CardReplacementInfo],
pinResets: List[PinResetInfo],
collected: Option[CardCollectionInfo],
posted: Option[CardPostedInfo]) extends TopicTrait
bankCardNumber: String,
nameOnCard: String,
cardType: String,
issueNumber: String,
serialNumber: String,
validFrom: Date,
expires: Date,
enabled: Boolean,
cancelled: Boolean,
onHotList: Boolean,
technology: String,
networks: List[String],
allows: List[String],
accountId: String,
bankId: String,
replacement: Option[CardReplacementInfo],
pinResets: List[PinResetInfo],
collected: Option[CardCollectionInfo],
posted: Option[CardPostedInfo],
customerId: String
) extends TopicTrait
case class InBoundCreatePhysicalCard(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: PhysicalCard) extends InBoundTrait[PhysicalCard]

View File

@ -306,7 +306,7 @@ object ReflectUtils {
tp.typeSymbol.isClass && !tp.typeSymbol.asClass.isTrait match {
case false => Map.empty[String, ru.Type]
case true => {
ReflectUtils.getPrimaryConstructor(tp)
getPrimaryConstructor(tp)
.paramLists
.headOption
.getOrElse(Nil)

View File

@ -71,6 +71,11 @@
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.tesobe</groupId>
<artifactId>obp-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.liftweb</groupId>
<artifactId>lift-common_${scala.version}</artifactId>