From eea33cf8360f2c1eec70cc5465fde637f311913a Mon Sep 17 00:00:00 2001 From: Oleksandr Kitsera Date: Mon, 18 Feb 2019 13:03:15 +0200 Subject: [PATCH 1/2] Add sample code on how to retrieve phone number and session token. --- .../example/yuta/ringflashwithoutuisample/WaitActivity.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/yuta/ringflashwithoutuisample/WaitActivity.java b/app/src/main/java/com/example/yuta/ringflashwithoutuisample/WaitActivity.java index 47ae508..fe5e4ec 100644 --- a/app/src/main/java/com/example/yuta/ringflashwithoutuisample/WaitActivity.java +++ b/app/src/main/java/com/example/yuta/ringflashwithoutuisample/WaitActivity.java @@ -75,7 +75,10 @@ public void onCallEnded(String callerNumber) { RingFlashAPIHandler ringFlashAPIHandler1 = new RingFlashAPIHandler() { @Override public void onSuccess(RingFlashResponse response) { - Log.i(MainActivity.TAG, response.toString()); + // Get verified phone number and session token from the response object: + Log.i(MainActivity.TAG, response.getPhone()); + Log.i(MainActivity.TAG, response.getToken()); + String message = ""; boolean is_verified = response.checkStatus(); if (is_verified) { From 3a37d3b6a12d565f331f81a8290304d04b4e1099 Mon Sep 17 00:00:00 2001 From: Oleksandr Kitsera Date: Mon, 18 Feb 2019 13:04:15 +0200 Subject: [PATCH 2/2] Update README with instructions on how to work with response object. --- README.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/README.md b/README.md index 45a1f19..d134cf6 100644 --- a/README.md +++ b/README.md @@ -171,5 +171,59 @@ ringFlashAPIController.requestVerification(credentials, "Replace with caller num ``` **Warning:** The same Credentials object must be passed to both **requestVoiceCall** and **requestVerification** methods. In another case, verification fails even if Credentials instances have the same APP_KEY, SECRET_KEY, and phone number. +#### Parse response from RingCaptcha +To parse response from RingCaptcha, use ```RingFlashResponse``` class. Following getters exists: +```java +public String getId() { + return id; + } + + public String getToken() { + return token; + } + + public String getStatus() { + return status; + } + + public String getMessage() { + return message; + } + + public String getPhone() { + return phone; + } + + public String getService() { + return service; + } + + public int getExpires_in() { + return expires_in; + } + + public int getRetry_in() { + return retry_in; + } +``` + +You can access them easily in `onSuccess` method: + +```java +RingFlashAPIHandler ringFlashAPIHandler = new RingFlashAPIHandler() { + @Override + public void onSuccess(RingFlashResponse response) { + boolean is_verified = response.checkStatus(); + if (is_verified) { + // Get verified phone number and session token from the response object: + Log.i(MainActivity.TAG, response.getPhone()); + Log.i(MainActivity.TAG, response.getToken()); + } else { + //Actions needed to perform after request was failed + } + } +} +``` + ### Retrieving an additional info from callbacks Almost all callbacks provided by ```RingFlashAPIHandler``` and ```RingFlashVerificationHandler``` has a ```RingFlashResponse``` object as a parameter. This object contains all data from RC API response, i.e., seconds needed to wait before another attempt, transaction id, token etc.