refactor/replace hardcoded method names with nameOf function for improved readability

This commit is contained in:
Hongwei 2025-04-09 17:50:21 +02:00
parent 6cf3bd19ad
commit 5d767e6617
10 changed files with 490 additions and 46 deletions

View File

@ -49,18 +49,18 @@ object SwaggerDefinitionsJSON {
lazy val regulatedEntitiesJsonV510: RegulatedEntitiesJsonV510 = RegulatedEntitiesJsonV510(List(regulatedEntityJsonV510))
lazy val regulatedEntityJsonV510: RegulatedEntityJsonV510 = RegulatedEntityJsonV510(
entity_id = "0af807d7-3c39-43ef-9712-82bcfde1b9ca",
certificate_authority_ca_owner_id = "CY_CBC",
entity_certificate_public_key = "-----BEGIN CERTIFICATE-----MIICsjCCAZqgAwIBAgIGAYwQ62R0MA0GCSqGSIb3DQEBCwUAMBoxGDAWBgNVBAMMD2FwcC5leGFtcGxlLmNvbTAeFw0yMzExMjcxMzE1MTFaFw0yNTExMjYxMzE1MTFaMBoxGDAWBgNVBAMMD2FwcC5leGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK9WIodZHWzKyCcf9YfWEhPURbfO6zKuMqzHN27GdqHsVVEGxP4F/J4mso+0ENcRr6ur4u81iREaVdCc40rHDHVJNEtniD8Icbz7tcsqAewIVhc/q6WXGqImJpCq7hA0m247dDsaZT0lb/MVBiMoJxDEmAE/GYYnWTEn84R35WhJsMvuQ7QmLvNg6RkChY6POCT/YKe9NKwa1NqI1U+oA5RFzAaFtytvZCE3jtp+aR0brL7qaGfgxm6B7dEpGyhg0NcVCV7xMQNq2JxZTVdAr6lcsRGaAFulakmW3aNnmK+L35Wu8uW+OxNxwUuC6f3b4FVBa276FMuUTRfu7gc+k6kCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAAU5CjEyAoyTn7PgFpQD48ZNPuUsEQ19gzYgJvHMzFIoZ7jKBodjO5mCzWBcR7A4mpeAsdyiNBl2sTiZscSnNqxk61jVzP5Ba1D7XtOjjr7+3iqowrThj6BY40QqhYh/6BSY9fDzVZQiHnvlo6ZUM5kUK6OavZOovKlp5DIl5sGqoP0qAJnpQ4nhB2WVVsKfPlOXc+2KSsbJ23g9l8zaTMr+X0umlvfEKqyEl1Fa2L1dO0y/KFQ+ILmxcZLpRdq1hRAjd0quq9qGC8ucXhRWDgM4hslVpau0da68g0aItWNez3mc5lB82b3dcZpFMzO41bgw7gvw10AvvTfQDqEYIuQ==-----END CERTIFICATE-----",
entity_name = "EXAMPLE COMPANY LTD",
entity_code = "PSD_PICY_CBC!12345",
entity_type = "PSD_PI",
entity_address = "EXAMPLE COMPANY LTD, 5 SOME STREET",
entity_town_city = "SOME CITY",
entity_post_code = "1060",
entity_country = "CY",
entity_web_site = "www.example.com",
services = json.parse("""[{"CY":["PS_010","PS_020","PS_03C","PS_04C"]}]"""),
entity_id = entityIdExample.value,
certificate_authority_ca_owner_id = certificateAuthorityCaOwnerIdExample.value,
entity_certificate_public_key = entityCertificatePublicKeyExample.value,
entity_name = entityNameExample.value,
entity_code = entityCodeExample.value,
entity_type = entityTypeExample.value,
entity_address = entityAddressExample.value,
entity_town_city = entityTownCityExample.value,
entity_post_code = entityPostCodeExample.value,
entity_country = entityCountryExample.value,
entity_web_site = entityWebSiteExample.value,
services = json.parse(servicesExample.value),
attributes = Some(List(RegulatedEntityAttributeSimple(
attributeType=attributeTypeExample.value,
name=attributeNameExample.value,
@ -69,17 +69,17 @@ object SwaggerDefinitionsJSON {
)
lazy val regulatedEntityPostJsonV510: RegulatedEntityPostJsonV510 = RegulatedEntityPostJsonV510(
certificate_authority_ca_owner_id = "CY_CBC",
entity_certificate_public_key = "-----BEGIN CERTIFICATE-----MIICsjCCAZqgAwIBAgIGAYwQ62R0MA0GCSqGSIb3DQEBCwUAMBoxGDAWBgNVBAMMD2FwcC5leGFtcGxlLmNvbTAeFw0yMzExMjcxMzE1MTFaFw0yNTExMjYxMzE1MTFaMBoxGDAWBgNVBAMMD2FwcC5leGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK9WIodZHWzKyCcf9YfWEhPURbfO6zKuMqzHN27GdqHsVVEGxP4F/J4mso+0ENcRr6ur4u81iREaVdCc40rHDHVJNEtniD8Icbz7tcsqAewIVhc/q6WXGqImJpCq7hA0m247dDsaZT0lb/MVBiMoJxDEmAE/GYYnWTEn84R35WhJsMvuQ7QmLvNg6RkChY6POCT/YKe9NKwa1NqI1U+oA5RFzAaFtytvZCE3jtp+aR0brL7qaGfgxm6B7dEpGyhg0NcVCV7xMQNq2JxZTVdAr6lcsRGaAFulakmW3aNnmK+L35Wu8uW+OxNxwUuC6f3b4FVBa276FMuUTRfu7gc+k6kCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAAU5CjEyAoyTn7PgFpQD48ZNPuUsEQ19gzYgJvHMzFIoZ7jKBodjO5mCzWBcR7A4mpeAsdyiNBl2sTiZscSnNqxk61jVzP5Ba1D7XtOjjr7+3iqowrThj6BY40QqhYh/6BSY9fDzVZQiHnvlo6ZUM5kUK6OavZOovKlp5DIl5sGqoP0qAJnpQ4nhB2WVVsKfPlOXc+2KSsbJ23g9l8zaTMr+X0umlvfEKqyEl1Fa2L1dO0y/KFQ+ILmxcZLpRdq1hRAjd0quq9qGC8ucXhRWDgM4hslVpau0da68g0aItWNez3mc5lB82b3dcZpFMzO41bgw7gvw10AvvTfQDqEYIuQ==-----END CERTIFICATE-----",
entity_name = "EXAMPLE COMPANY LTD",
entity_code = "PSD_PICY_CBC!12345",
entity_type = "PSD_PI",
entity_address = "EXAMPLE COMPANY LTD, 5 SOME STREET",
entity_town_city = "SOME CITY",
entity_post_code = "1060",
entity_country = "CY",
entity_web_site = "www.example.com",
services = json.parse("""[{"CY":["PS_010","PS_020","PS_03C","PS_04C"]}]"""),
certificate_authority_ca_owner_id = certificateAuthorityCaOwnerIdExample.value,
entity_certificate_public_key = entityCertificatePublicKeyExample.value,
entity_name = entityNameExample.value,
entity_code = entityCodeExample.value,
entity_type = entityTypeExample.value,
entity_address = entityAddressExample.value,
entity_town_city = entityTownCityExample.value,
entity_post_code = entityPostCodeExample.value,
entity_country = entityCountryExample.value,
entity_web_site = entityWebSiteExample.value,
services = json.parse(servicesExample.value),
attributes = Some(List(RegulatedEntityAttributeSimple(
attributeType=attributeTypeExample.value,
name=attributeNameExample.value,
@ -5645,11 +5645,31 @@ object SwaggerDefinitionsJSON {
legal_name = legalNameExample.value,
agent_number = agentNumberExample.value
)
lazy val minimalAgentsJsonV510 = MinimalAgentsJsonV510(
agents = List(minimalAgentJsonV510)
)
lazy val regulatedEntityAttributeRequestJsonV510 = RegulatedEntityAttributeRequestJsonV510(
name = regulatedEntityAttributeNameExample.value,
attribute_type = regulatedEntityAttributeTypeExample.value,
value = regulatedEntityAttributeValueExample.value,
is_active = Some(isActiveExample.value.toBoolean)
)
lazy val regulatedEntityAttributeResponseJsonV510 = RegulatedEntityAttributeResponseJsonV510(
regulated_entity_id = entityIdExample.value,
regulated_entity_attribute_id = regulatedEntityAttributeIdExample.value,
name = nameExample.value,
attribute_type = typeExample.value,
value = valueExample.value,
is_active = Some(activeExample.value.toBoolean)
)
lazy val regulatedEntityAttributesJsonV510 = RegulatedEntityAttributesJsonV510(
List(regulatedEntityAttributeResponseJsonV510)
)
//The common error or success format.
//Just some helper format to use in Json
case class NotSupportedYet()

View File

@ -581,6 +581,21 @@ object ApiRole extends MdcLoggable{
case class CanDeleteSystemView(requiresBankId: Boolean = false) extends ApiRole
lazy val canDeleteSystemView = CanDeleteSystemView()
case class CanGetRegulatedEntityAttribute(requiresBankId: Boolean = false) extends ApiRole
lazy val canGetRegulatedEntityAttribute = CanGetRegulatedEntityAttribute()
case class CanGetRegulatedEntityAttributes(requiresBankId: Boolean = false) extends ApiRole
lazy val canGetRegulatedEntityAttributes = CanGetRegulatedEntityAttributes()
case class CanCreateRegulatedEntityAttribute(requiresBankId: Boolean = false) extends ApiRole
lazy val canCreateRegulatedEntityAttribute = CanCreateRegulatedEntityAttribute()
case class CanUpdateRegulatedEntityAttribute(requiresBankId: Boolean = false) extends ApiRole
lazy val canUpdateRegulatedEntityAttribute = CanUpdateRegulatedEntityAttribute()
case class CanDeleteRegulatedEntityAttribute(requiresBankId: Boolean = false) extends ApiRole
lazy val canDeleteRegulatedEntityAttribute = CanDeleteRegulatedEntityAttribute()
case class CanGetMethodRoutings(requiresBankId: Boolean = false) extends ApiRole
lazy val canGetMethodRoutings = CanGetMethodRoutings()

View File

@ -305,7 +305,7 @@ object ErrorMessages {
val CustomerNumberAlreadyExists = "OBP-30006: Customer Number already exists. Please specify a different value for BANK_ID or CUSTOMER_NUMBER."
val CustomerAlreadyExistsForUser = "OBP-30007: The User is already linked to a Customer at the bank specified by BANK_ID"
val UserCustomerLinksNotFoundForUser = "OBP-30008: User Customer Link not found by USER_ID"
val AtmNotFoundByAtmId = "OBP-30009: ATM not found. Please specify a valid value for ATM_ID."
val AtmNotFoundByAtmId = "OBP-30009: ATM not found. ATMPlease specify a valid value for ATM_ID."
val BranchNotFoundByBranchId = "OBP-300010: Branch not found. Please specify a valid value for BRANCH_ID. Or License may not be set. meta.license.id and meta.license.name can not be empty"
val ProductNotFoundByProductCode = "OBP-30011: Product not found. Please specify a valid value for PRODUCT_CODE."
val CounterpartyNotFoundByIban = "OBP-30012: Counterparty not found. Please specify a valid value for IBAN."

View File

@ -30,11 +30,13 @@ object ExampleValue {
lazy val bankIdGlossary = glossaryItems.find(_.title == "Bank.bank_id").map(_.textDescription)
lazy val bankIdExample = ConnectorField("gh.29.uk", s"A string that MUST uniquely identify the bank on this OBP instance. It COULD be a UUID but is generally a short string that easily identifies the bank / brand it represents.")
lazy val bankIdExample = ConnectorField("gh.29.uk", s"A string that MUST uniquely identify the bank on this OBP instance. " +
s"It COULD be a UUID but is generally a short string that easily identifies the bank / brand it represents.")
lazy val bank_idExample = bankIdExample
glossaryItems += makeGlossaryItem("Bank.bank_id", bankIdExample)
lazy val accountIdExample = ConnectorField("8ca8a7e4-6d02-40e3-a129-0b2bf89de9f0", s"A string that, in combination with the bankId MUST uniquely identify the account on this OBP instance. SHOULD be a UUID. MUST NOT be able to guess accountNumber from accountId. OBP-API or Adapter keeps a mapping between accountId and accountNumber. AccountId is a non reversible hash of the human readable account number.")
lazy val accountIdExample = ConnectorField("8ca8a7e4-6d02-40e3-a129-0b2bf89de9f0", s"A string that, in combination with the bankId MUST uniquely identify the account on this OBP instance. SHOULD be a UUID. " +
s"MUST NOT be able to guess accountNumber from accountId. OBP-API or Adapter keeps a mapping between accountId and accountNumber. AccountId is a non reversible hash of the human readable account number.")
lazy val account_idExample = accountIdExample
@ -59,17 +61,23 @@ object ExampleValue {
lazy val userNameExample = ConnectorField("felixsmith", s"The userName the user uses to authenticate.")
glossaryItems += makeGlossaryItem("User.userNameExample", userNameExample)
lazy val correlationIdExample = ConnectorField("1flssoftxq0cr1nssr68u0mioj", s"A string generated by OBP-API that MUST uniquely identify the API call received by OBP-API. Used for debugging and logging purposes. It is returned in header to the caller.")
lazy val correlationIdExample = ConnectorField("1flssoftxq0cr1nssr68u0mioj", s"A string generated by OBP-API that MUST " +
s"uniquely identify the API call received by OBP-API. Used for debugging and logging purposes. It is returned in header to the caller.")
glossaryItems += makeGlossaryItem("API.correlation_id", correlationIdExample)
lazy val customerIdExample = ConnectorField("7uy8a7e4-6d02-40e3-a129-0b2bf89de8uh", s"A non human friendly string that identifies the customer and is used in URLs. This SHOULD NOT be the customer number. The combination of customerId and bankId MUST be unique on an OBP instance. customerId SHOULD be unique on an OBP instance. Ideally customerId is a UUID. A mapping between customer number and customer id is kept in OBP.")
lazy val customerIdExample = ConnectorField("7uy8a7e4-6d02-40e3-a129-0b2bf89de8uh", s"A non human friendly string that " +
s"identifies the customer and is used in URLs. This SHOULD NOT be the customer number. The combination of customerId and " +
s"bankId MUST be unique on an OBP instance. customerId SHOULD be unique on an OBP instance. Ideally customerId is a UUID. A mapping between customer number and customer id is kept in OBP.")
glossaryItems += makeGlossaryItem("Customer.customerId", customerIdExample)
lazy val agentIdExample = ConnectorField("7uy8a7e4-6d02-40e3-a129-0b2bf89de8uh", s"A non human friendly string that identifies the agent and is used in URLs. This SHOULD NOT be the agent number. The combination of agentId and bankId MUST be unique on an OBP instance. AgentId SHOULD be unique on an OBP instance. Ideally agentId is a UUID. A mapping between agent number and agent id is kept in OBP.")
lazy val agentIdExample = ConnectorField("7uy8a7e4-6d02-40e3-a129-0b2bf89de8uh", s"A non human friendly string that " +
s"identifies the agent and is used in URLs. This SHOULD NOT be the agent number. The combination of agentId and bankId " +
s"MUST be unique on an OBP instance. AgentId SHOULD be unique on an OBP instance. Ideally agentId is a UUID. A mapping between agent number and agent id is kept in OBP.")
glossaryItems += makeGlossaryItem("Agent.agent_id", agentIdExample)
lazy val customerAccountLinkIdExample = ConnectorField("xyz8a7e4-6d02-40e3-a129-0b2bf89de8uh", s"A non human friendly string that identifies the Customer Account Link and is used in URLs. ")
lazy val customerAccountLinkIdExample = ConnectorField("xyz8a7e4-6d02-40e3-a129-0b2bf89de8uh", s"A non human friendly " +
s"string that identifies the Customer Account Link and is used in URLs. ")
glossaryItems += makeGlossaryItem("Customer.customerAccountLinkId", customerAccountLinkIdExample)
lazy val customerAttributeId = ConnectorField("7uy8a7e4-6d02-40e3-a129-0b2bf89de8uh", s"A non human friendly string that identifies the customer attribute and is used in URLs.")
@ -323,7 +331,8 @@ object ExampleValue {
lazy val expiresDateExample = expiryDateExample
lazy val dateExpiresExample = expiryDateExample
lazy val transactionRequestTypeExample = ConnectorField("SEPA", "The Transaction Request Type defines the request body that is required - and the logic / flow of the Transaction Request. Allowed values include SEPA, COUNTERPARTY and SANDBOX_TAN.")
lazy val transactionRequestTypeExample = ConnectorField("SEPA", "The Transaction Request Type defines the request body that is " +
"required - and the logic / flow of the Transaction Request. Allowed values include SEPA, COUNTERPARTY and SANDBOX_TAN.")
glossaryItems += makeGlossaryItem("Transaction Requests.Transaction Request Type", transactionRequestTypeExample)
lazy val transactionRequestIdExample = ConnectorField("8138a7e4-6d02-40e3-a129-0b2bf89de9f1", "The Transaction Request Id")
@ -416,7 +425,8 @@ object ExampleValue {
lazy val serialNumberExample = ConnectorField("1324234", s"The serial number of the physical card, eg 1123.")
glossaryItems += makeGlossaryItem("Adapter.serial_number", serialNumberExample)
lazy val cardAttributeIdExample = ConnectorField("b4e0352a-9a0f-4bfa-b30b-9003aa467f50", s"A string that MUST uniquely identify the card attribute on this OBP instance. It SHOULD be a UUID.")
lazy val cardAttributeIdExample = ConnectorField("b4e0352a-9a0f-4bfa-b30b-9003aa467f50", s"A string that MUST uniquely " +
s"identify the card attribute on this OBP instance. It SHOULD be a UUID.")
glossaryItems += makeGlossaryItem("Adapter.card_attribute_id", cardAttributeIdExample)
lazy val cardAttributeNameExample = ConnectorField("OVERDRAFT_START_DATE", s"The Card attribute name")
@ -425,10 +435,13 @@ object ExampleValue {
lazy val cardAttributeValueExample = ConnectorField("2012-04-23", s"The card attribute values")
glossaryItems += makeGlossaryItem("Adapter.card_attribute_value", cardAttributeValueExample)
lazy val providerValueExample = ConnectorField("http://127.0.0.1:8080", s"The host name of an Identity Provider authenticating a User. OBP allows the use of multiple simultanious authentication providers. The provider name (host) along with the provider id (a username or id) uniquely identifies a user on OBP.")
lazy val providerValueExample = ConnectorField("http://127.0.0.1:8080", s"The host name of an Identity Provider authenticating a User. " +
s"OBP allows the use of multiple simultanious authentication providers. The provider name (host) along with the provider id " +
s"(a username or id) uniquely identifies a user on OBP.")
glossaryItems += makeGlossaryItem("Authentication.provider", providerValueExample)
lazy val providerIdValueExample = ConnectorField("Chris", s"The provider id of the user which is equivalent to the username. Used in combination with the provider name (host) to uniquely identify a User on OBP.")
lazy val providerIdValueExample = ConnectorField("Chris", s"The provider id of the user which is equivalent to the username. " +
s"Used in combination with the provider name (host) to uniquely identify a User on OBP.")
glossaryItems += makeGlossaryItem("Adapter.provider_id", providerIdValueExample)
lazy val cbsErrorCodeExample = ConnectorField("500-OFFLINE", "An error code returned by the CBS")
@ -520,7 +533,8 @@ object ExampleValue {
lazy val dynamicResourceDocIdExample = ConnectorField("vce035ca-9a0f-4bfa-b30b-9003aa467f51", "A string that MUST uniquely identify the dynamic Resource Doc on this OBP instance, can be used in all cache. ")
lazy val dynamicResourceDocIdExample = ConnectorField("vce035ca-9a0f-4bfa-b30b-9003aa467f51",
"A string that MUST uniquely identify the dynamic Resource Doc on this OBP instance, can be used in all cache. ")
glossaryItems += makeGlossaryItem("DynamicResourceDoc.dynamicResourceDocId", dynamicResourceDocIdExample)
lazy val partialFunctionExample = ConnectorField(NoExampleProvided,NoDescriptionProvided)
@ -544,7 +558,9 @@ object ExampleValue {
lazy val exampleRequestBodyExample = ConnectorField("""{"name": "Jhon", "age": 12, "hobby": ["coding"],"_optional_fields_": ["hobby"]}""", "the json string of the request body.")
glossaryItems += makeGlossaryItem("DynamicResourceDoc.exampleRequestBody", exampleRequestBodyExample)
lazy val successResponseBodyExample = ConnectorField("""{"my_user_id": "some_id_value", "name": "Jhon", "age": 12, "hobby": ["coding"],"_optional_fields_": ["hobby"]}""".stripMargin, "the json string of the success response body.")
lazy val successResponseBodyExample = ConnectorField(
"""{"my_user_id": "some_id_value", "name": "Jhon", "age": 12,
|"hobby": ["coding"],"_optional_fields_": ["hobby"]}""".stripMargin, "the json string of the success response body.")
glossaryItems += makeGlossaryItem("DynamicResourceDoc.successResponseBody", successResponseBodyExample)
lazy val errorResponseBodiesExample = ConnectorField(s"$UnknownError,$UserNotLoggedIn,$UserHasMissingRoles,$InvalidJsonFormat", "The possible error messages of the endpoint. ")
@ -874,7 +890,67 @@ object ExampleValue {
lazy val atmAttributeIdExample = ConnectorField("xxaf2a-9a0f-4bfa-b30b-9003aa467f51","A string that MUST uniquely identify the ATM Attribute on this OBP instance.")
glossaryItems += makeGlossaryItem("ATM.attribute_id", atmIdExample)
lazy val entityIdExample = ConnectorField("0af807d7-3c39-43ef-9712-82bcfde1b9ca", "A unique identifier for the entity.")
glossaryItems += makeGlossaryItem("entity_id", entityIdExample)
lazy val certificateAuthorityCaOwnerIdExample = ConnectorField("CY_CBC", "The certificate authority owner ID.")
glossaryItems += makeGlossaryItem("certificate_authority_ca_owner_id", certificateAuthorityCaOwnerIdExample)
lazy val entityCertificatePublicKeyExample = ConnectorField(
"""-----BEGIN CERTIFICATE-----
MIICsjCCAZqgAwIBAgIGAYwQ62R0MA0GCSqGSIb3DQEBCwUAMBoxGDAWBgNVBAMMD2FwcC5leGFtcGxlLmNvbTAeFw0yMzExMjcxMzE1MTFaFw0yNTExMjYxMzE1
MTFaMBoxGDAWBgNVBAMMD2FwcC5leGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK9WIodZHWzKyCcf9YfWEhPURbfO6zKuMqzHN27Gd
qHsVVEGxP4F/J4mso+0ENcRr6ur4u81iREaVdCc40rHDHVJNEtniD8Icbz7tcsqAewIVhc/q6WXGqImJpCq7hA0m247dDsaZT0lb/MVBiMoJxDEmAE/GYYnWTEn8
4R35WhJsMvuQ7QmLvNg6RkChY6POCT/YKe9NKwa1NqI1U+oA5RFzAaFtytvZCE3jtp+aR0brL7qaGfgxm6B7dEpGyhg0NcVCV7xMQNq2JxZTVdAr6lcsRGaAFul
akmW3aNnmK+L35Wu8uW+OxNxwUuC6f3b4FVBa276FMuUTRfu7gc+k6kCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAAU5CjEyAoyTn7PgFpQD48ZNPuUsEQ19gzY
gJvHMzFIoZ7jKBodjO5mCzWBcR7A4mpeAsdyiNBl2sTiZscSnNqxk61jVzP5Ba1D7XtOjjr7+3iqowrThj6BY40QqhYh/6BSY9fDzVZQiHnvlo6ZUM5kUK6Oav
ZOovKlp5DIl5sGqoP0qAJnpQ4nhB2WVVsKfPlOXc+2KSsbJ23g9l8zaTMr+X0umlvfEKqyEl1Fa2L1dO0y/KFQ+ILmxcZLpRdq1hRAjd0quq9qGC8ucXhRWDgM
4hslVpau0da68g0aItWNez3mc5lB82b3dcZpFMzO41bgw7gvw10AvvTfQDqEYIuQ==
-----END CERTIFICATE-----""",
"The public key of the entity certificate."
)
glossaryItems += makeGlossaryItem("entity_certificate_public_key", entityCertificatePublicKeyExample)
lazy val entityNameExample = ConnectorField("EXAMPLE COMPANY LTD", "The name of the entity.")
glossaryItems += makeGlossaryItem("entity_name", entityNameExample)
lazy val entityCodeExample = ConnectorField("PSD_PICY_CBC!12345", "The code of the entity.")
glossaryItems += makeGlossaryItem("entity_code", entityCodeExample)
lazy val entityTypeExample = ConnectorField("PSD_PI", "The type of the entity.")
glossaryItems += makeGlossaryItem("entity_type", entityTypeExample)
lazy val entityAddressExample = ConnectorField("EXAMPLE COMPANY LTD, 5 SOME STREET", "The address of the entity.")
glossaryItems += makeGlossaryItem("entity_address", entityAddressExample)
lazy val entityTownCityExample = ConnectorField("SOME CITY", "The town or city of the entity.")
glossaryItems += makeGlossaryItem("entity_town_city", entityTownCityExample)
lazy val entityPostCodeExample = ConnectorField("1060", "The postal code of the entity.")
glossaryItems += makeGlossaryItem("entity_post_code", entityPostCodeExample)
lazy val entityCountryExample = ConnectorField("CY", "The country of the entity.")
glossaryItems += makeGlossaryItem("entity_country", entityCountryExample)
lazy val entityWebSiteExample = ConnectorField("www.example.com", "The website of the entity.")
glossaryItems += makeGlossaryItem("entity_web_site", entityWebSiteExample)
lazy val servicesExample = ConnectorField("""[{"CY":["PS_010","PS_020","PS_03C","PS_04C"]}]""", "The services provided by the entity.")
glossaryItems += makeGlossaryItem("services", servicesExample)
lazy val regulatedEntityAttributeIdExample = ConnectorField("attrafa-9a0f-4bfa-b30b-9003aa467f51","A string that MUST uniquely identify the Regulated Entity Attribute on this OBP instance.")
glossaryItems += makeGlossaryItem("RegulatedEntity.attribute_id", regulatedEntityAttributeIdExample)
lazy val regulatedEntityAttributeNameExample = ConnectorField("Attribute Name", s"regulatedEntity attribute name")
glossaryItems += makeGlossaryItem("RegulatedEntity.attribute_name", regulatedEntityAttributeNameExample)
lazy val regulatedEntityAttributeTypeExample = ConnectorField("STRING", s"Regulated Entity Attribute Type.")
glossaryItems += makeGlossaryItem("RegulatedEntity.attribute_type", regulatedEntityAttributeNameExample)
lazy val regulatedEntityAttributeValueExample = ConnectorField("1234", s"Regulated Entity Attribute value")
glossaryItems += makeGlossaryItem("RegulatedEntity.attribute_value", regulatedEntityAttributeNameExample)
lazy val atmNameExample = ConnectorField("Atm by the Lake","The name of the ATM")
glossaryItems += makeGlossaryItem("ATM.name", atmNameExample)

View File

@ -47,8 +47,8 @@ object RegulatedEntityNewStyle {
) map {
(_, callContext)
}
} map {
unboxFull(_)
} map{ i =>
unboxFullOrFail(i, callContext,s"$InvalidConnectorResponse ${nameOf(createRegulatedEntityNewStyle _)} ", 400 )
}
}

View File

@ -0,0 +1,95 @@
package code.api.util.newstyle
import code.api.util.APIUtil.{OBPReturnType, unboxFull, unboxFullOrFail}
import code.api.util.ErrorMessages.{InvalidConnectorResponse}
import code.api.util.CallContext
import code.bankconnectors.Connector
import code.regulatedentities.attribute.RegulatedEntityAttributeX
import com.openbankproject.commons.ExecutionContext.Implicits.global
import com.openbankproject.commons.model.{RegulatedEntityAttributeTrait, RegulatedEntityId}
import com.openbankproject.commons.model.enums.RegulatedEntityAttributeType
import scala.concurrent.Future
import com.github.dwickern.macros.NameOf.nameOf
object RegulatedEntityAttributeNewStyle {
def createOrUpdateRegulatedEntityAttribute(
regulatedEntityId: RegulatedEntityId,
regulatedEntityAttributeId: Option[String],
name: String,
attributeType: RegulatedEntityAttributeType.Value,
value: String,
isActive: Option[Boolean],
callContext: Option[CallContext]
): OBPReturnType[RegulatedEntityAttributeTrait] = {
RegulatedEntityAttributeX.regulatedEntityAttributeProvider.vend.createOrUpdateRegulatedEntityAttribute(
regulatedEntityId: RegulatedEntityId,
regulatedEntityAttributeId: Option[String],
name: String,
attributeType: RegulatedEntityAttributeType.Value,
value: String,
isActive: Option[Boolean]
)
}.map {
result =>
(
unboxFullOrFail(
result,
callContext,
s"$InvalidConnectorResponse ${nameOf(createOrUpdateRegulatedEntityAttribute _)}",
400),
callContext
)
}
def getRegulatedEntityAttributeById(
attributeId: String,
callContext: Option[CallContext]
): OBPReturnType[RegulatedEntityAttributeTrait] = {
RegulatedEntityAttributeX.regulatedEntityAttributeProvider.vend.getRegulatedEntityAttributeById(attributeId).map {
result =>
(
unboxFullOrFail(
result,
callContext,
s"$InvalidConnectorResponse ${nameOf(getRegulatedEntityAttributeById _)}",
404),
callContext
)
}
}
def getRegulatedEntityAttributes(
entityId: RegulatedEntityId,
callContext: Option[CallContext]
): OBPReturnType[List[RegulatedEntityAttributeTrait]] = {
RegulatedEntityAttributeX.regulatedEntityAttributeProvider.vend.getRegulatedEntityAttributes(entityId).map {
result =>
(
unboxFullOrFail(
result,
callContext,
s"$InvalidConnectorResponse ${nameOf(getRegulatedEntityAttributes _)}",
404),
callContext
)
}
}
def deleteRegulatedEntityAttribute(
attributeId: String,
callContext: Option[CallContext]
): OBPReturnType[Boolean] = {
RegulatedEntityAttributeX.regulatedEntityAttributeProvider.vend.deleteRegulatedEntityAttribute(attributeId).map {
result =>
(
unboxFullOrFail(
result,
callContext,
s"$InvalidConnectorResponse ${nameOf(deleteRegulatedEntityAttribute _)}",
400),
callContext
)
}
}
}

View File

@ -14,7 +14,7 @@ import code.api.util.NewStyle.HttpCode
import code.api.util.NewStyle.function.extractQueryParams
import code.api.util.X509.{getCommonName, getEmailAddress, getOrganization}
import code.api.util._
import code.api.util.newstyle.BalanceNewStyle
import code.api.util.newstyle.{BalanceNewStyle, RegulatedEntityAttributeNewStyle}
import code.api.util.newstyle.Consumer.createConsumerNewStyle
import code.api.util.newstyle.RegulatedEntityNewStyle.{createRegulatedEntityNewStyle, deleteRegulatedEntityNewStyle, getRegulatedEntitiesNewStyle, getRegulatedEntityByEntityIdNewStyle}
import code.api.v2_0_0.AccountsHelper.{accountTypeFilterText, getFilteredCoreAccounts}
@ -47,7 +47,7 @@ import code.views.system.{AccountAccess, ViewDefinition}
import com.github.dwickern.macros.NameOf.nameOf
import com.openbankproject.commons.ExecutionContext.Implicits.global
import com.openbankproject.commons.model._
import com.openbankproject.commons.model.enums.{AtmAttributeType, ConsentType, StrongCustomerAuthentication, TransactionRequestStatus, UserAttributeType}
import com.openbankproject.commons.model.enums.{AtmAttributeType, ConsentType, RegulatedEntityAttributeType, StrongCustomerAuthentication, TransactionRequestStatus, UserAttributeType}
import com.openbankproject.commons.util.{ApiVersion, ScannedApiVersion}
import net.liftweb.common.Full
import net.liftweb.http.rest.RestHelper
@ -4637,6 +4637,207 @@ trait APIMethods510 {
}
}
staticResourceDocs += ResourceDoc(
createRegulatedEntityAttribute,
implementedInApiVersion,
nameOf(createRegulatedEntityAttribute),
"POST",
"/regulated-entities/REGULATED_ENTITY_ID/attributes",
"Create Regulated Entity Attribute",
s"""
| Create a new Regulated Entity Attribute for a given REGULATED_ENTITY_ID.
|
| The type field must be one of "STRING", "INTEGER", "DOUBLE" or "DATE_WITH_DAY".
| ${userAuthenticationMessage(true)}
|
""".stripMargin,
regulatedEntityAttributeRequestJsonV510,
regulatedEntityAttributeResponseJsonV510,
List($UserNotLoggedIn, InvalidJsonFormat, UnknownError),
List(apiTagDirectory, apiTagApi),
Some(List(canCreateRegulatedEntityAttribute))
)
lazy val createRegulatedEntityAttribute: OBPEndpoint = {
case "regulated-entities" :: entityId :: "attributes" :: Nil JsonPost json -> _ => {
cc =>
implicit val ec = EndpointContext(Some(cc))
for {
postedData <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $RegulatedEntityAttributeRequestJsonV510 ", 400, cc.callContext) {
json.extract[RegulatedEntityAttributeRequestJsonV510]
}
failMsg = s"$InvalidJsonFormat The `Type` field can only accept the following field: " +
s"${RegulatedEntityAttributeType.DOUBLE}(12.1234), ${RegulatedEntityAttributeType.STRING}(TAX_NUMBER), ${RegulatedEntityAttributeType.INTEGER}(123) and ${RegulatedEntityAttributeType.DATE_WITH_DAY}(2012-04-23)"
regulatedEntityAttributeType <- NewStyle.function.tryons(failMsg, 400, cc.callContext) {
RegulatedEntityAttributeType.withName(postedData.attribute_type)
}
(attribute, callContext) <- RegulatedEntityAttributeNewStyle.createOrUpdateRegulatedEntityAttribute(
regulatedEntityId = RegulatedEntityId(entityId),
regulatedEntityAttributeId = None,
name = postedData.name,
attributeType = regulatedEntityAttributeType,
value = postedData.value,
isActive = postedData.is_active,
callContext = cc.callContext
)
} yield {
(JSONFactory510.createRegulatedEntityAttributeJson(attribute), HttpCode.`201`(callContext))
}
}
}
staticResourceDocs += ResourceDoc(
deleteRegulatedEntityAttribute,
implementedInApiVersion,
nameOf(deleteRegulatedEntityAttribute),
"DELETE",
"/regulated-entities/REGULATED_ENTITY_ID/attributes/REGULATED_ENTITY_ATTRIBUTE_ID",
"Delete Regulated Entity Attribute",
s"""
| Delete a Regulated Entity Attribute specified by REGULATED_ENTITY_ATTRIBUTE_ID.
|
| ${userAuthenticationMessage(true)}
|
""".stripMargin,
EmptyBody,
EmptyBody,
List($UserNotLoggedIn, UnknownError),
List(apiTagDirectory, apiTagApi),
Some(List(canDeleteRegulatedEntityAttribute))
)
lazy val deleteRegulatedEntityAttribute: OBPEndpoint = {
case "regulated-entities" :: entityId :: "attributes" :: attributeId :: Nil JsonDelete _ => {
cc =>
implicit val ec = EndpointContext(Some(cc))
for {
(entity, callContext) <- getRegulatedEntityByEntityIdNewStyle(entityId, cc.callContext)
(deleted, callContext) <- RegulatedEntityAttributeNewStyle.deleteRegulatedEntityAttribute(attributeId, cc.callContext)
} yield {
(Full(deleted), HttpCode.`204`(callContext))
}
}
}
staticResourceDocs += ResourceDoc(
getRegulatedEntityAttributeById,
implementedInApiVersion,
nameOf(getRegulatedEntityAttributeById),
"GET",
"/regulated-entities/REGULATED_ENTITY_ID/attributes/REGULATED_ENTITY_ATTRIBUTE_ID",
"Get Regulated Entity Attribute By ID",
s"""
| Get a specific Regulated Entity Attribute by its REGULATED_ENTITY_ATTRIBUTE_ID.
|
| ${userAuthenticationMessage(true)}
|
""".stripMargin,
EmptyBody,
regulatedEntityAttributeResponseJsonV510,
List($UserNotLoggedIn,UnknownError),
List(apiTagDirectory, apiTagApi),
Some(List(canGetRegulatedEntityAttribute))
)
lazy val getRegulatedEntityAttributeById: OBPEndpoint = {
case "regulated-entities" :: entityId :: "attributes" :: attributeId :: Nil JsonGet _ => {
cc =>
implicit val ec = EndpointContext(Some(cc))
for {
(entity, callContext) <- getRegulatedEntityByEntityIdNewStyle(entityId, cc.callContext)
(attribute, callContext) <- RegulatedEntityAttributeNewStyle.getRegulatedEntityAttributeById(attributeId, cc.callContext)
} yield {
(JSONFactory510.createRegulatedEntityAttributeJson(attribute), HttpCode.`200`(callContext))
}
}
}
staticResourceDocs += ResourceDoc(
getAllRegulatedEntityAttributes,
implementedInApiVersion,
nameOf(getAllRegulatedEntityAttributes),
"GET",
"/regulated-entities/REGULATED_ENTITY_ID/attributes",
"Get All Regulated Entity Attributes",
s"""
| Get all attributes for the specified Regulated Entity.
|
| ${userAuthenticationMessage(true)}
|
""".stripMargin,
EmptyBody,
regulatedEntityAttributesJsonV510,
List($UserNotLoggedIn, UnknownError),
List(apiTagDirectory, apiTagApi),
Some(List(canGetRegulatedEntityAttributes))
)
lazy val getAllRegulatedEntityAttributes: OBPEndpoint = {
case "regulated-entities" :: RegulatedEntityId(entityId) :: "attributes" :: Nil JsonGet _ => {
cc =>
implicit val ec = EndpointContext(Some(cc))
for {
(entity, callContext) <- getRegulatedEntityByEntityIdNewStyle(entityId.value, cc.callContext)
(attributes, callContext) <- RegulatedEntityAttributeNewStyle.getRegulatedEntityAttributes(entityId, cc.callContext)
} yield {
(JSONFactory510.createRegulatedEntityAttributesJson(attributes), HttpCode.`200`(callContext))
}
}
}
staticResourceDocs += ResourceDoc(
updateRegulatedEntityAttribute,
implementedInApiVersion,
nameOf(updateRegulatedEntityAttribute),
"PUT",
"/regulated-entities/REGULATED_ENTITY_ID/attributes/REGULATED_ENTITY_ATTRIBUTE_ID",
"Update Regulated Entity Attribute",
s"""
| Update an existing Regulated Entity Attribute specified by ATTRIBUTE_ID.
|
| ${userAuthenticationMessage(true)}
|
""".stripMargin,
regulatedEntityAttributeRequestJsonV510,
regulatedEntityAttributeResponseJsonV510,
List($UserNotLoggedIn, InvalidJsonFormat, UnknownError),
List(apiTagDirectory, apiTagApi),
Some(List(canUpdateRegulatedEntityAttribute))
)
lazy val updateRegulatedEntityAttribute: OBPEndpoint = {
case "regulated-entities" :: entityId :: "attributes" :: attributeId :: Nil JsonPut json -> _ => {
cc =>
implicit val ec = EndpointContext(Some(cc))
for {
postedData <- NewStyle.function.tryons(s"$InvalidJsonFormat The Json body should be the $RegulatedEntityAttributeRequestJsonV510 ", 400, cc.callContext) {
json.extract[RegulatedEntityAttributeRequestJsonV510]
}
failMsg = s"$InvalidJsonFormat The `Type` field can only accept the following field: " +
s"${RegulatedEntityAttributeType.DOUBLE}(12.1234), ${RegulatedEntityAttributeType.STRING}(TAX_NUMBER), ${RegulatedEntityAttributeType.INTEGER}(123) and ${RegulatedEntityAttributeType.DATE_WITH_DAY}(2012-04-23)"
regulatedEntityAttributeType <- NewStyle.function.tryons(failMsg, 400, cc.callContext) {
RegulatedEntityAttributeType.withName(postedData.attribute_type)
}
(entity, callContext) <- getRegulatedEntityByEntityIdNewStyle(entityId, cc.callContext)
(updatedAttribute, callContext) <- RegulatedEntityAttributeNewStyle.createOrUpdateRegulatedEntityAttribute(
regulatedEntityId = RegulatedEntityId(entityId),
regulatedEntityAttributeId = Some(attributeId),
name = postedData.name,
attributeType = regulatedEntityAttributeType,
value = postedData.value,
isActive = postedData.is_active,
callContext = cc.callContext
)
} yield {
(JSONFactory510.createRegulatedEntityAttributeJson(updatedAttribute), HttpCode.`200`(callContext))
}
}
}
}
}

View File

@ -56,6 +56,26 @@ import java.util.Date
import scala.util.Try
case class RegulatedEntityAttributeRequestJsonV510(
name: String,
attribute_type: String,
value: String,
is_active: Option[Boolean]
)
case class RegulatedEntityAttributeResponseJsonV510(
regulated_entity_id: String,
regulated_entity_attribute_id: String,
name: String,
attribute_type: String,
value: String,
is_active: Option[Boolean]
)
case class RegulatedEntityAttributesJsonV510(
attributes: List[RegulatedEntityAttributeResponseJsonV510]
)
case class SuggestedSessionTimeoutV510(timeout_in_seconds: String)
case class APIInfoJsonV510(
version : String,
@ -1080,6 +1100,26 @@ object JSONFactory510 extends CustomJsonFormats {
agent_number = agent.number
)))
}
def createRegulatedEntityAttributeJson(attribute: RegulatedEntityAttributeTrait): RegulatedEntityAttributeResponseJsonV510 = {
RegulatedEntityAttributeResponseJsonV510(
regulated_entity_id = attribute.regulatedEntityId.value,
regulated_entity_attribute_id = attribute.regulatedEntityAttributeId,
name = attribute.name,
attribute_type = attribute.attributeType.toString,
value = attribute.value,
is_active = attribute.isActive
)
}
def createRegulatedEntityAttributesJson(attributes: List[RegulatedEntityAttributeTrait]): RegulatedEntityAttributesJsonV510 = {
// Implement the logic to convert the attributes to the desired JSON format
RegulatedEntityAttributesJsonV510(
attributes.map(createRegulatedEntityAttributeJson)
)
}
}

View File

@ -13,7 +13,7 @@ import scala.concurrent.Future
object RegulatedEntityAttributeProvider extends RegulatedEntityAttributeProviderTrait {
override def getRegulatedEntityAttributesFromProvider(regulatedEntityId: RegulatedEntityId): Future[Box[List[RegulatedEntityAttribute]]] =
override def getRegulatedEntityAttributes(regulatedEntityId: RegulatedEntityId): Future[Box[List[RegulatedEntityAttribute]]] =
Future {
Box !! RegulatedEntityAttribute.findAll(
By(RegulatedEntityAttribute.RegulatedEntityId_, regulatedEntityId.value)

View File

@ -29,9 +29,7 @@ object RegulatedEntityAttributeX extends SimpleInjector {
trait RegulatedEntityAttributeProviderTrait {
private val logger = Logger(classOf[RegulatedEntityAttributeProviderTrait])
def getRegulatedEntityAttributesFromProvider(regulatedEntityId: RegulatedEntityId): Future[Box[List[RegulatedEntityAttribute]]]
def getRegulatedEntityAttributes(regulatedEntityId: RegulatedEntityId): Future[Box[List[RegulatedEntityAttribute]]]
def getRegulatedEntityAttributeById(regulatedEntityAttributeId: String): Future[Box[RegulatedEntityAttribute]]
@ -46,5 +44,4 @@ trait RegulatedEntityAttributeProviderTrait {
def deleteRegulatedEntityAttribute(regulatedEntityAttributeId: String): Future[Box[Boolean]]
def deleteRegulatedEntityAttributesByRegulatedEntityId(regulatedEntityId: RegulatedEntityId): Future[Box[Boolean]]
// End of Trait
}