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

hyperwallet / hyperwallet-ios-sdk / 15826401626

21 May 2025 02:36PM UTC coverage: 96.705%. Remained the same
15826401626

push

github

web-flow
Initial commit for CodeQL (#152)

* Initial commit for CodeQL

* Updating language

1937 of 2003 relevant lines covered (96.7%)

18.55 hits per line

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

83.05
/Sources/Model/TransferMethod/HyperwalletTransferMethod.swift
1
//
2
// Copyright 2018 - Present Hyperwallet
3
//
4
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software
5
// and associated documentation files (the "Software"), to deal in the Software without restriction,
6
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
7
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
8
// furnished to do so, subject to the following conditions:
9
//
10
// The above copyright notice and this permission notice shall be included in all copies or
11
// substantial portions of the Software.
12
//
13
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
14
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18

19
import Foundation
20

21
/// Representation of the transfer method (bank account, bank card, PayPal account, prepaid card, paper check).
22
@objcMembers
23
public class HyperwalletTransferMethod: NSObject, Codable {
24
    private var storage: [String: AnyCodable]
25

26
    /// Representation of the transfer method's field type
27
    public enum TransferMethodField: String {
28
        // Common transfer method fields
29
        /// The datetime when the transfer method was created on.
30
        case createdOn
31
        /// The transfer method status transition.
32
        case status
33
        /// The transfer method identifier.
34
        case token
35
        /// The transfer method country.
36
        case transferMethodCountry
37
        /// The transfer method currency.
38
        case transferMethodCurrency
39
        /// The transfer method type.
40
        case type
41
        // Bank Account related fields
42
        ///
43
        /// The bank account holder's street address.
44
        case addressLine1
45
        /// The bank account holder's address, second line.
46
        case addressLine2
47
        /// The bank account number, IBAN or equivalent. If you are providing an IBAN,
48
        /// the first two letters of the IBAN must match the `transferMethodCountry`.
49
        case bankAccountId
50
        /// The purpose of the bank account (e.g. checking, savings, etc).
51
        case bankAccountPurpose
52
        /// The user's relationship with the bank account holder.
53
        case bankAccountRelationship
54
        /// The bank code or equivalent (e.g. BIC/SWIFT code).
55
        case bankId
56
        /// The bank name.
57
        case bankName
58
        /// The branch code, transit number, routing number or equivalent.
59
        case branchId
60
        /// The branch name
61
        case branchName
62
        /// The bank account holder's role in the organization.
63
        case businessContactRole
64
        /// The name of the transfer method holder's business
65
        case businessName
66
        /// The country where the transfer method holder's business is registered
67
        case businessRegistrationCountry
68
        /// The bank account holder's business registration number or identifier, as
69
        /// assigned by the relevant government body.
70
        case businessRegistrationId
71
        /// The state, province or region where the bank account holder's business
72
        /// is registered.
73
        case businessRegistrationStateProvince
74
        /// The bank account holder's business type.
75
        case businessType
76
        /// The bank account holder's city.
77
        case city
78
        /// The bank account holder's country.
79
        case country
80
        /// The country where bank account holder born
81
        case countryOfBirth
82
        /// The Nationality of the bank account holder
83
        case countryOfNationality
84
        /// The bank account holder's date of birth.
85
        case dateOfBirth
86
        /// The LicenseId of the bank account holder
87
        case driversLicenseId
88
        /// The employer Id of the bank account holder
89
        case employerId
90
        /// The bank account holder's first name.
91
        case firstName
92
        /// The bank account holder's gender
93
        case gender
94
        /// The bank account holder's government ID number, such as a Social Security Number.
95
        case governmentId
96
        /// The bank account holder's government IdType
97
        case governmentIdType
98
        /// The bank account holder's Intermediary Bank AccountId
99
        case intermediaryBankAccountId
100
        /// The bank account holder's Intermediary Bank AddressLine1
101
        case intermediaryBankAddressLine1
102
        /// The bank account holder's Intermediary Bank AddressLine2
103
        case intermediaryBankAddressLine2
104
        /// The bank account holder's Intermediary Bank's City
105
        case intermediaryBankCity
106
        /// The bank account holder's Intermediary Bank's Country
107
        case intermediaryBankCountry
108
        /// The bank account holder's Intermediary Bank Id
109
        case intermediaryBankId
110
        /// The bank account holder's Intermediary Bank Name
111
        case intermediaryBankName
112
        /// The bank account holder's Intermediary PostalCode:
113
        case intermediaryBankPostalCode
114
        /// The bank account holder's Intermediary Bank's State and Province
115
        case intermediaryBankStateProvince
116
        /// The bank account holder's last name.
117
        case lastName
118
        /// The bank account holder's middle name.
119
        case middleName
120
        /// The bank account holder's mobile number
121
        case mobileNumber
122
        /// The bank account holder's passport Id
123
        case passportId
124
        /// The bank account holder's phone number.
125
        case phoneNumber
126
        /// The bank account holder's postal code.
127
        case postalCode
128
        /// The bank account holder's profile type.
129
        case profileType
130
        /// The bank account holder's state, province or region.
131
        case stateProvince
132
        /// The wire transfer instructions
133
        case wireInstructions
134

135
        // Bank Card related fields
136
        ///
137
        /// The card brand.
138
        case cardBrand
139
        /// The 16-digit card number.
140
        case cardNumber
141
        /// The bank card type.
142
        case cardType
143
        /// The card security code which is embossed or printed on the card.
144
        case cvv
145
        /// The expiration date for the card (YYYY-MM).
146
        case dateOfExpiry
147
        /// The primary card token
148
        case primaryCardToken
149

150
        // PayPal account related fields
151
        ///
152
        /// The email address associated with the PayPal account.
153
        case email
154

155
        // Venmo account related field
156
        ///
157
        /// The mobile number associated with the Venmo account.
158
        case accountId
159

160
        // prepaid card related fields
161
        ///
162
        /// The card's package
163
        case cardPackage
164
        /// The user token
165
        case userToken
166

167
        // Paper check related fields
168
        /// The shipping method
169
        case shippingMethod
170
    }
171

172
    internal init(data: [String: AnyCodable]) {
27✔
173
        self.storage = data
27✔
174
    }
27✔
175

176
    /// Representation of the transfer method's type
177
    public enum TransferMethodType: String {
178
        /// When the transfer method is Bank Account
179
        case bankAccount = "BANK_ACCOUNT"
180
        /// When the transfer method is Bank Card
181
        case bankCard = "BANK_CARD"
182
        /// When the transfer method is PayPal Account
183
        case payPalAccount = "PAYPAL_ACCOUNT"
184
        /// When the transfer method is Wire Account
185
        case wireAccount = "WIRE_ACCOUNT"
186
        /// When the transfer method is Prepaid Card
187
        case prepaidCard = "PREPAID_CARD"
188
        /// When the transfer method is Venmo Account
189
        case venmoAccount = "VENMO_ACCOUNT"
190
        /// when transfer method is paper check
191
        case paperCheck = "PAPER_CHECK"
192
    }
193

194
    /// Creates a new instance of the `HyperwalletTransferMethod`
195
    override public init() {
×
196
        self.storage = [String: AnyCodable]()
×
197
    }
×
198

199
    public required init(from decoder: Decoder) throws {
41✔
200
        let container = try decoder.singleValueContainer()
41✔
201
        let data = try container.decode(Dictionary<String, AnyCodable>.self)
41✔
202
        self.storage = data
41✔
203
    }
41✔
204

205
    public func encode(to encoder: Encoder) throws {
27✔
206
        var container = encoder.container(keyedBy: CodingKeys.self)
27✔
207
        for (key, value) in storage {
243✔
208
            do {
243✔
209
                try container.encode(value, forKey: CodingKeys.make(key: key))
243✔
210
            }
243✔
211
        }
243✔
212
    }
27✔
213

214
    /// Gets the field value
215
    ///
216
    /// - Parameter fieldName: The `TransferMethodField` type raw value
217
    /// - Returns: Returns the field value, or nil if none exists.
218
    public func getField(_ fieldName: String) -> String? {
232✔
219
        self.storage[fieldName]?.value as? String
232✔
220
    }
232✔
221

222
    /// Sets the field value based on the key
223
    ///
224
    /// - Parameters:
225
    ///   - key: The `TransferMethodField.RawValue` value
226
    ///   - value: The value
227
    public func setField(key: TransferMethodField.RawValue, value: String) {
×
228
        storage[key] = AnyCodable(value: value)
×
229
    }
×
230

231
    internal func getFields() -> [String: AnyCodable] {
21✔
232
        self.storage
21✔
233
    }
21✔
234

235
    private struct CodingKeys: CodingKey {
236
        var intValue: Int?
237
        var stringValue: String
238

239
        init?(intValue: Int) {
×
240
            self.intValue = intValue
×
241
            self.stringValue = "\(intValue)"
×
242
        }
×
243

244
        init?(stringValue: String) {
243✔
245
            self.stringValue = stringValue
243✔
246
        }
243✔
247

248
        static func make(key: String) -> CodingKeys {
243✔
249
            CodingKeys(stringValue: key)!
243✔
250
        }
243✔
251
    }
252

253
    /// The transfer method's created time
254
    public var createdOn: String? {
3✔
255
        getField(TransferMethodField.createdOn.rawValue)
3✔
256
    }
3✔
257

258
    /// The transfer method holder's profile type, e.g. INDIVIDUAL or BUSINESS.
259
    public var profileType: String? {
10✔
260
        getField(TransferMethodField.profileType.rawValue)
10✔
261
    }
10✔
262

263
    /// The transfer method's status
264
    public var status: String? {
4✔
265
        getField(TransferMethodField.status.rawValue)
4✔
266
    }
4✔
267

268
    /// The transfer method's token
269
    public var token: String? {
21✔
270
        getField(TransferMethodField.token.rawValue)
21✔
271
    }
21✔
272

273
    /// The transfer method's country
274
    public var transferMethodCountry: String? {
6✔
275
        getField(TransferMethodField.transferMethodCountry.rawValue)
6✔
276
    }
6✔
277

278
    /// The transfer method's currency
279
    public var transferMethodCurrency: String? {
6✔
280
        getField(TransferMethodField.transferMethodCurrency.rawValue)
6✔
281
    }
6✔
282

283
    /// The transfer method's type
284
    public var type: String? {
18✔
285
        getField(TransferMethodField.type.rawValue)
18✔
286
    }
18✔
287
}
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