mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 17:17:09 +00:00
Endpoint createFx implemented in mapper mode
This commit is contained in:
parent
e84ae84a9e
commit
ecb7d89d93
@ -233,6 +233,10 @@ val dateformat = new java.text.SimpleDateFormat("yyyy-MM-dd")
|
||||
val CreateOrUpdateCounterpartyMetadataError = "OBP-30036: Could not create or update CounterpartyMetadata"
|
||||
val CounterpartyMetadataNotFound = "OBP-30037: CounterpartyMetadata not found. Please specify valid values for BANK_ID, ACCOUNT_ID and COUNTERPARTY_ID. "
|
||||
|
||||
val CreateFxRateError = "OBP-30032: Could not insert the Fx Rate"
|
||||
val UpdateFxRateError = "OBP-30033: Could not update the Fx Rate"
|
||||
val UnknownFxRateError = "OBP-30033: Unknown Fx Rate error"
|
||||
|
||||
|
||||
// Meetings
|
||||
val MeetingsNotSupported = "OBP-30101: Meetings are not supported on this server."
|
||||
|
||||
@ -643,7 +643,7 @@ trait APIMethods220 {
|
||||
UnknownError
|
||||
),
|
||||
Catalogs(notCore, notPSD2, OBWG),
|
||||
Nil,
|
||||
List(apiTagFx),
|
||||
Some(List(canCreateFxRate, canCreateFxRateAtAnyBank))
|
||||
)
|
||||
|
||||
|
||||
@ -214,6 +214,7 @@ object OBPAPI3_0_0 extends OBPRestHelper with APIMethods130 with APIMethods140 w
|
||||
|
||||
// Possible Endpoints from 2.1.0
|
||||
val endpointsOf2_2_0 = Implementations2_2_0.getCurrentFxRate ::
|
||||
Implementations2_2_0.createFx ::
|
||||
Implementations2_2_0.getCounterpartiesForAccount ::
|
||||
Implementations2_2_0.getCounterpartyById ::
|
||||
Implementations2_2_0.getMessageDocs ::
|
||||
|
||||
@ -1114,12 +1114,13 @@ trait Connector extends MdcLoggable{
|
||||
|
||||
|
||||
def createOrUpdateFXRate(
|
||||
bankId : String,
|
||||
fromCurrencyCode: String,
|
||||
toCurrencyCode: String,
|
||||
conversionValue: Double,
|
||||
inverseConversionValue: Double,
|
||||
effectiveDate: Date): Box[FXRate] = Failure(NotImplemented + currentMethodName)
|
||||
bankId: String,
|
||||
fromCurrencyCode: String,
|
||||
toCurrencyCode: String,
|
||||
conversionValue: Double,
|
||||
inverseConversionValue: Double,
|
||||
effectiveDate: Date
|
||||
): Box[FXRate] = Failure(NotImplemented + currentMethodName)
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1470,6 +1470,47 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
fxRateFromTo.orElse(fxRateToFrom)
|
||||
}
|
||||
|
||||
override def createOrUpdateFXRate(
|
||||
bankId: String,
|
||||
fromCurrencyCode: String,
|
||||
toCurrencyCode: String,
|
||||
conversionValue: Double,
|
||||
inverseConversionValue: Double,
|
||||
effectiveDate: Date
|
||||
): Box[FXRate] = {
|
||||
val fxRateFromTo = MappedFXRate.find(
|
||||
By(MappedFXRate.mBankId, bankId),
|
||||
By(MappedFXRate.mFromCurrencyCode, fromCurrencyCode),
|
||||
By(MappedFXRate.mToCurrencyCode, toCurrencyCode)
|
||||
)
|
||||
fxRateFromTo match {
|
||||
case Full(x) =>
|
||||
tryo {
|
||||
x
|
||||
.mBankId(bankId)
|
||||
.mFromCurrencyCode(fromCurrencyCode)
|
||||
.mToCurrencyCode(toCurrencyCode)
|
||||
.mConversionValue(conversionValue)
|
||||
.mInverseConversionValue(inverseConversionValue)
|
||||
.mEffectiveDate(effectiveDate)
|
||||
.saveMe()
|
||||
} ?~! UpdateFxRateError
|
||||
case Empty =>
|
||||
tryo {
|
||||
MappedFXRate.create
|
||||
.mBankId(bankId)
|
||||
.mFromCurrencyCode(fromCurrencyCode)
|
||||
.mToCurrencyCode(toCurrencyCode)
|
||||
.mConversionValue(conversionValue)
|
||||
.mInverseConversionValue(inverseConversionValue)
|
||||
.mEffectiveDate(effectiveDate)
|
||||
.saveMe()
|
||||
} ?~! CreateFxRateError
|
||||
case _ =>
|
||||
Failure("UnknownFxRateError")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the TransactionRequestTypeCharge from the TransactionRequestTypeCharge table
|
||||
* In Mapped, we will ignore accountId, viewId for now.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user