-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,168 additions
and
582 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
lib/src/main/java/com/smileidentity/submissions/BiometricKYCSubmission.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.smileidentity.submissions | ||
|
||
import com.smileidentity.models.AuthenticationRequest | ||
import com.smileidentity.models.AuthenticationResponse | ||
import com.smileidentity.models.IdInfo | ||
import com.smileidentity.models.JobType | ||
import com.smileidentity.models.PartnerParams | ||
import com.smileidentity.models.PrepUploadRequest | ||
import com.smileidentity.models.UploadRequest | ||
import com.smileidentity.models.v2.Metadatum | ||
import com.smileidentity.networking.asLivenessImage | ||
import com.smileidentity.networking.asSelfieImage | ||
import com.smileidentity.results.BiometricKycResult | ||
import com.smileidentity.results.SmileIDResult | ||
import com.smileidentity.submissions.base.BaseJobSubmission | ||
import java.io.File | ||
|
||
class BiometricKYCSubmission( | ||
private val userId: String, | ||
jobId: String, | ||
private val allowNewEnroll: Boolean, | ||
private val livenessFiles: List<File>, | ||
private val selfieFile: File, | ||
private val idInfo: IdInfo, | ||
private val extraPartnerParams: Map<String, String>, | ||
private val metadata: List<Metadatum>? = null, | ||
) : BaseJobSubmission<BiometricKycResult>(jobId) { | ||
|
||
override fun createAuthRequest() = AuthenticationRequest( | ||
jobType = JobType.BiometricKyc, | ||
enrollment = false, | ||
userId = userId, | ||
jobId = jobId, | ||
country = idInfo.country, | ||
idType = idInfo.idType, | ||
) | ||
|
||
override fun createPrepUploadRequest(authResponse: AuthenticationResponse?) = PrepUploadRequest( | ||
partnerParams = authResponse?.partnerParams?.copy(extras = extraPartnerParams) | ||
?: PartnerParams( | ||
jobType = JobType.BiometricKyc, | ||
jobId = jobId, | ||
userId = userId, | ||
extras = extraPartnerParams, | ||
), | ||
// TODO : Michael will change this to boolean | ||
allowNewEnroll = allowNewEnroll.toString(), | ||
metadata = metadata, | ||
signature = authResponse?.signature ?: "", | ||
timestamp = authResponse?.timestamp ?: "", | ||
) | ||
|
||
override fun createUploadRequest(authResponse: AuthenticationResponse?): UploadRequest { | ||
val selfieImageInfo = selfieFile.asSelfieImage() | ||
val livenessImageInfo = livenessFiles.map { it.asLivenessImage() } | ||
val uploadRequest = UploadRequest( | ||
images = listOfNotNull( | ||
selfieImageInfo, | ||
) + livenessImageInfo, | ||
idInfo = idInfo.copy(entered = true), | ||
) | ||
return uploadRequest | ||
} | ||
|
||
override suspend fun createSuccessResult( | ||
didSubmit: Boolean, | ||
): SmileIDResult.Success<BiometricKycResult> { | ||
return SmileIDResult.Success( | ||
BiometricKycResult( | ||
selfieFile = selfieFile, | ||
livenessFiles = livenessFiles, | ||
didSubmitBiometricKycJob = didSubmit, | ||
), | ||
) | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
lib/src/main/java/com/smileidentity/submissions/DocumentVerificationSubmission.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.smileidentity.submissions | ||
|
||
import com.smileidentity.models.JobType | ||
import com.smileidentity.models.v2.Metadatum | ||
import com.smileidentity.results.DocumentVerificationResult | ||
import com.smileidentity.results.SmileIDResult | ||
import com.smileidentity.submissions.base.BaseDocumentVerificationSubmission | ||
import java.io.File | ||
|
||
class DocumentVerificationSubmission( | ||
jobId: String, | ||
userId: String, | ||
countryCode: String, | ||
allowNewEnroll: Boolean, | ||
documentFrontFile: File, | ||
selfieFile: File, | ||
documentType: String? = null, | ||
documentBackFile: File? = null, | ||
livenessFiles: List<File>? = null, | ||
extraPartnerParams: Map<String, String>, | ||
metadata: List<Metadatum>? = null, | ||
) : BaseDocumentVerificationSubmission<DocumentVerificationResult>( | ||
jobId = jobId, | ||
userId = userId, | ||
jobType = JobType.DocumentVerification, | ||
countryCode = countryCode, | ||
documentType = documentType, | ||
allowNewEnroll = allowNewEnroll, | ||
documentFrontFile = documentFrontFile, | ||
selfieFile = selfieFile, | ||
documentBackFile = documentBackFile, | ||
livenessFiles = livenessFiles, | ||
extraPartnerParams = extraPartnerParams, | ||
metadata = metadata, | ||
) { | ||
override suspend fun createSuccessResult(didSubmit: Boolean) = SmileIDResult.Success( | ||
createResultInstance( | ||
selfieFile, | ||
documentFrontFile, | ||
livenessFiles, | ||
documentBackFile, | ||
didSubmit, | ||
), | ||
) | ||
|
||
override fun createResultInstance( | ||
selfieFile: File, | ||
documentFrontFile: File, | ||
livenessFiles: List<File>?, | ||
documentBackFile: File?, | ||
didSubmitJob: Boolean, | ||
) = DocumentVerificationResult( | ||
selfieFile = selfieFile, | ||
documentFrontFile = documentFrontFile, | ||
livenessFiles = livenessFiles, | ||
documentBackFile = documentBackFile, | ||
didSubmitDocumentVerificationJob = didSubmitJob, | ||
) | ||
} |
Oops, something went wrong.