mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 17:56:46 +00:00
feature/Finish API Validate and check IBAN number
This commit is contained in:
parent
7c30d1993a
commit
10620cef2d
@ -16,7 +16,7 @@ import code.api.v3_0_0.JSONFactory300.createBranchJsonV300
|
||||
import code.api.v3_0_0.custom.JSONFactoryCustom300
|
||||
import code.api.v3_0_0.{LobbyJsonV330, _}
|
||||
import code.api.v3_1_0.{AccountBalanceV310, AccountsBalancesV310Json, BadLoginStatusJson, ContactDetailsJson, CustomerWithAttributesJsonV310, InviteeJson, ObpApiLoopbackJson, PhysicalCardWithAttributesJsonV310, PutUpdateCustomerEmailJsonV310, _}
|
||||
import code.api.v4_0_0.{APIInfoJson400, AccountBalanceJsonV400, AccountTagJSON, AccountTagsJSON, AccountsBalancesJsonV400, AttributeDefinitionJsonV400, AttributeDefinitionResponseJsonV400, AttributeDefinitionsResponseJsonV400, BalanceJsonV400, BankAccountRoutingJson, BankJson400, BanksJson400, ChallengeAnswerJson400, ChallengeJsonV400, CounterpartiesJson400, CounterpartyJson400, CounterpartyWithMetadataJson400, CustomerAttributeJsonV400, CustomerAttributesResponseJson, DirectDebitJsonV400, EnergySource400, HostedAt400, HostedBy400, JsonSchemaV400, JsonValidationV400, LogoutLinkJson, ModeratedAccountJSON400, ModeratedCoreAccountJsonV400, ModeratedFirehoseAccountJsonV400, ModeratedFirehoseAccountsJsonV400, PostAccountAccessJsonV400, PostAccountTagJSON, PostCounterpartyJson400, PostCustomerPhoneNumberJsonV400, PostDirectDebitJsonV400, PostRevokeGrantAccountAccessJsonV400, PostStandingOrderJsonV400, PostViewJsonV400, Properties, RefundJson, RevokedJsonV400, SettlementAccountJson, SettlementAccountRequestJson, SettlementAccountResponseJson, SettlementAccountsJson, StandingOrderJsonV400, TransactionAttributeJsonV400, TransactionAttributeResponseJson, TransactionAttributesResponseJson, TransactionRequestAttributeJsonV400, TransactionRequestAttributeResponseJson, TransactionRequestAttributesResponseJson, TransactionRequestBodyRefundJsonV400, TransactionRequestBodySEPAJsonV400, TransactionRequestReasonJsonV400, TransactionRequestRefundFrom, TransactionRequestRefundTo, TransactionRequestWithChargeJSON400, UpdateAccountJsonV400, UserLockStatusJson, When, XxxId}
|
||||
import code.api.v4_0_0.{APIInfoJson400, AccountBalanceJsonV400, AccountTagJSON, AccountTagsJSON, AccountsBalancesJsonV400, AttributeDefinitionJsonV400, AttributeDefinitionResponseJsonV400, AttributeDefinitionsResponseJsonV400, AttributeJsonV400, BalanceJsonV400, BankAccountRoutingJson, BankJson400, BanksJson400, ChallengeAnswerJson400, ChallengeJsonV400, CounterpartiesJson400, CounterpartyJson400, CounterpartyWithMetadataJson400, CustomerAttributeJsonV400, CustomerAttributesResponseJson, DirectDebitJsonV400, EnergySource400, HostedAt400, HostedBy400, IbanCheckerJsonV400, IbanDetailsJsonV400, JsonSchemaV400, JsonValidationV400, LogoutLinkJson, ModeratedAccountJSON400, ModeratedCoreAccountJsonV400, ModeratedFirehoseAccountJsonV400, ModeratedFirehoseAccountsJsonV400, PostAccountAccessJsonV400, PostAccountTagJSON, PostCounterpartyJson400, PostCustomerPhoneNumberJsonV400, PostDirectDebitJsonV400, PostRevokeGrantAccountAccessJsonV400, PostStandingOrderJsonV400, PostViewJsonV400, Properties, RefundJson, RevokedJsonV400, SettlementAccountJson, SettlementAccountRequestJson, SettlementAccountResponseJson, SettlementAccountsJson, StandingOrderJsonV400, TransactionAttributeJsonV400, TransactionAttributeResponseJson, TransactionAttributesResponseJson, TransactionRequestAttributeJsonV400, TransactionRequestAttributeResponseJson, TransactionRequestAttributesResponseJson, TransactionRequestBodyRefundJsonV400, TransactionRequestBodySEPAJsonV400, TransactionRequestReasonJsonV400, TransactionRequestRefundFrom, TransactionRequestRefundTo, TransactionRequestWithChargeJSON400, UpdateAccountJsonV400, UserLockStatusJson, When, XxxId}
|
||||
import code.api.v3_1_0.{AccountBalanceV310, AccountsBalancesV310Json, BadLoginStatusJson, ContactDetailsJson, InviteeJson, ObpApiLoopbackJson, PhysicalCardWithAttributesJsonV310, PutUpdateCustomerEmailJsonV310, _}
|
||||
import code.branches.Branches.{Branch, DriveUpString, LobbyString}
|
||||
import code.consent.ConsentStatus
|
||||
@ -833,13 +833,13 @@ object SwaggerDefinitionsJSON {
|
||||
banks = List(bankJson400)
|
||||
)
|
||||
|
||||
val ibanCheckerPostJsonV400 = Iban("DE75512108001245126199")
|
||||
val ibanCheckerPostJsonV400 = IbanAddress("DE75512108001245126199")
|
||||
|
||||
val ibanCheckerJsonV400 = IbanChecker(
|
||||
val ibanCheckerJsonV400 = IbanCheckerJsonV400(
|
||||
true,
|
||||
Some(
|
||||
IbanDetails(
|
||||
bic = "SOGEDEFF",
|
||||
IbanDetailsJsonV400(
|
||||
bank_routings = List(BankRoutingJsonV121("bic", "SOGEDEFF")) ,
|
||||
bank = "Societe Generale",
|
||||
branch = "",
|
||||
address = "Neue mainzer strasse 46-50",
|
||||
@ -847,12 +847,14 @@ object SwaggerDefinitionsJSON {
|
||||
zip = "60311",
|
||||
phone = "",
|
||||
country = "Germany",
|
||||
countryIso = "",
|
||||
sepaCreditTransfer = "YES",
|
||||
sepaDirectDebit = "YES",
|
||||
sepaSddCore = "YES",
|
||||
sepaB2b = "YES",
|
||||
sepaCardClearing = "YES"
|
||||
attributes = List(
|
||||
AttributeJsonV400("country_iso", ""),
|
||||
AttributeJsonV400("sepa_credit_transfer", "YES"),
|
||||
AttributeJsonV400("sepa_direct_debit", "YES"),
|
||||
AttributeJsonV400("sepa_sdd_core", "YES"),
|
||||
AttributeJsonV400("sepa_b2b", "YES"),
|
||||
AttributeJsonV400("sepa_card_clearing", "YES"),
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@ -182,7 +182,7 @@ trait APIMethods400 {
|
||||
implementedInApiVersion,
|
||||
nameOf(ibanChecker),
|
||||
"POST",
|
||||
"/iban-check",
|
||||
"/check/scheme/IBAN",
|
||||
"Validate and check IBAN number",
|
||||
"""Validate and check IBAN number for errors
|
||||
|
|
||||
@ -194,16 +194,16 @@ trait APIMethods400 {
|
||||
)
|
||||
|
||||
lazy val ibanChecker: OBPEndpoint = {
|
||||
case "iban-check" :: Nil JsonPost json -> _ => {
|
||||
case "check" :: "scheme" :: "IBAN" :: Nil JsonPost json -> _ => {
|
||||
cc =>
|
||||
val failMsg = s"$InvalidJsonFormat The Json body should be the ${prettyRender(Extraction.decompose(ibanCheckerPostJsonV400))}"
|
||||
for {
|
||||
ibanJson <- NewStyle.function.tryons(failMsg, 400, cc.callContext) {
|
||||
json.extract[Iban]
|
||||
json.extract[IbanAddress]
|
||||
}
|
||||
(ibanChecker, callContext) <- NewStyle.function.validateAndCheckIbanNumber(ibanJson.iban, cc.callContext)
|
||||
(ibanChecker, callContext) <- NewStyle.function.validateAndCheckIbanNumber(ibanJson.address, cc.callContext)
|
||||
} yield {
|
||||
(ibanChecker, HttpCode.`200`(callContext))
|
||||
(JSONFactory400.createIbanCheckerJson(ibanChecker), HttpCode.`200`(callContext))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ import code.api.v2_0_0.TransactionRequestChargeJsonV200
|
||||
import code.api.v2_1_0.{IbanJson, JSONFactory210, PostCounterpartyBespokeJson, ResourceUserJSON}
|
||||
import code.api.v2_2_0.CounterpartyMetadataJson
|
||||
import code.api.v3_0_0.JSONFactory300.{createAccountRoutingsJSON, createAccountRulesJSON}
|
||||
import code.api.v3_0_0.{AccountRuleJsonV300, CustomerAttributeResponseJsonV300, ViewBasicV300}
|
||||
import code.api.v3_0_0.{AccountRuleJsonV300, CustomerAttributeResponseJsonV300}
|
||||
import code.api.v3_1_0.AccountAttributeResponseJson
|
||||
import code.api.v3_1_0.JSONFactory310.createAccountAttributeJson
|
||||
import code.entitlement.Entitlement
|
||||
@ -519,6 +519,24 @@ case class JsonSchemaV400(
|
||||
case class JsonValidationV400(operationId: String, jsonSchema: JsonSchemaV400)
|
||||
// Validation related END
|
||||
|
||||
|
||||
case class IbanCheckerJsonV400(
|
||||
is_valid: Boolean,
|
||||
details: Option[IbanDetailsJsonV400]
|
||||
)
|
||||
|
||||
case class AttributeJsonV400(name: String, value: String)
|
||||
case class IbanDetailsJsonV400(bank_routings: List[BankRoutingJsonV121],
|
||||
bank: String,
|
||||
branch: String,
|
||||
address: String,
|
||||
city: String,
|
||||
zip: String,
|
||||
phone: String,
|
||||
country: String,
|
||||
attributes: List[AttributeJsonV400]
|
||||
)
|
||||
|
||||
object JSONFactory400 {
|
||||
def createBankJSON400(bank: Bank): BankJson400 = {
|
||||
val obp = BankRoutingJsonV121("OBP", bank.bankId.value)
|
||||
@ -929,6 +947,33 @@ object JSONFactory400 {
|
||||
)
|
||||
)
|
||||
}
|
||||
def createIbanCheckerJson(iban: IbanChecker): IbanCheckerJsonV400 = {
|
||||
val details = iban.details.map(
|
||||
i =>
|
||||
IbanDetailsJsonV400(
|
||||
bank_routings = List(BankRoutingJsonV121("bic", i.bic)),
|
||||
bank = i.bank,
|
||||
branch = i.branch,
|
||||
address = i.address,
|
||||
city = i.city,
|
||||
zip = i.zip,
|
||||
phone = i.phone,
|
||||
country = i.country,
|
||||
attributes = List(
|
||||
AttributeJsonV400("country_iso", i.countryIso),
|
||||
AttributeJsonV400("sepa_credit_transfer", i.sepaDirectDebit),
|
||||
AttributeJsonV400("sepa_direct_debit", i.sepaSddCore),
|
||||
AttributeJsonV400("sepa_sdd_core", i.sepaSddCore),
|
||||
AttributeJsonV400("sepa_b2b", i.sepaB2b),
|
||||
AttributeJsonV400("sepa_card_clearing", i.sepaCardClearing),
|
||||
)
|
||||
)
|
||||
)
|
||||
IbanCheckerJsonV400(
|
||||
iban.isValid,
|
||||
details
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -297,6 +297,9 @@ object AmountOfMoney extends Converter[AmountOfMoneyTrait, AmountOfMoney]
|
||||
case class Iban(
|
||||
iban: String
|
||||
)
|
||||
case class IbanAddress(
|
||||
address: String
|
||||
)
|
||||
case class IbanChecker(
|
||||
isValid: Boolean,
|
||||
details: Option[IbanDetails]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user