Skip to content

Commit

Permalink
Updated return format
Browse files Browse the repository at this point in the history
  • Loading branch information
mohit-appsfly committed Dec 12, 2017
1 parent 3e14d4b commit ce882b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/main/java/io/appsfly/core/AppInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.appsfly.crypto.CtyptoUtil;
import io.appsfly.util.json.JSONArray;
import io.appsfly.util.json.JSONException;
import io.appsfly.util.json.JSONObject;
import io.appsfly.util.json.JSONTokener;
import okhttp3.*;
Expand Down Expand Up @@ -67,7 +68,11 @@ public void onResponse(Call call, final okhttp3.Response response) throws IOExce
byte[] bytes = response.body().bytes();
boolean verified = CtyptoUtil.getInstance().verifychecksum(bytes, checksum, config.secretKey);
if (verified) {
callback.onResponse(new JSONObject(bytes));
try {
callback.onResponse(new JSONTokener(new String(bytes)).nextValue());
} catch (JSONException e) {
callback.onResponse(new JSONObject());
}
} else {
callback.onError(new JSONObject() {{
put("message", "Checksum Validation Failed");
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/appsfly/core/Callback.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.appsfly.util.json.JSONObject;

public interface Callback {
void onResponse(JSONObject response);
void onResponse(Object response);

void onError(JSONObject error);
}

0 comments on commit ce882b7

Please # to comment.