VictorPavfurious commented on code in PR #4573:
URL: https://github.com/apache/fineract/pull/4573#discussion_r2046236802


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientAddressApiResource.java:
##########
@@ -113,30 +96,11 @@ public String addClientAddress(@QueryParam("type") 
@Parameter(description = "typ
     @Produces({ MediaType.APPLICATION_JSON })
     @Operation(summary = "List all addresses for a Client", description = 
"Example Requests:\n" + "\n" + "client/1/addresses\n" + "\n"
             + "\n" + "clients/1/addresses?status=false,true&&type=1,2,3")
-    @ApiResponses({
-            @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(array = @ArraySchema(schema = @Schema(implementation = 
ClientAddressApiResourcesSwagger.GetClientClientIdAddressesResponse.class)))) })
-    public String getAddresses(@QueryParam("status") @Parameter(description = 
"status") final String status,
+    public List<AddressData> getAddresses(@QueryParam("status") 
@Parameter(description = "status") final String status,
             @QueryParam("type") @Parameter(description = "type") final long 
addressTypeId,
-            @PathParam("clientid") @Parameter(description = "clientId") final 
long clientid, @Context final UriInfo uriInfo) {
-        Collection<AddressData> address;
-
-        
this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
-
-        // TODO: This is quite a confusing implementation with all these checks
-        // These have to be considered as filtering criterias instead
-        if (addressTypeId == 0 && status == null) {
-            address = 
this.readPlatformService.retrieveAllClientAddress(clientid);
-        } else if (addressTypeId != 0 && status == null) {
-            address = this.readPlatformService.retrieveAddressbyType(clientid, 
addressTypeId);
-        } else if (addressTypeId != 0 && status != null) {
-            address = 
this.readPlatformService.retrieveAddressbyTypeAndStatus(clientid, 
addressTypeId, status);
-        } else {
-            address = 
this.readPlatformService.retrieveAddressbyStatus(clientid, status);
-        }
-
-        final ApiRequestJsonSerializationSettings settings = 
this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
-        return this.toApiJsonSerializer.serialize(settings, address, 
RESPONSE_DATA_PARAMETERS);
-
+            @PathParam("clientid") @Parameter(description = "clientId") final 
long clientid) {
+        
context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
+        return getFilterMethod(addressTypeId, status).apply(clientid, 
addressTypeId, status);

Review Comment:
   I have added filter rules to service, I hope this style will be clearer and 
more stable



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to