Skip to content

Commit

Permalink
Merge pull request #422 from radarlabs/raw-token
Browse files Browse the repository at this point in the history
use rawJson for RadarVerifiedLocationToken
  • Loading branch information
nickpatrick authored Dec 11, 2024
2 parents cca1abf + 16e6781 commit 3a55d56
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
6 changes: 0 additions & 6 deletions example/src/main/java/io/radar/example/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,6 @@ class MainActivity : AppCompatActivity() {
}
}

createButton("trackVerified") {
Radar.trackVerified(false) { status, token ->
Log.v("example", "TrackVerified: status = $status; token = ${token?.toJson()}")
}
}

createButton("startTrackingVerified") {
Radar.startTrackingVerified(60, false)
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ apply plugin: "org.jetbrains.dokka"
apply plugin: 'io.radar.mvnpublish'

ext {
radarVersion = '3.18.9'
radarVersion = '3.18.10'
}

String buildNumber = ".${System.currentTimeMillis()}"
Expand Down
22 changes: 8 additions & 14 deletions sdk/src/main/java/io/radar/sdk/model/RadarVerifiedLocationToken.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ class RadarVerifiedLocationToken(
* The Radar ID of the location check.
*/
val _id: String,

/**
* The full JSON value of the token.
*/
val fullJson: JSONObject,
) {
internal companion object {
private const val FIELD_USER = "user"
Expand All @@ -71,7 +76,7 @@ class RadarVerifiedLocationToken(
val token: String? = obj.optString(FIELD_TOKEN)
val expiresAt: Date? = RadarUtils.isoStringToDate(obj.optString(FIELD_EXPIRES_AT))
val expiresIn: Int = obj.optInt(FIELD_EXPIRES_IN)
val passed: Boolean = user?.fraud?.passed == true && user.country?.passed == true && user.state?.passed == true
val passed: Boolean = obj.optBoolean(FIELD_PASSED)
val failureReasons = obj.optJSONArray(FIELD_FAILURE_REASONS)?.let { failureReasons ->
Array<String>(failureReasons.length()) {
failureReasons.optString(it)
Expand All @@ -83,23 +88,12 @@ class RadarVerifiedLocationToken(
return null
}

return RadarVerifiedLocationToken(user, events, token, expiresAt, expiresIn, passed, failureReasons, id)
return RadarVerifiedLocationToken(user, events, token, expiresAt, expiresIn, passed, failureReasons, id, obj)
}
}

fun toJson(): JSONObject {
val obj = JSONObject()
obj.putOpt(FIELD_USER, this.user.toJson())
obj.putOpt(FIELD_EVENTS, RadarEvent.toJson(this.events))
obj.putOpt(FIELD_TOKEN, this.token)
obj.putOpt(FIELD_EXPIRES_AT, RadarUtils.dateToISOString(this.expiresAt))
obj.putOpt(FIELD_EXPIRES_IN, this.expiresIn)
obj.putOpt(FIELD_PASSED, this.passed)
val failureReasonsArr = JSONArray()
this.failureReasons.forEach { failureReason -> failureReasonsArr.put(failureReason) }
obj.putOpt(FIELD_FAILURE_REASONS, failureReasonsArr)
obj.putOpt(FIELD_ID, this._id)
return obj
return fullJson
}

}

0 comments on commit 3a55d56

Please # to comment.