|
|
|
@ -10,6 +10,7 @@ import com.cst.im30.model.EventLogDetailed;
|
|
|
|
|
import com.cst.im30.retrofit.RetrofitAPICollection; |
|
|
|
|
import com.cst.im30.retrofit.RetrofitClient; |
|
|
|
|
|
|
|
|
|
import org.json.JSONException; |
|
|
|
|
import org.json.JSONObject; |
|
|
|
|
|
|
|
|
|
import retrofit2.Call; |
|
|
|
@ -20,6 +21,8 @@ public class IDVerificationService {
|
|
|
|
|
|
|
|
|
|
public static final String CALLBACK_SUCCESS_GET_EVENT_LOG = "callback_success_get_event_log"; |
|
|
|
|
public static final String CALLBACK_FAIL_GET_EVENT_LOG = "callback_fail_get_event_log"; |
|
|
|
|
public static final String CALLBACK_SUCCESS_UPDATE_EVENT_LOG = "callback_success_update_event_log"; |
|
|
|
|
public static final String CALLBACK_FAIL_UPDATE_EVENT_LOG = "callback_fail_update_event_log"; |
|
|
|
|
|
|
|
|
|
private final Context context; |
|
|
|
|
private final CallableInterface callback; |
|
|
|
@ -92,4 +95,54 @@ public class IDVerificationService {
|
|
|
|
|
|
|
|
|
|
return eventLogDetailed; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void verifySuccess(String code) { |
|
|
|
|
updateBroadcastEventLogDetail(code, "success"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void verifyFail(String code) { |
|
|
|
|
updateBroadcastEventLogDetail(code, "fail"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void verifyCancel(String code) { |
|
|
|
|
updateBroadcastEventLogDetail(code, "cancelled"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void updateBroadcastEventLogDetail(String code, String status) { |
|
|
|
|
JSONObject payload = new JSONObject(); |
|
|
|
|
try { |
|
|
|
|
payload.put("status", status); |
|
|
|
|
|
|
|
|
|
RetrofitAPICollection service = RetrofitClient.getRetrofitClient(hostUrl).create(RetrofitAPICollection.class); |
|
|
|
|
Call<String> call = service.updateBroadcastEventLogDetails(clientId, clientSecret, payload.toString(), code); |
|
|
|
|
|
|
|
|
|
call.enqueue(new Callback<String>() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) { |
|
|
|
|
onResponseUpdateBroadcastEventLogDetails(response); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) { |
|
|
|
|
onFailureGetEventLog(t);//todo
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} catch (JSONException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void onResponseUpdateBroadcastEventLogDetails(Response<String> response) { |
|
|
|
|
try { |
|
|
|
|
if (!response.isSuccessful()) { |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
JSONObject responseJSON = new JSONObject(response.body()); |
|
|
|
|
callback.callBack(CALLBACK_SUCCESS_UPDATE_EVENT_LOG); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|