Merge pull request #2520 from hongwei1/develop

feature/added getRegulatedEntities and getRegulatedEntityByEntityId
This commit is contained in:
Simon Redfern 2025-04-04 16:30:10 +02:00 committed by GitHub
commit 7430f40ca8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 144 additions and 22 deletions

View File

@ -8,6 +8,10 @@ import code.model.{AppType, Consumer}
import code.regulatedentities.MappedRegulatedEntityProvider
import com.openbankproject.commons.model.RegulatedEntityTrait
import net.liftweb.common.Box
import code.bankconnectors.Connector
import code.api.util.ErrorMessages.{InvalidConnectorResponse}
import code.api.util.{APIUtil, CallContext}
import com.github.dwickern.macros.NameOf.nameOf
import scala.concurrent.Future
@ -48,22 +52,19 @@ object RegulatedEntityNewStyle {
}
}
def getRegulatedEntitiesNewStyle(callContext: Option[CallContext]): OBPReturnType[List[RegulatedEntityTrait]] = {
Future {
MappedRegulatedEntityProvider.getRegulatedEntities()
} map {
(_, callContext)
def getRegulatedEntitiesNewStyle(
callContext: Option[CallContext]
): OBPReturnType[List[RegulatedEntityTrait]] = {
Connector.connector.vend.getRegulatedEntities(callContext: Option[CallContext]) map { i =>
(unboxFullOrFail(i._1, callContext,s"$InvalidConnectorResponse ${nameOf(Connector.connector.vend.getRegulatedEntities _)} ", 400 ), i._2)
}
}
def getRegulatedEntityByEntityIdNewStyle(id: String,
callContext: Option[CallContext]
): OBPReturnType[RegulatedEntityTrait] = {
Future {
MappedRegulatedEntityProvider.getRegulatedEntityByEntityId(id)
} map {
(_, callContext)
} map {
x => (unboxFullOrFail(x._1, callContext, RegulatedEntityNotFound, 404), x._2)
def getRegulatedEntityByEntityIdNewStyle(
id: String,
callContext: Option[CallContext]
): OBPReturnType[RegulatedEntityTrait] = {
Connector.connector.vend.getRegulatedEntityByEntityId(id, callContext: Option[CallContext]) map { i =>
(unboxFullOrFail(i._1, callContext,s"$InvalidConnectorResponse ${nameOf(Connector.connector.vend.getRegulatedEntityByEntityId _)} ", 400 ), i._2)
}
}
def deleteRegulatedEntityNewStyle(id: String,

View File

@ -174,7 +174,7 @@ trait APIMethods510 {
"""Get Regulated Entity By REGULATED_ENTITY_ID
""",
EmptyBody,
regulatedEntitiesJsonV510,
regulatedEntityJsonV510,
List(UnknownError),
apiTagDirectory :: apiTagApi :: Nil)

View File

@ -1885,5 +1885,12 @@ trait Connector extends MdcLoggable {
callContext: Option[CallContext]
): OBPReturnType[Box[Boolean]] = Future{(Failure(setUnimplementedError(nameOf(deleteCounterpartyLimit _))), callContext)}
def getRegulatedEntities(
callContext: Option[CallContext]
): OBPReturnType[Box[List[RegulatedEntityTrait]]] = Future{(Failure(setUnimplementedError(nameOf(getRegulatedEntities _))), callContext)}
def getRegulatedEntityByEntityId(
regulatedEntityId: String,
callContext: Option[CallContext]
): OBPReturnType[Box[RegulatedEntityTrait]] = Future{(Failure(setUnimplementedError(nameOf(getRegulatedEntityByEntityId _))), callContext)}
}

View File

@ -49,6 +49,7 @@ import code.productcollection.ProductCollectionX
import code.productcollectionitem.ProductCollectionItems
import code.productfee.ProductFeeX
import code.products.MappedProduct
import code.regulatedentities.MappedRegulatedEntityProvider
import code.standingorders.StandingOrders
import com.openbankproject.commons.model.StandingOrderTrait
import code.taxresidence.TaxResidenceX
@ -5345,5 +5346,22 @@ object LocalMappedConnector extends Connector with MdcLoggable {
counterpartyId: String) map {
(_, callContext)
}
override def getRegulatedEntities(
callContext: Option[CallContext]
): OBPReturnType[Box[List[RegulatedEntityTrait]]] = Future {
tryo {MappedRegulatedEntityProvider.getRegulatedEntities()}
} map {
(_, callContext)
}
override def getRegulatedEntityByEntityId(
regulatedEntityId: String,
callContext: Option[CallContext]
): OBPReturnType[Box[RegulatedEntityTrait]] = Future {
MappedRegulatedEntityProvider.getRegulatedEntityByEntityId(regulatedEntityId)
} map {
(_, callContext)
}
}

View File

@ -435,6 +435,8 @@ object ConnectorBuilderUtil {
"getTransactionRequestTypeCharges",
"getAccountsHeld",
"getAccountsHeldByUser",
"getRegulatedEntities",
"getRegulatedEntityByEntityId",
).distinct
/**

View File

@ -60,17 +60,15 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
// If we want to add a new message format, create a new file e.g. March2017_messages.scala
// Then add a suffix to the connector value i.e. instead of RabbitMq we might have rest_vMar2019.
// Then in this file, populate the different case classes depending on the connector name and send to CBS
val messageFormat: String = "Oct2024"
val messageFormat: String = "rabbitmq_vOct2024"
override val messageDocs = ArrayBuffer[MessageDoc]()
val authInfoExample = AuthInfo(userId = "userId", username = "username", cbsToken = "cbsToken")
val errorCodeExample = "INTERNAL-OBP-ADAPTER-6001: ..."
val connectorName = "rabbitmq_vOct2024"
//---------------- dynamic start -------------------please don't modify this line
// ---------- created on 2025-01-14T19:52:36Z
// ---------- created on 2025-04-04T14:01:22Z
messageDocs += getAdapterInfoDoc
def getAdapterInfoDoc = MessageDoc(
@ -7070,8 +7068,81 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
response.map(convertToTuple[Boolean](callContext))
}
// ---------- created on 2025-01-14T19:52:36Z
//---------------- dynamic end ---------------------please don't modify this line
messageDocs += getRegulatedEntitiesDoc
def getRegulatedEntitiesDoc = MessageDoc(
process = "obp.getRegulatedEntities",
messageFormat = messageFormat,
description = "Get Regulated Entities",
outboundTopic = None,
inboundTopic = None,
exampleOutboundMessage = (
OutBoundGetRegulatedEntities(MessageDocsSwaggerDefinitions.outboundAdapterCallContext)
),
exampleInboundMessage = (
InBoundGetRegulatedEntities(inboundAdapterCallContext=MessageDocsSwaggerDefinitions.inboundAdapterCallContext,
status=MessageDocsSwaggerDefinitions.inboundStatus,
data=List( RegulatedEntityTraitCommons(entityId="string",
certificateAuthorityCaOwnerId="string",
entityName="string",
entityCode="string",
entityCertificatePublicKey="string",
entityType="string",
entityAddress="string",
entityTownCity="string",
entityPostCode="string",
entityCountry="string",
entityWebSite="string",
services="string")))
),
adapterImplementation = Some(AdapterImplementation("- Core", 1))
)
override def getRegulatedEntities(callContext: Option[CallContext]): OBPReturnType[Box[List[RegulatedEntityTrait]]] = {
import com.openbankproject.commons.dto.{InBoundGetRegulatedEntities => InBound, OutBoundGetRegulatedEntities => OutBound}
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull)
val response: Future[Box[InBound]] = sendRequest[InBound]("obp_get_regulated_entities", req, callContext)
response.map(convertToTuple[List[RegulatedEntityTraitCommons]](callContext))
}
messageDocs += getRegulatedEntityByEntityIdDoc
def getRegulatedEntityByEntityIdDoc = MessageDoc(
process = "obp.getRegulatedEntityByEntityId",
messageFormat = messageFormat,
description = "Get Regulated Entity By Entity Id",
outboundTopic = None,
inboundTopic = None,
exampleOutboundMessage = (
OutBoundGetRegulatedEntityByEntityId(outboundAdapterCallContext=MessageDocsSwaggerDefinitions.outboundAdapterCallContext,
regulatedEntityId="string")
),
exampleInboundMessage = (
InBoundGetRegulatedEntityByEntityId(inboundAdapterCallContext=MessageDocsSwaggerDefinitions.inboundAdapterCallContext,
status=MessageDocsSwaggerDefinitions.inboundStatus,
data= RegulatedEntityTraitCommons(entityId="string",
certificateAuthorityCaOwnerId="string",
entityName="string",
entityCode="string",
entityCertificatePublicKey="string",
entityType="string",
entityAddress="string",
entityTownCity="string",
entityPostCode="string",
entityCountry="string",
entityWebSite="string",
services="string"))
),
adapterImplementation = Some(AdapterImplementation("- Core", 1))
)
override def getRegulatedEntityByEntityId(regulatedEntityId: String, callContext: Option[CallContext]): OBPReturnType[Box[RegulatedEntityTrait]] = {
import com.openbankproject.commons.dto.{InBoundGetRegulatedEntityByEntityId => InBound, OutBoundGetRegulatedEntityByEntityId => OutBound}
val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, regulatedEntityId)
val response: Future[Box[InBound]] = sendRequest[InBound]("obp_get_regulated_entity_by_entity_id", req, callContext)
response.map(convertToTuple[RegulatedEntityTraitCommons](callContext))
}
// ---------- created on 2025-04-04T14:01:22Z
//---------------- dynamic end ---------------------please don't modify this line
private val availableOperation = DynamicEntityOperation.values.map(it => s""""$it"""").mkString("[", ", ", "]")

View File

@ -43,6 +43,14 @@ trait InBoundTrait[T] {
//--------generated
case class OutBoundGetRegulatedEntities (outboundAdapterCallContext: OutboundAdapterCallContext) extends TopicTrait
case class InBoundGetRegulatedEntities (inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[RegulatedEntityTraitCommons]) extends InBoundTrait[List[RegulatedEntityTraitCommons]]
case class OutBoundGetRegulatedEntityByEntityId (outboundAdapterCallContext: OutboundAdapterCallContext,
regulatedEntityId: String) extends TopicTrait
case class InBoundGetRegulatedEntityByEntityId (inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: RegulatedEntityTraitCommons) extends InBoundTrait[RegulatedEntityTraitCommons]
case class OutBoundGetObpConnectorLoopback(outboundAdapterCallContext: OutboundAdapterCallContext) extends TopicTrait
case class InBoundGetObpConnectorLoopback(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: ObpApiLoopback) extends InBoundTrait[ObpApiLoopback]

View File

@ -890,6 +890,21 @@ case class TransactionRequestTransferToAtm(
to: ToAccountTransferToAtm
) extends TransactionRequestCommonBodyJSON
case class RegulatedEntityTraitCommons(
entityId :String,
certificateAuthorityCaOwnerId :String,
entityName :String,
entityCode :String,
entityCertificatePublicKey :String,
entityType :String,
entityAddress :String,
entityTownCity :String,
entityPostCode :String,
entityCountry :String,
entityWebSite :String,
services :String) extends RegulatedEntityTrait
object RegulatedEntityTraitCommons extends Converter[RegulatedEntityTrait, RegulatedEntityTraitCommons]
//For COUNTERPARTY, it needs the counterparty_id to find the toCounterparty--> toBankAccount
case class TransactionRequestCounterpartyId (counterparty_id : String)