• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hyperwallet / hyperwallet-ios-ui-sdk / 4735069856

pending completion
4735069856

push

github

Gustavo Meyer
DTPOMERSER-84 - Address swift lint

2255 of 2353 relevant lines covered (95.84%)

17.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.45
/TransferMethodRepository/Sources/PrepaidCardRepository.swift
1
import HyperwalletSDK
2

3
///  Prepaid Card repository protocol
4
public protocol PrepaidCardRepository {
5
    /// List Prepaid cards
6
    func listPrepaidCards(queryParam: HyperwalletPrepaidCardQueryParam,
7
                          completion: @escaping (Result<HyperwalletPageList<HyperwalletPrepaidCard>?,
8
    HyperwalletErrorType>) -> Void)
9

10
    /// Get Prepaid card
11
    func getPrepaidCard(token: String, completion: @escaping (Result < HyperwalletPrepaidCard?,
12
        HyperwalletErrorType>) -> Void)
13

14
    /// Refreshes Prepaid Card
15
    func refreshPrepaidCard()
16

17
    /// Refreshes Prepaid Cards
18
    func refreshPrepaidCards()
19
}
20

21
/// Prepaid Card repository
22
public final class RemotePrepaidCardRepository: PrepaidCardRepository {
23
    var prepaidCardPageList: HyperwalletPageList<HyperwalletPrepaidCard>?
24
    var prepaidCard: HyperwalletPrepaidCard?
25

26
    public func listPrepaidCards(queryParam: HyperwalletPrepaidCardQueryParam,
27
                                 completion: @escaping (Result<HyperwalletPageList<HyperwalletPrepaidCard>?,
28
    HyperwalletErrorType>) -> Void) {
30✔
29
        if prepaidCardPageList == nil {
30✔
30
            Hyperwallet.shared.listPrepaidCards(queryParam: queryParam,
30✔
31
                                                completion: listPrepaidCardHandler(completion))
30✔
32
        } else {
30✔
33
            completion(.success(prepaidCardPageList))
×
34
        }
30✔
35
    }
30✔
36

37
    public func getPrepaidCard(token: String,
38
                               completion: @escaping (Result < HyperwalletPrepaidCard?,
39
    HyperwalletErrorType>) -> Void) {
3✔
40
        if prepaidCard == nil {
3✔
41
            Hyperwallet.shared.getPrepaidCard(transferMethodToken: token, completion: getPrepaidCardHandler(completion))
3✔
42
        } else {
3✔
43
            completion(.success(prepaidCard))
×
44
        }
3✔
45
    }
3✔
46

47
    /// Refreshes Prepaid Card
48
    public func refreshPrepaidCard() {
4✔
49
        prepaidCard = nil
4✔
50
    }
4✔
51

52
    /// Refreshes Prepaid Cards
53
    public func refreshPrepaidCards() {
4✔
54
        prepaidCardPageList = nil
4✔
55
    }
4✔
56

57
    private func getPrepaidCardHandler(
58
            _ completion: @escaping (Result < HyperwalletPrepaidCard?,
59
            HyperwalletErrorType>) -> Void)
60
                    -> (HyperwalletPrepaidCard?, HyperwalletErrorType?) -> Void {
3✔
61
        return { (result, error) in
3✔
62
            if let error = error {
3✔
63
                DispatchQueue.main.async {
2✔
64
                    completion(.failure(error))
2✔
65
                }
2✔
66
            } else {
3✔
67
                DispatchQueue.main.async {
1✔
68
                    completion(.success(result))
1✔
69
                    self.prepaidCard = result
1✔
70
                }
1✔
71
            }
3✔
72
        }
3✔
73
    }
3✔
74

75
    private func listPrepaidCardHandler(
76
            _ completion: @escaping (Result<HyperwalletPageList<HyperwalletPrepaidCard>?,
77
            HyperwalletErrorType>) -> Void)
78
                    -> (HyperwalletPageList<HyperwalletPrepaidCard>?, HyperwalletErrorType?) -> Void {
30✔
79
        return { (result, error) in
30✔
80
            if let error = error {
29✔
81
                DispatchQueue.main.async {
13✔
82
                    completion(.failure(error))
13✔
83
                }
13✔
84
            } else {
29✔
85
                DispatchQueue.main.async {
16✔
86
                    completion(.success(result))
16✔
87
                    self.prepaidCardPageList = result
16✔
88
                }
16✔
89
            }
29✔
90
        }
29✔
91
    }
30✔
92

93
    private func setUpPrepaidCardQueryParam() -> HyperwalletPrepaidCardQueryParam {
×
94
        let queryParam = HyperwalletPrepaidCardQueryParam()
×
95
        // Only fetch active prepaid cards
×
96
        queryParam.status = HyperwalletPrepaidCardQueryParam.QueryStatus.activated.rawValue
×
97
        return queryParam
×
98
    }
×
99
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc