diff --git a/obp-api/src/main/scala/code/api/util/APIUtil.scala b/obp-api/src/main/scala/code/api/util/APIUtil.scala index 9d940699c..abc4b558e 100644 --- a/obp-api/src/main/scala/code/api/util/APIUtil.scala +++ b/obp-api/src/main/scala/code/api/util/APIUtil.scala @@ -2621,9 +2621,23 @@ Returns a string showed to the developer else first+ "***" + "***" + second } - + + /** + * This endpoint returns BIC on an bank according to next rules: + * 1st try - Inspect bank routing + * 2nd ry - get deprecated field "swiftBic" + * @param bankId The BANK_ID specified at an endpoint's path + * @return BIC of the Bank + */ def getBicFromBankId(bankId: String)= { - Connector.connector.vend.getBankLegacy(BankId(bankId), None).map(_._1.swiftBic).getOrElse("") + Connector.connector.vend.getBankLegacy(BankId(bankId), None) match { + case Full((bank, _)) => + bank.bankRoutingScheme match { + case "BIC" => bank.bankRoutingAddress + case _ => bank.swiftBic + } + case _ => "" + } } /** diff --git a/obp-api/src/main/scala/code/api/util/ErrorMessages.scala b/obp-api/src/main/scala/code/api/util/ErrorMessages.scala index 6407b9e1b..b153ed736 100644 --- a/obp-api/src/main/scala/code/api/util/ErrorMessages.scala +++ b/obp-api/src/main/scala/code/api/util/ErrorMessages.scala @@ -308,6 +308,7 @@ object ErrorMessages { val ConsentAllowedScaMethods = "OBP-35009: Only SMS and EMAIL are supported as SCA methods. " val SmsServerNotResponding = "OBP-35010: SMS server is not working or SMS server can not send the message to the phone number: " val AuthorizationNotFound = "OBP-35011: Resource identification of the related Consent authorisation sub-resource not found by AUTHORIZATION_ID. " + val ConsentAlreadyRevoked = "OBP-35012: Consent is already revoked. " //Authorisations val AuthorisationNotFound = "OBP-36001: Authorisation not found. Please specify valid values for PAYMENT_ID and AUTHORISATION_ID. " diff --git a/obp-api/src/main/scala/code/consent/MappedConsent.scala b/obp-api/src/main/scala/code/consent/MappedConsent.scala index 2dfddf84e..f43cb6c15 100644 --- a/obp-api/src/main/scala/code/consent/MappedConsent.scala +++ b/obp-api/src/main/scala/code/consent/MappedConsent.scala @@ -88,6 +88,8 @@ object MappedConsentProvider extends ConsentProvider { } override def revoke(consentId: String): Box[MappedConsent] = { MappedConsent.find(By(MappedConsent.mConsentId, consentId)) match { + case Full(consent) if consent.status == ConsentStatus.REVOKED.toString => + Failure(ErrorMessages.ConsentAlreadyRevoked) case Full(consent) => tryo(consent .mStatus(ConsentStatus.REVOKED.toString)