Browse Source

Update

hbw_build
Wong Joon Hui 3 years ago
parent
commit
826f080421
  1. 1
      .idea/.gitignore
  2. 1
      .idea/gradle.xml
  3. 14
      app/src/main/java/com/cst/im30/activity/MainActivity.java
  4. 2
      app/src/main/java/com/cst/im30/common/Constants.java
  5. 13
      app/src/main/java/com/cst/im30/retrofit/RetrofitAPICollection.java
  6. 53
      app/src/main/java/com/cst/im30/service/IDVerificationService.java

1
.idea/.gitignore vendored

@ -1,3 +1,4 @@
# Default ignored files # Default ignored files
/shelf/ /shelf/
/workspace.xml /workspace.xml
/compiler.xml

1
.idea/gradle.xml

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>

14
app/src/main/java/com/cst/im30/activity/MainActivity.java

@ -1,6 +1,7 @@
package com.cst.im30.activity; package com.cst.im30.activity;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.drawable.AnimationDrawable; import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle; import android.os.Bundle;
@ -50,6 +51,7 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
ActivityResultLauncher<Intent> icVerificationLauncher = registerForActivityResult( ActivityResultLauncher<Intent> icVerificationLauncher = registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(), new ActivityResultContracts.StartActivityForResult(),
result -> { result -> {
IDVerificationService service = new IDVerificationService(MainActivity.this, MainActivity.this);
if (result.getResultCode() == Activity.RESULT_OK) { if (result.getResultCode() == Activity.RESULT_OK) {
Intent incomingData = result.getData(); Intent incomingData = result.getData();
if (incomingData != null) { if (incomingData != null) {
@ -58,16 +60,18 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
if (verifyIC(name, cardNo)) { if (verifyIC(name, cardNo)) {
Log.d(TAG, "Match"); Log.d(TAG, "Match");
service.verifySuccess(code);
} else { } else {
Log.d(TAG, "Fail"); Log.d(TAG, "Fail");
resetView(); service.verifyFail(code);
} }
} }
} else if (result.getResultCode() == Activity.RESULT_CANCELED) { // Retry Payment } else if (result.getResultCode() == Activity.RESULT_CANCELED) {
service.verifyCancel(code);
} else { } else {
service.verifyFail(code);
} }
resetView();
}); });
public static String getValue() { public static String getValue() {
@ -388,7 +392,7 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
// Verify Card No. // Verify Card No.
String savedNo = this.eventLogDetailed.getDocumentNumber().trim(); String savedNo = this.eventLogDetailed.getDocumentNumber().trim();
if (!savedNo.equalsIgnoreCase(cardNo.trim())) { if (!cardNo.contains(savedNo)) {
match = false; match = false;
} }

2
app/src/main/java/com/cst/im30/common/Constants.java

@ -9,7 +9,7 @@ public class Constants {
public static final String ECHO_SERVER_URL = "http://hello-booking-api-build.testpigeon.net"; public static final String ECHO_SERVER_URL = "http://hello-booking-api-build.testpigeon.net";
public static final String ECHO_SERVER_PORT = "6001"; public static final String ECHO_SERVER_PORT = "6001";
public static final String KIOSK_CODE = "KIOSK001"; public static final String KIOSK_CODE = "KIOSK002";
public static final String SOCKET_PREFIX = "HelloBookingApi_"; public static final String SOCKET_PREFIX = "HelloBookingApi_";

13
app/src/main/java/com/cst/im30/retrofit/RetrofitAPICollection.java

@ -3,6 +3,7 @@ package com.cst.im30.retrofit;
import com.cst.im30.common.Payment; import com.cst.im30.common.Payment;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field; import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded; import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET; import retrofit2.http.GET;
@ -33,6 +34,18 @@ public interface RetrofitAPICollection {
@Path("eventCode") String referenceNumber @Path("eventCode") String referenceNumber
); );
@Headers({
"Accept: application/json",
"Content-Type: application/json"
})
@PUT("api/v1/kiosk/broadcast-event-log/{eventCode}")
Call<String> updateBroadcastEventLogDetails(
@Header("Client-Id") String clientId,
@Header("Client-Secret") String clientSecret,
@Body String body,
@Path("eventCode") String referenceNumber
);
@Headers({ @Headers({
"Accept: application/json" "Accept: application/json"

53
app/src/main/java/com/cst/im30/service/IDVerificationService.java

@ -10,6 +10,7 @@ import com.cst.im30.model.EventLogDetailed;
import com.cst.im30.retrofit.RetrofitAPICollection; import com.cst.im30.retrofit.RetrofitAPICollection;
import com.cst.im30.retrofit.RetrofitClient; import com.cst.im30.retrofit.RetrofitClient;
import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import retrofit2.Call; 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_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_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 Context context;
private final CallableInterface callback; private final CallableInterface callback;
@ -92,4 +95,54 @@ public class IDVerificationService {
return eventLogDetailed; 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();
}
}
} }

Loading…
Cancel
Save