|
|
|
@ -4,6 +4,7 @@ import androidx.annotation.NonNull;
|
|
|
|
|
|
|
|
|
|
import com.cst.im30.BuildConfig; |
|
|
|
|
import com.cst.im30.common.CallableInterface; |
|
|
|
|
import com.cst.im30.common.Constants; |
|
|
|
|
import com.cst.im30.model.EventLogDetailed; |
|
|
|
|
import com.cst.im30.api.RetrofitAPICollection; |
|
|
|
|
import com.cst.im30.api.RetrofitClient; |
|
|
|
@ -24,12 +25,17 @@ public class IDVerificationService {
|
|
|
|
|
public static final String SUCCESS_UPDATE_EVENT_LOG = TAG + "SUCCESS_UPDATE_EVENT_LOG"; |
|
|
|
|
public static final String FAIL_UPDATE_EVENT_LOG = TAG + "FAIL_UPDATE_EVENT_LOG"; |
|
|
|
|
|
|
|
|
|
public static final String REJECT_EVENT_LOG = "REJECT"; |
|
|
|
|
|
|
|
|
|
private final CallableInterface callback; |
|
|
|
|
|
|
|
|
|
private final String hostUrl; |
|
|
|
|
private final String clientId; |
|
|
|
|
private final String clientSecret; |
|
|
|
|
|
|
|
|
|
private String code; |
|
|
|
|
private String status; |
|
|
|
|
|
|
|
|
|
public IDVerificationService(CallableInterface callback) { |
|
|
|
|
this.callback = callback; |
|
|
|
|
|
|
|
|
@ -39,7 +45,6 @@ public class IDVerificationService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void getEventLog(String code) { |
|
|
|
|
|
|
|
|
|
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class); |
|
|
|
|
Call<String> call = service.getBroadcastEventLogDetails(clientId, clientSecret, code); |
|
|
|
|
|
|
|
|
@ -83,12 +88,15 @@ public class IDVerificationService {
|
|
|
|
|
private void onFailureGetEventLog(Throwable t) { |
|
|
|
|
if (t instanceof Exception) { |
|
|
|
|
Logger.logE(t.getMessage()); |
|
|
|
|
((Exception) t).printStackTrace(); |
|
|
|
|
t.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
callback.callBack(FAIL_GET_EVENT_LOG, t.getMessage()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void updateBroadcastEventLogDetail(String code, String status) { |
|
|
|
|
this.code = code; |
|
|
|
|
this.status = status; |
|
|
|
|
|
|
|
|
|
JSONObject payload = new JSONObject(); |
|
|
|
|
try { |
|
|
|
|
payload.put("status", status); |
|
|
|
@ -112,7 +120,7 @@ public class IDVerificationService {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) { |
|
|
|
|
onFailureUpdateEventLog(t); |
|
|
|
|
onFailureUpdateBroadcastEventLogDetails(t); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -129,8 +137,14 @@ public class IDVerificationService {
|
|
|
|
|
callback.callBack(FAIL_UPDATE_EVENT_LOG, responseJSON); |
|
|
|
|
} else { |
|
|
|
|
JSONObject responseJSON = new JSONObject(response.body()); |
|
|
|
|
|
|
|
|
|
Logger.logV(responseJSON.toString()); |
|
|
|
|
callback.callBack(SUCCESS_UPDATE_EVENT_LOG, responseJSON); |
|
|
|
|
|
|
|
|
|
if (Constants.STATUS_REJECT.equalsIgnoreCase(status)) { |
|
|
|
|
callback.callBack(REJECT_EVENT_LOG, code); |
|
|
|
|
} else { |
|
|
|
|
callback.callBack(SUCCESS_UPDATE_EVENT_LOG, responseJSON); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
Logger.logE(e.getMessage()); |
|
|
|
@ -138,25 +152,28 @@ public class IDVerificationService {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void onFailureUpdateEventLog(Throwable t) { |
|
|
|
|
private void onFailureUpdateBroadcastEventLogDetails(Throwable t) { |
|
|
|
|
if (t instanceof Exception) { |
|
|
|
|
Logger.logE(t.getMessage()); |
|
|
|
|
((Exception) t).printStackTrace(); |
|
|
|
|
t.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
callback.callBack(FAIL_UPDATE_EVENT_LOG, t.getMessage()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void verifySuccess(String code) { |
|
|
|
|
updateBroadcastEventLogDetail(code, "success"); |
|
|
|
|
updateBroadcastEventLogDetail(code, Constants.STATUS_SUCCESS); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void verifyFail(String code) { |
|
|
|
|
updateBroadcastEventLogDetail(code, "fail"); |
|
|
|
|
updateBroadcastEventLogDetail(code, Constants.STATUS_FAIL); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void verifyCancel(String code) { |
|
|
|
|
updateBroadcastEventLogDetail(code, "cancelled"); |
|
|
|
|
updateBroadcastEventLogDetail(code, Constants.STATUS_CANCELLED); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void verifyReject(String code) { |
|
|
|
|
updateBroadcastEventLogDetail(code, Constants.STATUS_REJECT); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private EventLogDetailed parseGetEventLogResponse(JSONObject jsonObject) throws Exception { |
|
|
|
|