Skip to content

Commit

Permalink
fix for repsonse body parsing error for version 1.0.3 (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankita10r authored Oct 26, 2022
1 parent 6166b99 commit f4d704f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.dataformat.JsonLibrary;
import org.apache.camel.util.json.JsonObject;
import org.json.JSONObject;
import org.mifos.connector.ams.paygops.paygopsDTO.PaygopsRequestDTO;
import org.mifos.connector.ams.paygops.paygopsDTO.PaygopsResponseDto;
Expand All @@ -16,8 +17,6 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Map;

import static org.mifos.connector.ams.paygops.camel.config.CamelProperties.*;
import static org.mifos.connector.ams.paygops.camel.config.CamelProperties.AMS_REQUEST;
import static org.mifos.connector.ams.paygops.zeebe.ZeebeVariables.*;
Expand Down Expand Up @@ -47,6 +46,12 @@ enum accountStatus{
REJECTED
}


public PaygopsRouteBuilder() {

}


@Override
public void configure() {

Expand Down Expand Up @@ -76,12 +81,11 @@ public void configure() {
.choice()
.when(header("CamelHttpResponseCode").isEqualTo("200"))
.log(LoggingLevel.INFO, "Paygops Validation Response Received")
.unmarshal().json(JsonLibrary.Jackson, PaygopsResponseDto.class)
.process(exchange -> {
// processing success case
try {
String body = exchange.getIn().getBody(String.class);
ObjectMapper mapper = new ObjectMapper();
PaygopsResponseDto result = mapper.readValue(body, PaygopsResponseDto.class);
PaygopsResponseDto result = exchange.getIn().getBody(PaygopsResponseDto.class);
if (result.getReconciled()) {
logger.info("Paygops Validation Successful");
exchange.setProperty(PARTY_LOOKUP_FAILED, false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.mifos.connector.ams.paygops.paygopsDTO;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.json.JSONArray;
import org.json.JSONObject;

public class PaygopsResponseDto {

Expand Down Expand Up @@ -59,7 +61,7 @@ public class PaygopsResponseDto {
private String destination_type;

@JsonProperty("destinations")
private String [] destinations = new String[1];
private Object[] destinations = new Object[1];

@Override
public String toString() {
Expand Down Expand Up @@ -171,11 +173,11 @@ public void setDestination_type(String destination_type) {
this.destination_type = destination_type;
}

public String[] getDestinations() {
public Object[] getDestinations() {
return destinations;
}

public void setDestination(String[] destinations) {
public void setDestination(Object[] destinations) {
this.destinations = destinations;
}
}

0 comments on commit f4d704f

Please sign in to comment.