Skip to content

Commit

Permalink
Lints and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vanshg committed Oct 13, 2023
1 parent f886070 commit d7e85c1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sdk-primary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Danger
uses: docker://ghcr.io/danger/danger-swift-with-swiftlint:3.15.0
uses: docker://ghcr.io/danger/danger-swift-with-swiftlint:3.17.1
with:
args: --failOnErrors --no-publish-check
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class TextDetector {
onDetectionResult(false)
return
}
if let error = error {
print("Text Detection Error: \(error)")
}

let recognisedString = observations.compactMap { $0.topCandidates(1).first?.string }

Expand Down
15 changes: 13 additions & 2 deletions Sources/SmileID/Classes/Networking/Models/JobStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public typealias DocumentVerificationJobStatusResponse =
public typealias EnhancedDocumentVerificationJobStatusResponse =
JobStatusResponse<EnhancedDocumentVerificationJobResult>

public class JobStatusResponse<T: JobResult>: Codable {
public final class JobStatusResponse<T: JobResult>: Codable {
public let timestamp: String
public let jobComplete: Bool
public let jobSuccess: Bool
Expand All @@ -36,7 +36,18 @@ public class JobStatusResponse<T: JobResult>: Codable {
public let history: [T]?
public let imageLinks: ImageLinks?

required public init(from decoder: Decoder) throws {
internal init(jobComplete: Bool = true) {
self.jobComplete = jobComplete
timestamp = ""
jobSuccess = true
code = "0"
result = nil
resultString = nil
history = nil
imageLinks = nil
}

public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
timestamp = try container.decode(String.self, forKey: .timestamp)
jobComplete = try container.decode(Bool.self, forKey: .jobComplete)
Expand Down
3 changes: 1 addition & 2 deletions Sources/SmileID/Classes/Networking/SmileIDService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ extension SmileIDServiceable {
attemptCount += 1

return SmileID.api.getJobStatus(request: request)
.delay(for: .seconds(interval), scheduler: RunLoop.main)
// swiftlint:disable force_cast
.map { response in response as! JobStatusResponse<T> }
// swiftlint:disable force_cast
// swiftlint:enable force_cast
.flatMap { response -> AnyPublisher<JobStatusResponse<T>, Error> in
if response.jobComplete {
return Just(response).setFailureType(to: Error.self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public struct SelfieCaptureView: View, SelfieViewDelegate {
}
}
.overlay(ZStack {
if (showBackButton) {
if showBackButton {
NavigationBar {
viewModel.resetState()
viewModel.pauseCameraSession()
Expand Down
2 changes: 1 addition & 1 deletion Tests/Mocks/NetworkingMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class MockSmileIdentityService: SmileIDServiceable {
func getJobStatus<T: JobResult>(
request _: JobStatusRequest
) -> AnyPublisher<JobStatusResponse<T>, Error> {
let response = try! JobStatusResponse<T>(from: JSONDecoder() as! Decoder)
let response = try! JobStatusResponse<T>(jobComplete: MockHelper.jobComplete)
if MockHelper.shouldFail {
return Fail(error: SmileIDError.request(URLError(.resourceUnavailable)))
.eraseToAnyPublisher()
Expand Down

0 comments on commit d7e85c1

Please sign in to comment.