Skip to content

Commit f561aaf

Browse files
feat(v3.1.0): migrate updateCustomerAddress to Http4s310
PUT /banks/BANK_ID/customers/CUSTOMER_ID/addresses/CUSTOMER_ADDRESS_ID was the last genuine miss in v3.1.0 (the other two — getMessageDocsSwagger and getObpConnectorLoopback — are tracked as per-version Lift leftovers that retire via separate workstreams). Mirrors the Lift handler verbatim: same role check (canCreateCustomer), same NewStyle.function.updateCustomerAddress arg list, same JSON shape. Modelled after the existing Http4s310.createCustomerAddress endpoint — withUserAndBankAndBody[B, A] for PUT-with-body returning 200.
1 parent 7659410 commit f561aaf

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

obp-api/src/main/scala/code/api/v3_1_0/Http4s310.scala

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,6 +1706,39 @@ object Http4s310 {
17061706
List(apiTagCustomer), Some(List(canCreateCustomerAddress)),
17071707
http4sPartialFunction = Some(createCustomerAddress))
17081708

1709+
// ─── updateCustomerAddress (PUT) ─────────────────────────────────────────
1710+
1711+
val updateCustomerAddress: HttpRoutes[IO] = HttpRoutes.of[IO] {
1712+
case req @ PUT -> `prefixPath` / "banks" / _ / "customers" / customerIdStr / "addresses" / customerAddressIdStr =>
1713+
EndpointHelpers.withUserAndBankAndBody[PostCustomerAddressJsonV310, Any](req) { (user, bank, postedData, cc) =>
1714+
for {
1715+
_ <- NewStyle.function.hasEntitlement(bank.bankId.value, user.userId, canCreateCustomer, Some(cc))
1716+
(_, _) <- NewStyle.function.getCustomerByCustomerId(customerIdStr, Some(cc))
1717+
(address, _) <- NewStyle.function.updateCustomerAddress(
1718+
customerAddressIdStr,
1719+
postedData.line_1, postedData.line_2, postedData.line_3,
1720+
postedData.city, postedData.county, postedData.state,
1721+
postedData.postcode, postedData.country_code,
1722+
postedData.state,
1723+
postedData.tags.mkString(","),
1724+
Some(cc))
1725+
} yield JSONFactory310.createAddress(address)
1726+
}
1727+
}
1728+
1729+
resourceDocs += ResourceDoc(
1730+
null, implementedInApiVersion, nameOf(updateCustomerAddress), "PUT",
1731+
"/banks/BANK_ID/customers/CUSTOMER_ID/addresses/CUSTOMER_ADDRESS_ID",
1732+
"Update the Address of a Customer",
1733+
s"""Update an Address of the Customer specified by CUSTOMER_ADDRESS_ID.
1734+
|
1735+
|${userAuthenticationMessage(true)}
1736+
|""",
1737+
postCustomerAddressJsonV310, customerAddressJsonV310,
1738+
List(AuthenticatedUserIsRequired, UserHasMissingRoles, InvalidJsonFormat, UnknownError),
1739+
List(apiTagCustomer), Some(List(canCreateCustomer)),
1740+
http4sPartialFunction = Some(updateCustomerAddress))
1741+
17091742
// ─── createUserAuthContext (POST) ────────────────────────────────────────
17101743

17111744
val createUserAuthContext: HttpRoutes[IO] = HttpRoutes.of[IO] {
@@ -3581,6 +3614,7 @@ object Http4s310 {
35813614
.orElse(revokeConsent.run(req))
35823615
.orElse(createTaxResidence.run(req))
35833616
.orElse(createCustomerAddress.run(req))
3617+
.orElse(updateCustomerAddress.run(req))
35843618
.orElse(createUserAuthContext.run(req))
35853619
.orElse(createProductAttribute.run(req))
35863620
.orElse(createAccountWebhook.run(req))

0 commit comments

Comments
 (0)