Skip to content

Commit c305e99

Browse files
authored
Merge pull request #2702 from hongwei1/develop
refactor/(customer): Make customerType and parentCustomerId optional
2 parents 43e65c3 + 4b9cd95 commit c305e99

11 files changed

Lines changed: 99 additions & 97 deletions

File tree

obp-api/src/main/scala/code/api/ResourceDocs1_4_0/MessageDocsSwaggerDefinitions.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ object MessageDocsSwaggerDefinitions
194194
title =titleExample.value,
195195
branchId = branchIdExample.value,
196196
nameSuffix = nameSuffixExample.value,
197-
customerType = "",
198-
parentCustomerId = ""
197+
customerType = Some("INDIVIDUAL"),
198+
parentCustomerId = Some("")
199199
)
200200

201201
val customerAttribute = CustomerAttributeCommons(

obp-api/src/main/scala/code/api/v6_0_0/APIMethods600.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3217,7 +3217,7 @@ trait APIMethods600 {
32173217
(_, callContext) <- NewStyle.function.getBank(bankId, cc.callContext)
32183218
(customer, callContext) <- NewStyle.function.getCustomerByCustomerId(customerId, callContext)
32193219
_ <- Helper.booleanToFuture(failMsg = CustomerTypeMismatch, 404, callContext) {
3220-
customer.customerType == "INDIVIDUAL"
3220+
customer.customerType.contains("INDIVIDUAL")
32213221
}
32223222
(customerAttributes, callContext) <- NewStyle.function.getCustomerAttributes(
32233223
bankId,
@@ -3406,7 +3406,7 @@ trait APIMethods600 {
34063406
(_, callContext) <- NewStyle.function.getBank(bankId, cc.callContext)
34073407
(customer, callContext) <- NewStyle.function.getCustomerByCustomerId(customerId, callContext)
34083408
_ <- Helper.booleanToFuture(failMsg = CustomerTypeMismatch, 404, callContext) {
3409-
List("CORPORATE", "SUBSIDIARY").contains(customer.customerType)
3409+
customer.customerType.exists(ct => List("CORPORATE", "SUBSIDIARY").contains(ct))
34103410
}
34113411
(customerAttributes, callContext) <- NewStyle.function.getCustomerAttributes(
34123412
bankId,
@@ -3451,7 +3451,7 @@ trait APIMethods600 {
34513451
(_, callContext) <- NewStyle.function.getBank(bankId, cc.callContext)
34523452
(customer, callContext) <- NewStyle.function.getCustomerByCustomerId(customerId, callContext)
34533453
_ <- Helper.booleanToFuture(failMsg = CustomerTypeMismatch, 404, callContext) {
3454-
List("CORPORATE", "SUBSIDIARY").contains(customer.customerType)
3454+
customer.customerType.exists(ct => List("CORPORATE", "SUBSIDIARY").contains(ct))
34553455
}
34563456
(children, callContext) <- NewStyle.function.getCustomersByParentCustomerId(bankId, customerId, callContext)
34573457
} yield {
@@ -8713,7 +8713,9 @@ trait APIMethods600 {
87138713
json.extract[PostVerifyUserCredentialsJsonV600]
87148714
}
87158715
// Validate credentials using the existing AuthUser mechanism
8716-
resourceUserIdBox = code.model.dataAccess.AuthUser.getResourceUserId(postedData.username, postedData.password)
8716+
resourceUserIdBox = //we first try to get the userId from local, if not find, we try to get it from external
8717+
code.model.dataAccess.AuthUser.getResourceUserId(postedData.username, postedData.password)
8718+
.or(code.model.dataAccess.AuthUser.externalUserHelper(postedData.username, postedData.password).map(_.user.get))
87178719
// Check if account is locked
87188720
_ <- Helper.booleanToFuture(UsernameHasBeenLocked, 401, callContext) {
87198721
resourceUserIdBox != Full(code.model.dataAccess.AuthUser.usernameLockedStateCode)
@@ -8722,16 +8724,16 @@ trait APIMethods600 {
87228724
resourceUserId <- Future {
87238725
resourceUserIdBox
87248726
} map {
8725-
x => unboxFullOrFail(x, callContext, InvalidLoginCredentials, 401)
8727+
x => unboxFullOrFail(x, callContext, s"$InvalidLoginCredentials Failed to authenticate user credentials.", 401)
87268728
}
87278729
// Get the user object
87288730
user <- Future {
87298731
Users.users.vend.getUserByResourceUserId(resourceUserId)
87308732
} map {
8731-
x => unboxFullOrFail(x, callContext, InvalidLoginCredentials, 401)
8733+
x => unboxFullOrFail(x, callContext, s"$InvalidLoginCredentials User account not found in system.", 401)
87328734
}
87338735
// Verify provider matches if specified and not empty
8734-
_ <- Helper.booleanToFuture(InvalidLoginCredentials, 401, callContext) {
8736+
_ <- Helper.booleanToFuture(s"$InvalidLoginCredentials Authentication provider mismatch.", 401, callContext) {
87358737
postedData.provider.isEmpty || user.provider == postedData.provider
87368738
}
87378739
} yield {

obp-api/src/main/scala/code/api/v6_0_0/JSONFactory6.0.0.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,8 +1362,8 @@ object JSONFactory600 extends CustomJsonFormats with MdcLoggable {
13621362
title = cInfo.title,
13631363
branch_id = cInfo.branchId,
13641364
name_suffix = cInfo.nameSuffix,
1365-
customer_type = cInfo.customerType,
1366-
parent_customer_id = cInfo.parentCustomerId
1365+
customer_type = cInfo.customerType.getOrElse("INDIVIDUAL"),
1366+
parent_customer_id = cInfo.parentCustomerId.getOrElse("")
13671367
)
13681368
}
13691369

@@ -1414,8 +1414,8 @@ object JSONFactory600 extends CustomJsonFormats with MdcLoggable {
14141414
title = cInfo.title,
14151415
branch_id = cInfo.branchId,
14161416
name_suffix = cInfo.nameSuffix,
1417-
customer_type = cInfo.customerType,
1418-
parent_customer_id = cInfo.parentCustomerId,
1417+
customer_type = cInfo.customerType.getOrElse("INDIVIDUAL"),
1418+
parent_customer_id = cInfo.parentCustomerId.getOrElse(""),
14191419
customer_attributes = customerAttributes.map(customerAttribute =>
14201420
CustomerAttributeResponseJsonV300(
14211421
customer_attribute_id = customerAttribute.customerAttributeId,

obp-api/src/main/scala/code/bankconnectors/akka/AkkaConnector_vDec2018.scala

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3837,8 +3837,8 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit {
38373837
title=customerTitleExample.value,
38383838
branchId=branchIdExample.value,
38393839
nameSuffix=nameSuffixExample.value,
3840-
customerType="",
3841-
parentCustomerId=""))
3840+
customerType=Some("INDIVIDUAL"),
3841+
parentCustomerId=Some("")))
38423842
),
38433843
adapterImplementation = Some(AdapterImplementation("- Core", 1))
38443844
)
@@ -3890,8 +3890,8 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit {
38903890
title=customerTitleExample.value,
38913891
branchId=branchIdExample.value,
38923892
nameSuffix=nameSuffixExample.value,
3893-
customerType="",
3894-
parentCustomerId=""))
3893+
customerType=Some("INDIVIDUAL"),
3894+
parentCustomerId=Some("")))
38953895
),
38963896
adapterImplementation = Some(AdapterImplementation("- Core", 1))
38973897
)
@@ -3944,8 +3944,8 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit {
39443944
title=customerTitleExample.value,
39453945
branchId=branchIdExample.value,
39463946
nameSuffix=nameSuffixExample.value,
3947-
customerType="",
3948-
parentCustomerId=""))
3947+
customerType=Some("INDIVIDUAL"),
3948+
parentCustomerId=Some("")))
39493949
),
39503950
adapterImplementation = Some(AdapterImplementation("- Core", 1))
39513951
)
@@ -4007,8 +4007,8 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit {
40074007
title=customerTitleExample.value,
40084008
branchId=branchIdExample.value,
40094009
nameSuffix=nameSuffixExample.value,
4010-
customerType="",
4011-
parentCustomerId=""))
4010+
customerType=Some("INDIVIDUAL"),
4011+
parentCustomerId=Some("")))
40124012
),
40134013
adapterImplementation = Some(AdapterImplementation("- Core", 1))
40144014
)
@@ -4057,8 +4057,8 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit {
40574057
title=customerTitleExample.value,
40584058
branchId=branchIdExample.value,
40594059
nameSuffix=nameSuffixExample.value,
4060-
customerType="",
4061-
parentCustomerId=""))
4060+
customerType=Some("INDIVIDUAL"),
4061+
parentCustomerId=Some("")))
40624062
),
40634063
adapterImplementation = Some(AdapterImplementation("- Core", 1))
40644064
)
@@ -4108,8 +4108,8 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit {
41084108
title=customerTitleExample.value,
41094109
branchId=branchIdExample.value,
41104110
nameSuffix=nameSuffixExample.value,
4111-
customerType="",
4112-
parentCustomerId=""))
4111+
customerType=Some("INDIVIDUAL"),
4112+
parentCustomerId=Some("")))
41134113
),
41144114
adapterImplementation = Some(AdapterImplementation("- Core", 1))
41154115
)
@@ -4408,8 +4408,8 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit {
44084408
title=customerTitleExample.value,
44094409
branchId=branchIdExample.value,
44104410
nameSuffix=nameSuffixExample.value,
4411-
customerType="",
4412-
parentCustomerId="")))
4411+
customerType=Some("INDIVIDUAL"),
4412+
parentCustomerId=Some(""))))
44134413
),
44144414
adapterImplementation = Some(AdapterImplementation("- Core", 1))
44154415
)
@@ -4459,8 +4459,8 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit {
44594459
title=customerTitleExample.value,
44604460
branchId=branchIdExample.value,
44614461
nameSuffix=nameSuffixExample.value,
4462-
customerType="",
4463-
parentCustomerId="")))
4462+
customerType=Some("INDIVIDUAL"),
4463+
parentCustomerId=Some(""))))
44644464
),
44654465
adapterImplementation = Some(AdapterImplementation("- Core", 1))
44664466
)
@@ -5164,8 +5164,8 @@ object AkkaConnector_vDec2018 extends Connector with AkkaConnectorActorInit {
51645164
title=customerTitleExample.value,
51655165
branchId=branchIdExample.value,
51665166
nameSuffix=nameSuffixExample.value,
5167-
customerType="",
5168-
parentCustomerId="")))
5167+
customerType=Some("INDIVIDUAL"),
5168+
parentCustomerId=Some(""))))
51695169
),
51705170
exampleInboundMessage = (
51715171
InBoundGetCustomerAttributesForCustomers(inboundAdapterCallContext=MessageDocsSwaggerDefinitions.inboundAdapterCallContext,

obp-api/src/main/scala/code/bankconnectors/rabbitmq/RabbitMQConnector_vOct2024.scala

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4534,8 +4534,8 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
45344534
title=customerTitleExample.value,
45354535
branchId=branchIdExample.value,
45364536
nameSuffix=nameSuffixExample.value,
4537-
customerType="",
4538-
parentCustomerId=""))
4537+
customerType=Some("INDIVIDUAL"),
4538+
parentCustomerId=Some("")))
45394539
),
45404540
adapterImplementation = Some(AdapterImplementation("- Core", 1))
45414541
)
@@ -4587,8 +4587,8 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
45874587
title=customerTitleExample.value,
45884588
branchId=branchIdExample.value,
45894589
nameSuffix=nameSuffixExample.value,
4590-
customerType="",
4591-
parentCustomerId=""))
4590+
customerType=Some("INDIVIDUAL"),
4591+
parentCustomerId=Some("")))
45924592
),
45934593
adapterImplementation = Some(AdapterImplementation("- Core", 1))
45944594
)
@@ -4641,8 +4641,8 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
46414641
title=customerTitleExample.value,
46424642
branchId=branchIdExample.value,
46434643
nameSuffix=nameSuffixExample.value,
4644-
customerType="",
4645-
parentCustomerId=""))
4644+
customerType=Some("INDIVIDUAL"),
4645+
parentCustomerId=Some("")))
46464646
),
46474647
adapterImplementation = Some(AdapterImplementation("- Core", 1))
46484648
)
@@ -4704,8 +4704,8 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
47044704
title=customerTitleExample.value,
47054705
branchId=branchIdExample.value,
47064706
nameSuffix=nameSuffixExample.value,
4707-
customerType="",
4708-
parentCustomerId=""))
4707+
customerType=Some("INDIVIDUAL"),
4708+
parentCustomerId=Some("")))
47094709
),
47104710
adapterImplementation = Some(AdapterImplementation("- Core", 1))
47114711
)
@@ -4754,8 +4754,8 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
47544754
title=customerTitleExample.value,
47554755
branchId=branchIdExample.value,
47564756
nameSuffix=nameSuffixExample.value,
4757-
customerType="",
4758-
parentCustomerId="")))
4757+
customerType=Some("INDIVIDUAL"),
4758+
parentCustomerId=Some(""))))
47594759
),
47604760
adapterImplementation = Some(AdapterImplementation("- Core", 1))
47614761
)
@@ -4804,8 +4804,8 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
48044804
title=customerTitleExample.value,
48054805
branchId=branchIdExample.value,
48064806
nameSuffix=nameSuffixExample.value,
4807-
customerType="",
4808-
parentCustomerId=""))
4807+
customerType=Some("INDIVIDUAL"),
4808+
parentCustomerId=Some("")))
48094809
),
48104810
adapterImplementation = Some(AdapterImplementation("- Core", 1))
48114811
)
@@ -4855,8 +4855,8 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
48554855
title=customerTitleExample.value,
48564856
branchId=branchIdExample.value,
48574857
nameSuffix=nameSuffixExample.value,
4858-
customerType="",
4859-
parentCustomerId=""))
4858+
customerType=Some("INDIVIDUAL"),
4859+
parentCustomerId=Some("")))
48604860
),
48614861
adapterImplementation = Some(AdapterImplementation("- Core", 1))
48624862
)
@@ -5155,8 +5155,8 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
51555155
title=customerTitleExample.value,
51565156
branchId=branchIdExample.value,
51575157
nameSuffix=nameSuffixExample.value,
5158-
customerType="",
5159-
parentCustomerId="")))
5158+
customerType=Some("INDIVIDUAL"),
5159+
parentCustomerId=Some(""))))
51605160
),
51615161
adapterImplementation = Some(AdapterImplementation("- Core", 1))
51625162
)
@@ -5206,8 +5206,8 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
52065206
title=customerTitleExample.value,
52075207
branchId=branchIdExample.value,
52085208
nameSuffix=nameSuffixExample.value,
5209-
customerType="",
5210-
parentCustomerId="")))
5209+
customerType=Some("INDIVIDUAL"),
5210+
parentCustomerId=Some(""))))
52115211
),
52125212
adapterImplementation = Some(AdapterImplementation("- Core", 1))
52135213
)
@@ -5942,8 +5942,8 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
59425942
title=customerTitleExample.value,
59435943
branchId=branchIdExample.value,
59445944
nameSuffix=nameSuffixExample.value,
5945-
customerType="",
5946-
parentCustomerId="")))
5945+
customerType=Some("INDIVIDUAL"),
5946+
parentCustomerId=Some(""))))
59475947
),
59485948
exampleInboundMessage = (
59495949
InBoundGetCustomerAttributesForCustomers(inboundAdapterCallContext=MessageDocsSwaggerDefinitions.inboundAdapterCallContext,

0 commit comments

Comments
 (0)