Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/main/java/com/simprints/libsimprints/Identification.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ import android.os.Parcel
import android.os.Parcelable
import android.os.Parcelable.Creator

/**
* This constructor creates a new identification
*
* @param guid Global unique id of the verified person
* @param confidence An int containing the (matching) confidence
* @param tier The tier score derived from the confidence
*/
@Deprecated("Use contracts.data.Identification instead")
data class Identification(
val guid: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.simprints.libsimprints.contracts.data

/**
* This constructor creates a new enrolment result
*
* @param guid Global unique id of the new enrolment
*/
data class Enrolment(
val guid: String,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.simprints.libsimprints.contracts.data
import org.json.JSONArray

/**
* This constructor creates a new identification
* This constructor creates a new identification result
*
* @param guid Global unique id of the verified person
* @param confidence An int containing the (matching) confidence
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.json.JSONArray
import org.json.JSONException
import org.json.JSONObject

internal inline fun <T> T.asJsonObject(crossinline block: (JSONObject) -> JSONObject): JSONObject = JSONObject().also { block(it) }
internal inline fun <T> T.asJsonObject(crossinline block: (JSONObject) -> Unit): JSONObject = JSONObject().also { block(it) }

internal inline fun <T> fromJsonString(
jsonString: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.simprints.libsimprints.contracts.data

/**
* This constructor creates a new refusal form response
*
* @param reason Refusal reason chosen by user out of the provided options
* @param extra Additional information provided by the user
*/
data class RefusalForm(
val reason: String,
val extra: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@ package com.simprints.libsimprints.contracts.data
/**
* This constructor creates a new identification
*
* @param guid Global unique id of the verified person
* @param confidence An int containing the (matching) confidence
* @param guid Global unique id of the verified person
* @param confidence An int containing the (matching) confidence
* @param confidenceBand Confidence qualifier based on the project's configuration
* @param isSuccess Whether the confidence is higher than threshold in the project's configuration if configured
*/
data class Verification(
val guid: String,
val confidence: Float,
val confidenceBand: ConfidenceBand,
val isSuccess: Boolean,
val isSuccess: Boolean?,
) {
fun toJson(): String = asJsonObject {
it.put(KEY_GUID, guid)
it.put(KEY_CONFIDENCE_BAND, confidenceBand.name)
it.put(KEY_CONFIDENCE, confidence)
it.put(KEY_IS_SUCCESS, isSuccess)
if (isSuccess != null) {
it.put(KEY_IS_SUCCESS, isSuccess)
}
}.toString()

companion object {
Expand All @@ -30,7 +33,13 @@ data class Verification(
val guid = json.getString(KEY_GUID)
val confidence = json.getDouble(KEY_CONFIDENCE).toFloat()
val band = json.getString(KEY_CONFIDENCE_BAND).let { ConfidenceBand.valueOf(it) }
val isSuccess = json.getBoolean(KEY_IS_SUCCESS)

// Success flag is only provided if threshold is enabled in project configuration
val isSuccess = if (!json.isNull(KEY_IS_SUCCESS)) {
json.getBoolean(KEY_IS_SUCCESS)
} else {
null
}

Verification(guid, confidence, band, isSuccess)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,12 @@ class VerificationTest {

Assert.assertEquals(expected, actual)
}

@Test
fun `test verification does not have isSuccess if null`() {
val expected = Verification("case-id", 42f, ConfidenceBand.HIGH, null)
val actual = Verification.fromJson(expected.toJson())

Assert.assertEquals(expected, actual)
}
}