Skip to content

Commit

Permalink
Merge pull request #269 from tangem/IOS-3438_filter_by_max_fw
Browse files Browse the repository at this point in the history
Filter cards by firmware
  • Loading branch information
tureck1y authored Apr 15, 2023
2 parents 54c9cf7 + ee756b3 commit 6558d79
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions TangemSdk/TangemSdk/Common/CardFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public struct CardFilter {

/// Use this filter to configure issuers allowed to work with your app
public var issuerFilter: ItemFilter? = nil

/// Use this filter to configure the highest firmware version allowed to work with your app. Nil to allow all versions.
public var maxFirmwareVersion: FirmwareVersion? = nil

/// Custom error localized description
public var localizedDescription: String? = nil
Expand All @@ -32,6 +35,11 @@ public struct CardFilter {
}

public func verifyCard(_ card: Card) throws {
if let maxFirmwareVersion = maxFirmwareVersion,
card.firmwareVersion > maxFirmwareVersion {
throw wrongCardError
}

if !allowedCardTypes.contains(card.firmwareVersion.type) {
throw wrongCardError
}
Expand Down

0 comments on commit 6558d79

Please sign in to comment.