Skip to content

Commit

Permalink
Rename partnerParams to extraPartnerParams (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
jumaallan authored Nov 16, 2023
1 parent 2a8d9cb commit 705ea54
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct OrchestratedBiometricKycScreen: View {
let showInstructions: Bool
let showAttribution: Bool
let allowAgentMode: Bool
let partnerParams: [String: String] = [:]
let extraPartnerParams: [String: String] = [:]
let delegate: BiometricKycResultDelegate
@ObservedObject private var viewModel: OrchestratedBiometricKycViewModel

Expand All @@ -28,7 +28,7 @@ struct OrchestratedBiometricKycScreen: View {
showInstructions: Bool,
showAttribution: Bool,
allowAgentMode: Bool,
partnerParams: [String: String] = [:],
extraPartnerParams: [String: String] = [:],
delegate: BiometricKycResultDelegate
) {
self.userId = userId
Expand All @@ -42,7 +42,7 @@ struct OrchestratedBiometricKycScreen: View {
self.allowAgentMode = allowAgentMode
self.delegate = delegate
viewModel = OrchestratedBiometricKycViewModel(
userId: userId, jobId: jobId, idInfo: idInfo, partnerParams: partnerParams
userId: userId, jobId: jobId, idInfo: idInfo, extraPartnerParams: extraPartnerParams
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class OrchestratedBiometricKycViewModel: ObservableObject, SelfieImageC
// MARK: - Input Properties
private let userId: String
private let jobId: String
private var partnerParams: [String: String]
private var extraPartnerParams: [String: String]
private var idInfo: IdInfo?

// MARK: - Other Properties
Expand All @@ -27,11 +27,11 @@ internal class OrchestratedBiometricKycViewModel: ObservableObject, SelfieImageC
messageKey: "BiometricKYC.Loading.IdTypes"
)

init(userId: String, jobId: String, idInfo: IdInfo?, partnerParams: [String: String] = [:]) {
init(userId: String, jobId: String, idInfo: IdInfo?, extraPartnerParams: [String: String] = [:]) {
self.userId = userId
self.jobId = jobId
self.idInfo = idInfo
self.partnerParams = partnerParams
self.extraPartnerParams = extraPartnerParams
if let idInfo = idInfo {
guard let idType = idInfo.idType else {
fatalError("You are expected to pass in the idType if you pass in idInfo")
Expand Down Expand Up @@ -214,7 +214,7 @@ internal class OrchestratedBiometricKycViewModel: ObservableObject, SelfieImageC
)
let authResponse = try await SmileID.api.authenticate(request: authRequest).async()
let prepUploadRequest = PrepUploadRequest(
partnerParams: authResponse.partnerParams.copy(partnerParams: partnerParams),
partnerParams: authResponse.partnerParams.copy(extras: extraPartnerParams),
timestamp: authResponse.timestamp,
signature: authResponse.signature
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class IOrchestratedDocumentVerificationViewModel<T, U: JobResult>: Obse
internal let captureBothSides: Bool
internal var selfieFile: Data?
internal let jobType: JobType
internal let partnerParams: [String: String]
internal let extraPartnerParams: [String: String]

// Other properties
internal var documentFrontFile: Data?
Expand All @@ -41,7 +41,7 @@ internal class IOrchestratedDocumentVerificationViewModel<T, U: JobResult>: Obse
captureBothSides: Bool,
selfieFile: URL?,
jobType: JobType,
partnerParams: [String: String] = [:]
extraPartnerParams: [String: String] = [:]
) {
self.userId = userId
self.jobId = jobId
Expand All @@ -50,7 +50,7 @@ internal class IOrchestratedDocumentVerificationViewModel<T, U: JobResult>: Obse
self.captureBothSides = captureBothSides
self.selfieFile = selfieFile.flatMap { try? Data(contentsOf: $0) }
self.jobType = jobType
self.partnerParams = partnerParams
self.extraPartnerParams = extraPartnerParams
}

func onFrontDocumentImageConfirmed(data: Data) {
Expand Down Expand Up @@ -142,7 +142,7 @@ internal class IOrchestratedDocumentVerificationViewModel<T, U: JobResult>: Obse
let auth = SmileID.api.authenticate(request: authRequest)
networkingSubscriber = auth.flatMap { authResponse in
let prepUploadRequest = PrepUploadRequest(
partnerParams: authResponse.partnerParams.copy(partnerParams: self.partnerParams),
partnerParams: authResponse.partnerParams.copy(extras: self.extraPartnerParams),
timestamp: authResponse.timestamp,
signature: authResponse.signature
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct OrchestratedDocumentVerificationScreen: View {
let allowGalleryUpload: Bool
let allowAgentMode: Bool
let showInstructions: Bool
let partnerParams: [String: String]
let extraPartnerParams: [String: String]
let onResult: DocumentVerificationResultDelegate

var body: some View {
Expand All @@ -28,7 +28,7 @@ struct OrchestratedDocumentVerificationScreen: View {
allowGalleryUpload: allowGalleryUpload,
allowAgentMode: allowAgentMode,
showInstructions: showInstructions,
partnerParams: partnerParams,
extraPartnerParams: extraPartnerParams,
onResult: onResult,
viewModel: OrchestratedDocumentVerificationViewModel(
userId: userId,
Expand All @@ -38,7 +38,7 @@ struct OrchestratedDocumentVerificationScreen: View {
captureBothSides: captureBothSides,
selfieFile: bypassSelfieCaptureWithFile,
jobType: .documentVerification,
partnerParams: partnerParams
extraPartnerParams: extraPartnerParams
)
)
}
Expand All @@ -56,7 +56,7 @@ struct OrchestratedEnhancedDocumentVerificationScreen: View {
let allowGalleryUpload: Bool
let allowAgentMode: Bool
let showInstructions: Bool
let partnerParams: [String: String]
let extraPartnerParams: [String: String]
let onResult: EnhancedDocumentVerificationResultDelegate

var body: some View {
Expand All @@ -72,7 +72,7 @@ struct OrchestratedEnhancedDocumentVerificationScreen: View {
allowGalleryUpload: allowGalleryUpload,
allowAgentMode: allowAgentMode,
showInstructions: showInstructions,
partnerParams: partnerParams,
extraPartnerParams: extraPartnerParams,
onResult: onResult,
viewModel: OrchestratedEnhancedDocumentVerificationViewModel(
userId: userId,
Expand All @@ -82,7 +82,7 @@ struct OrchestratedEnhancedDocumentVerificationScreen: View {
captureBothSides: captureBothSides,
selfieFile: bypassSelfieCaptureWithFile,
jobType: .enhancedDocumentVerification,
partnerParams: partnerParams
extraPartnerParams: extraPartnerParams
)
)
}
Expand All @@ -100,7 +100,7 @@ private struct IOrchestratedDocumentVerificationScreen<T, U: JobResult>: View {
let allowGalleryUpload: Bool
let allowAgentMode: Bool
let showInstructions: Bool
var partnerParams: [String: String]
var extraPartnerParams: [String: String]
let onResult: T
@ObservedObject var viewModel: IOrchestratedDocumentVerificationViewModel<T, U>

Expand All @@ -116,7 +116,7 @@ private struct IOrchestratedDocumentVerificationScreen<T, U: JobResult>: View {
allowGalleryUpload: Bool,
allowAgentMode: Bool,
showInstructions: Bool,
partnerParams: [String: String],
extraPartnerParams: [String: String],
onResult: T,
viewModel: IOrchestratedDocumentVerificationViewModel<T, U>
) {
Expand All @@ -131,7 +131,7 @@ private struct IOrchestratedDocumentVerificationScreen<T, U: JobResult>: View {
self.allowGalleryUpload = allowGalleryUpload
self.allowAgentMode = allowAgentMode
self.showInstructions = showInstructions
self.partnerParams = partnerParams
self.extraPartnerParams = extraPartnerParams
self.onResult = onResult
self.viewModel = viewModel
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/SmileID/Classes/Networking/Models/PartnerParams.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public struct PartnerParams: Codable {
}

// Method for copying with modified properties
func copy(partnerParams: [String: String]?) -> PartnerParams {
func copy(extras: [String: String]?) -> PartnerParams {
return PartnerParams(
jobId: self.jobId, userId: self.userId, jobType: self.jobType, extras: partnerParams
jobId: self.jobId, userId: self.userId, jobType: self.jobType, extras: extras
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ final class SelfieCaptureViewModel: ObservableObject, JobSubmittable, Confirmati
private var userId: String
private var jobId: String
private var isEnroll: Bool
private var partnerParams: [String: String]
private var extraPartnerParams: [String: String]
private var shouldSubmitJob: Bool
private (set) var showAttribution: Bool
internal var selfieImage: Data?
Expand Down Expand Up @@ -136,7 +136,7 @@ final class SelfieCaptureViewModel: ObservableObject, JobSubmittable, Confirmati
userId: String,
jobId: String,
isEnroll: Bool,
partnerParams: [String: String] = [:],
extraPartnerParams: [String: String] = [:],
allowsAgentMode: Bool = false,
showAttribution: Bool = true,
cameraManager: CameraManageable? = nil,
Expand All @@ -146,7 +146,7 @@ final class SelfieCaptureViewModel: ObservableObject, JobSubmittable, Confirmati
self.userId = userId
self.isEnroll = isEnroll
self.jobId = jobId
self.partnerParams = partnerParams
self.extraPartnerParams = extraPartnerParams
self.shouldSubmitJob = shouldSubmitJob
self.showAttribution = showAttribution
self.allowsAgentMode = allowsAgentMode
Expand Down Expand Up @@ -431,7 +431,7 @@ final class SelfieCaptureViewModel: ObservableObject, JobSubmittable, Confirmati

SmileID.api.authenticate(request: authRequest)
.flatMap { authResponse in
self.prepUpload(authResponse: authResponse, partnerParams: self.partnerParams)
self.prepUpload(authResponse: authResponse, extraPartnerParams: self.extraPartnerParams)
.flatMap { prepUploadResponse in
self.upload(prepUploadResponse, zip: zip)
.filter { result in
Expand Down
30 changes: 15 additions & 15 deletions Sources/SmileID/Classes/SmileID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,22 @@ public class SmileID {
/// - showAttribution: Whether to show the Smile ID attribution or not on the Instructions
/// screen
/// - showInstructions: Whether to deactivate capture screen's instructions for SmartSelfie.
/// - partnerParams: Custom values specific to partners
/// - extraPartnerParams: Custom values specific to partners
/// - delegate: Callback to be invoked when the SmartSelfie™ Enrollment is complete.
public class func smartSelfieEnrollmentScreen(
userId: String = generateUserId(),
jobId: String = generateJobId(),
allowAgentMode: Bool = false,
showAttribution: Bool = true,
showInstructions: Bool = true,
partnerParams: [String: String] = [:],
extraPartnerParams: [String: String] = [:],
delegate: SmartSelfieResultDelegate
) -> some View {
let viewModel = SelfieCaptureViewModel(
userId: userId,
jobId: jobId,
isEnroll: true,
partnerParams: partnerParams,
extraPartnerParams: extraPartnerParams,
allowsAgentMode: allowAgentMode,
showAttribution: showAttribution
)
Expand All @@ -156,22 +156,22 @@ public class SmileID {
/// - showAttribution: Whether to show the Smile ID attribution or not on the Instructions
/// screen
/// - showInstructions: Whether to deactivate capture screen's instructions for SmartSelfie.
/// - partnerParams: Custom values specific to partners
/// - extraPartnerParams: Custom values specific to partners
/// - delegate: Callback to be invoked when the SmartSelfie™ Authentication is complete.
public class func smartSelfieAuthenticationScreen(
userId: String,
jobId: String = generateJobId(),
allowAgentMode: Bool = false,
showAttribution: Bool = true,
showInstructions: Bool = true,
partnerParams: [String: String] = [:],
extraPartnerParams: [String: String] = [:],
delegate: SmartSelfieResultDelegate
) -> some View {
let viewModel = SelfieCaptureViewModel(
userId: userId,
jobId: jobId,
isEnroll: false,
partnerParams: partnerParams,
extraPartnerParams: extraPartnerParams,
allowsAgentMode: allowAgentMode,
showAttribution: showAttribution
)
Expand Down Expand Up @@ -202,7 +202,7 @@ public class SmileID {
/// - showInstructions: Whether to deactivate capture screen's instructions for Document
/// Verification (NB! If instructions are disabled, gallery upload won't be possible)
/// - showAttribution: Whether to show the Smile ID attribution on the Instructions screen
/// - partnerParams: Custom values specific to partners
/// - extraPartnerParams: Custom values specific to partners
/// - delegate: The delegate object that receives the result of the Document Verification
public class func documentVerificationScreen(
userId: String = generateUserId(),
Expand All @@ -216,7 +216,7 @@ public class SmileID {
allowGalleryUpload: Bool = false,
showInstructions: Bool = true,
showAttribution: Bool = true,
partnerParams: [String: String] = [:],
extraPartnerParams: [String: String] = [:],
delegate: DocumentVerificationResultDelegate
) -> some View {
OrchestratedDocumentVerificationScreen(
Expand All @@ -231,7 +231,7 @@ public class SmileID {
allowGalleryUpload: allowGalleryUpload,
allowAgentMode: allowAgentMode,
showInstructions: showInstructions,
partnerParams: partnerParams,
extraPartnerParams: extraPartnerParams,
onResult: delegate
).environmentObject(router)
}
Expand Down Expand Up @@ -260,7 +260,7 @@ public class SmileID {
/// - showInstructions: Whether to deactivate capture screen's instructions for Document
/// Verification (NB! If instructions are disabled, gallery upload won't be possible)
/// - showAttribution: Whether to show the Smile ID attribution on the Instructions screen
/// - partnerParams: Custom values specific to partners
/// - extraPartnerParams: Custom values specific to partners
/// - delegate: The delegate object that receives the result of the Document Verification
public class func enhancedDocumentVerificationScreen(
userId: String = generateUserId(),
Expand All @@ -274,7 +274,7 @@ public class SmileID {
allowGalleryUpload: Bool = false,
showInstructions: Bool = true,
showAttribution: Bool = true,
partnerParams: [String: String] = [:],
extraPartnerParams: [String: String] = [:],
delegate: EnhancedDocumentVerificationResultDelegate
) -> some View {
OrchestratedEnhancedDocumentVerificationScreen(
Expand All @@ -289,7 +289,7 @@ public class SmileID {
allowGalleryUpload: allowGalleryUpload,
allowAgentMode: allowAgentMode,
showInstructions: showInstructions,
partnerParams: partnerParams,
extraPartnerParams: extraPartnerParams,
onResult: delegate
).environmentObject(router)
}
Expand All @@ -314,7 +314,7 @@ public class SmileID {
/// the front camera will be used.
/// - showAttribution: Whether to show the Smile ID attribution on the Instructions screen
/// - showInstructions: Whether to deactivate capture screen's instructions for SmartSelfie.
/// - partnerParams: Custom values specific to partners
/// - extraPartnerParams: Custom values specific to partners
/// - delegate: Callback to be invoked when the Biometric KYC is complete.
public class func biometricKycScreen(
partnerIcon: UIImage,
Expand All @@ -327,7 +327,7 @@ public class SmileID {
allowAgentMode: Bool = false,
showAttribution: Bool = true,
showInstructions: Bool = true,
partnerParams: [String: String] = [:],
extraPartnerParams: [String: String] = [:],
delegate: BiometricKycResultDelegate
) -> some View {
OrchestratedBiometricKycScreen(
Expand All @@ -341,7 +341,7 @@ public class SmileID {
showInstructions: showInstructions,
showAttribution: showAttribution,
allowAgentMode: allowAgentMode,
partnerParams: partnerParams,
extraPartnerParams: extraPartnerParams,
delegate: delegate
)
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/SmileID/Classes/Views/JobSubmittable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ protocol JobSubmittable {
) -> AnyPublisher<UploadResponse, Error>
func prepUpload(
authResponse: AuthenticationResponse,
partnerParams: [String: String]
extraPartnerParams: [String: String]
) -> AnyPublisher<PrepUploadResponse, Error>
func handleRetry()
func handleClose()
Expand All @@ -19,10 +19,10 @@ protocol JobSubmittable {
extension JobSubmittable {
func prepUpload(
authResponse: AuthenticationResponse,
partnerParams: [String: String]
extraPartnerParams: [String: String]
) -> AnyPublisher<PrepUploadResponse, Error> {
let prepUploadRequest = PrepUploadRequest(
partnerParams: authResponse.partnerParams.copy(partnerParams: partnerParams),
partnerParams: authResponse.partnerParams.copy(extras: extraPartnerParams),
timestamp: authResponse.timestamp,
signature: authResponse.signature
)
Expand Down

0 comments on commit 705ea54

Please sign in to comment.