• 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

98.78
/Sources/Hyperwallet.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
/// The `Hyperwallet` class is an iOS specific implementation of the
22
/// [Hyperwallet platform User APIs.](https://portal.hyperwallet.com/docs)
23
///
24
/// A single instance of the `Hyperwallet` class is maintained. Resetting the current instance by calling
25
/// `setup(_: HyperwalletAuthenticationTokenProvider)` is critical when switching between authenticated Users.
26
/// Failure to do so will result in incorrect access and incorrect modifications to User data.
27
///
28
/// Authentication with the Hyperwallet platform is accomplished through the usage of JSON Web Tokens. At
29
/// instantiation an `HyperwalletAuthenticationTokenProvider` is set as a member variable to provide
30
/// the `Hyperwallet` class with an authentication token upon request.
31
@objcMembers
32
public final class Hyperwallet: NSObject {
33
    private var httpTransaction: HTTPTransaction!
34
    private static var instance: Hyperwallet?
35
    private var provider: HyperwalletAuthenticationTokenProvider
36

37
    /// Returns the previously initialized instance of the Hyperwallet Core SDK interface object
38
    public static var shared: Hyperwallet {
88✔
39
        guard let instance = instance else {
88✔
40
            fatalError("Call Hyperwallet.setup(_:) before accessing Hyperwallet.shared")
×
41
        }
88✔
42
        return instance
88✔
43
    }
88✔
44

45
    private init(_ provider: HyperwalletAuthenticationTokenProvider) {
5✔
46
        self.provider = provider
5✔
47
        self.httpTransaction = HTTPTransaction(provider: provider)
5✔
48
    }
5✔
49

50
    /// Clears Hyperwallet instance.
51
    public static func clearInstance() {
5✔
52
        if let httpTransaction = instance?.httpTransaction {
5✔
53
            httpTransaction.invalidate()
4✔
54
        }
4✔
55
        instance = nil
5✔
56
    }
5✔
57

58
    /// Creates a new instance of the Hyperwallet Core SDK interface object. If a previously created instance exists,
59
    /// it will be replaced.
60
    ///
61
    /// - Parameter provider: a provider of Hyperwallet authentication tokens.
62
    public static func setup(_ provider: HyperwalletAuthenticationTokenProvider) {
94✔
63
        if instance == nil {
94✔
64
            instance = Hyperwallet(provider)
5✔
65
        }
5✔
66
    }
94✔
67

68
    /// Retrieves a configuration if one exists - else using the authentication token from the provider,
69
    /// it tries to fetch the configuration object again and returns it else error
70
    ///
71
    /// - Parameter completion: the callback handler of responses from the Hyperwallet platform
72
    public func getConfiguration(completion: @escaping (Configuration?, HyperwalletErrorType?) -> Void ) {
4✔
73
        if let configuration = httpTransaction.configuration {
4✔
74
            completion(configuration, nil)
2✔
75
        } else {
2✔
76
            provider.retrieveAuthenticationToken(
2✔
77
                completionHandler: retrieveAuthenticationTokenResponseHandler(completion: completion))
2✔
78
        }
2✔
79
    }
4✔
80

81
    /// Returns the `HyperwalletUser` for the User associated with the authentication token returned from
82
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)` or nil
83
    /// if none exists.
84
    ///
85
    /// The `completion: @escaping (HyperwalletUser?, HyperwalletErrorType?) -> Void` that is passed in to
86
    /// this method invocation will receive the successful response(HyperwalletUser) or error(HyperwalletErrorType)
87
    /// from processing the request.
88
    ///
89
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
90
    /// if the current one is expired or is about to expire.
91
    ///
92
    /// - Parameter completion: the callback handler of responses from the Hyperwallet platform
93
    public func getUser(completion: @escaping (HyperwalletUser?, HyperwalletErrorType?) -> Void) {
3✔
94
        httpTransaction.performRest(httpMethod: .get,
3✔
95
                                    urlPath: "users/%@",
3✔
96
                                    payload: "",
3✔
97
                                    completionHandler: completion)
3✔
98
    }
3✔
99

100
    /// Creates a `HyperwalletBankAccount` for the User associated with the authentication token returned from
101
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
102
    ///
103
    /// The `completion: @escaping (HyperwalletBankAccount?, HyperwalletErrorType?) -> Void` that is passed in to this
104
    /// method invocation will receive the successful response(HyperwalletBankAccount) or error(HyperwalletErrorType)
105
    /// from processing the request.
106
    ///
107
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
108
    /// if the current one is expired or is about to expire.
109
    ///
110
    /// - Parameters:
111
    ///   - account: the `HyperwalletBankAccount` to be created
112
    ///   - completion: the callback handler of responses from the Hyperwallet platform
113
    public func createBankAccount(account: HyperwalletBankAccount,
114
                                  completion: @escaping (HyperwalletBankAccount?, HyperwalletErrorType?) -> Void) {
5✔
115
        httpTransaction.performRest(httpMethod: .post,
5✔
116
                                    urlPath: "users/%@/bank-accounts",
5✔
117
                                    payload: account,
5✔
118
                                    completionHandler: completion)
5✔
119
    }
5✔
120

121
    /// Creates a `HyperwalletPaperCheck` for the User associated with the authentication token returned from
122
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
123
    ///
124
    /// The `completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void`
125
    /// that is passed in to this method invocation will receive the successful response(HyperwalletPaperCheck)
126
    /// or error(HyperwalletErrorType) from processing the request.
127
    ///
128
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
129
    /// if the current one is expired or is about to expire.
130
    ///
131
    /// - Parameters:
132
    ///   - account: the `HyperwalletPaperCheck` to be created
133
    ///   - completion: the callback handler of responses from the Hyperwallet platform
134
    public func createPaperCheck(
135
        account: HyperwalletPaperCheck,
136
        completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void) {
3✔
137
        httpTransaction.performRest(httpMethod: .post,
3✔
138
                                    urlPath: "users/%@/paper-checks",
3✔
139
                                    payload: account,
3✔
140
                                    completionHandler: completion)
3✔
141
    }
3✔
142

143
    /// Creates a `HyperwalletBankCard` for the User associated with the authentication token returned from
144
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
145
    ///
146
    /// The `completion: @escaping (HyperwalletBankCard?, HyperwalletErrorType?) -> Void` that is passed in to this
147
    /// method invocation will receive the successful response(HyperwalletBankCard) or error(HyperwalletErrorType)
148
    /// from processing the request.
149
    ///
150
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
151
    /// if the current one is expired or is about to expire.
152
    ///
153
    /// @param bankCard
154
    /// @param listener
155
    ///
156
    /// - Parameters:
157
    ///   - account: the `HyperwalletBankCard` to be created
158
    ///   - completion: the callback handler of responses from the Hyperwallet platform
159
    public func createBankCard(account: HyperwalletBankCard,
160
                               completion: @escaping (HyperwalletBankCard?, HyperwalletErrorType?) -> Void) {
2✔
161
        httpTransaction.performRest(httpMethod: .post,
2✔
162
                                    urlPath: "users/%@/bank-cards",
2✔
163
                                    payload: account,
2✔
164
                                    completionHandler: completion)
2✔
165
    }
2✔
166

167
    /// Creates a `HyperwalletPayPalAccount` for the User associated with the authentication token returned from
168
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
169
    ///
170
    /// The `completion: @escaping (HyperwalletPayPalAccount?, HyperwalletErrorType?) -> Void` that is passed in to this
171
    /// method invocation will receive the successful response(HyperwalletPayPalAccount) or error(HyperwalletErrorType)
172
    /// from processing the request.
173
    ///
174
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
175
    /// if the current one is expired or is about to expire.
176
    ///
177
    /// - Parameters:
178
    ///   - account: the `HyperwalletPayPalAccount` to be created
179
    ///   - completion: the callback handler of responses from the Hyperwallet platform
180
    public func createPayPalAccount(account: HyperwalletPayPalAccount,
181
                                    completion: @escaping (HyperwalletPayPalAccount?, HyperwalletErrorType?) -> Void) {
3✔
182
        httpTransaction.performRest(httpMethod: .post,
3✔
183
                                    urlPath: "users/%@/paypal-accounts",
3✔
184
                                    payload: account,
3✔
185
                                    completionHandler: completion)
3✔
186
    }
3✔
187

188
    /// Creates a `HyperwalletTransfer` for the User associated with the authentication token returned from
189
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
190
    ///
191
    /// The `completion: @escaping (HyperwalletTransfer?, HyperwalletErrorType?) -> Void` that is passed in to this
192
    /// method invocation will receive the successful response(HyperwalletTransfer) or error(HyperwalletErrorType)
193
    /// from processing the request.
194
    ///
195
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
196
    /// if the current one is expired or is about to expire.
197
    ///
198
    /// - Parameters:
199
    ///   - transfer: the `HyperwalletTransfer` to be created
200
    ///   - completion: the callback handler of responses from the Hyperwallet platform
201
    public func createTransfer(transfer: HyperwalletTransfer,
202
                               completion: @escaping (HyperwalletTransfer?, HyperwalletErrorType?) -> Void) {
2✔
203
        httpTransaction.performRest(httpMethod: .post,
2✔
204
                                    urlPath: "transfers",
2✔
205
                                    payload: transfer,
2✔
206
                                    completionHandler: completion)
2✔
207
    }
2✔
208

209
    /// Creates a `HyperwalletVenmoAccount` for the User associated with the authentication token returned from
210
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
211
    ///
212
    /// The `completion: @escaping (HyperwalletVenmoAccount?, HyperwalletErrorType?) -> Void` that is passed in to this
213
    /// method invocation will receive the successful response(HyperwalletVenmoAccount) or error(HyperwalletErrorType)
214
    /// from processing the request.
215
    ///
216
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
217
    /// if the current one is expired or is about to expire.
218
    ///
219
    /// - Parameters:
220
    ///   - account: the `HyperwalletVenmoAccount` to be created
221
    ///   - completion: the callback handler of responses from the Hyperwallet platform
222
    public func createVenmoAccount(account: HyperwalletVenmoAccount,
223
                                   completion: @escaping (HyperwalletVenmoAccount?, HyperwalletErrorType?) -> Void) {
3✔
224
        httpTransaction.performRest(httpMethod: .post,
3✔
225
                                    urlPath: "users/%@/venmo-accounts",
3✔
226
                                    payload: account,
3✔
227
                                    completionHandler: completion)
3✔
228
    }
3✔
229

230
    /// Deactivates the `HyperwalletBankAccount` linked to the transfer method token specified. The
231
    /// `HyperwalletBankAccount` being deactivated must belong to the User that is associated with the
232
    /// authentication token returned from
233
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
234
    ///
235
    /// The `completion: @escaping (HyperwalletStatusTransition?, HyperwalletErrorType?) -> Void` that is passed in to
236
    /// this method invocation will receive the successful response(HyperwalletStatusTransition) or
237
    /// error(HyperwalletErrorType) from processing the request.
238
    ///
239
    /// This function will request a new authentication token via  HyperwalletAuthenticationTokenProvider`
240
    /// if the current one is expired or is about to expire.
241
    ///
242
    /// - Parameters:
243
    ///   - transferMethodToken: the Hyperwallet specific unique identifier for the `HyperwalletBankAccount`
244
    ///                          being deactivated
245
    ///   - notes: a note regarding the status change
246
    ///   - completion: the callback handler of responses from the Hyperwallet platform
247
    public func deactivateBankAccount(transferMethodToken: String,
248
                                      notes: String? = nil,
249
                                      completion: @escaping (HyperwalletStatusTransition?,
250
                                                             HyperwalletErrorType?) -> Void) {
2✔
251
        let statusTransition = HyperwalletStatusTransition.Builder(notes: notes, transition: .deactivated).build()
2✔
252
        httpTransaction.performRest(httpMethod: .post,
2✔
253
                                    urlPath: "users/%@/bank-accounts/\(transferMethodToken)/status-transitions",
2✔
254
                                    payload: statusTransition,
2✔
255
                                    completionHandler: completion)
2✔
256
    }
2✔
257

258
    /// Deactivates the `HyperwalletPaperCheck` linked to the transfer method token specified. The
259
    /// `HyperwalletPaperCheck` being deactivated must belong to the User that is associated with the
260
    /// authentication token returned from
261
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
262
    ///
263
    /// The `completion: @escaping (HyperwalletStatusTransition?, HyperwalletErrorType?) -> Void` that is passed in to
264
    /// this method invocation will receive the successful response(HyperwalletStatusTransition) or
265
    /// error(HyperwalletErrorType) from processing the request.
266
    ///
267
    /// This function will request a new authentication token via  HyperwalletAuthenticationTokenProvider`
268
    /// if the current one is expired or is about to expire.
269
    ///
270
    /// - Parameters:
271
    ///   - transferMethodToken: the Hyperwallet specific unique identifier for the `HyperwalletPaperCheck`
272
    ///                          being deactivated
273
    ///   - notes: a note regarding the status change
274
    ///   - completion: the callback handler of responses from the Hyperwallet platform
275
    public func deactivatePaperCheck(transferMethodToken: String,
276
                                     notes: String? = nil,
277
                                     completion: @escaping (HyperwalletStatusTransition?,
278
                                                             HyperwalletErrorType?) -> Void) {
2✔
279
        let statusTransition = HyperwalletStatusTransition.Builder(notes: notes, transition: .deactivated).build()
2✔
280
        httpTransaction.performRest(httpMethod: .post,
2✔
281
                                    urlPath: "users/%@/paper-checks/\(transferMethodToken)/status-transitions",
2✔
282
                                    payload: statusTransition,
2✔
283
                                    completionHandler: completion)
2✔
284
    }
2✔
285

286
    /// Deactivates the `HyperwalletBankCard` linked to the transfer method token specified. The
287
    /// `HyperwalletBankCard` being deactivated must belong to the User that is associated with the
288
    /// authentication token returned from
289
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
290
    ///
291
    /// The `completion: @escaping (HyperwalletStatusTransition?, HyperwalletErrorType?) -> Void` that is passed in to
292
    /// this method invocation will receive the successful response(HyperwalletStatusTransition) or
293
    /// error(HyperwalletErrorType) from processing the request.
294
    ///
295
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
296
    /// if the current one is expired or is about to expire.
297
    ///
298
    /// - Parameters:
299
    ///   - transferMethodToken: the Hyperwallet specific unique identifier for the `HyperwalletBankCard`
300
    ///                          being deactivated
301
    ///   - notes: a note regarding the status change
302
    ///   - completion: the callback handler of responses from the Hyperwallet platform
303
    public func deactivateBankCard(transferMethodToken: String,
304
                                   notes: String? = nil,
305
                                   completion: @escaping (HyperwalletStatusTransition?,
306
                                                          HyperwalletErrorType?) -> Void) {
2✔
307
        let statusTransition = HyperwalletStatusTransition.Builder(notes: notes, transition: .deactivated).build()
2✔
308
        httpTransaction.performRest(httpMethod: .post,
2✔
309
                                    urlPath: "users/%@/bank-cards/\(transferMethodToken)/status-transitions",
2✔
310
                                    payload: statusTransition,
2✔
311
                                    completionHandler: completion)
2✔
312
    }
2✔
313

314
    /// Deactivates the `HyperwalletPayPalAccount` linked to the transfer method token specified. The
315
    /// `HyperwalletPayPalAccount` being deactivated must belong to the User that is associated with the
316
    /// authentication token returned from
317
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
318
    ///
319
    /// The `completion: @escaping (HyperwalletStatusTransition?, HyperwalletErrorType?) -> Void` that is passed in to
320
    /// this method invocation will receive the successful response(HyperwalletStatusTransition) or
321
    /// error(HyperwalletErrorType) from processing the request.
322
    ///
323
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
324
    /// if the current one is expired or is about to expire.
325
    ///
326
    /// - Parameters:
327
    ///   - transferMethodToken: the Hyperwallet specific unique identifier for the `HyperwalletPayPalAccount`
328
    ///                          being deactivated
329
    ///   - notes: a note regarding the status change
330
    ///   - completion: the callback handler of responses from the Hyperwallet platform
331
    public func deactivatePayPalAccount(transferMethodToken: String,
332
                                        notes: String? = nil,
333
                                        completion: @escaping (HyperwalletStatusTransition?,
334
                                                               HyperwalletErrorType?) -> Void) {
2✔
335
        let statusTransition = HyperwalletStatusTransition.Builder(notes: notes, transition: .deactivated).build()
2✔
336
        httpTransaction.performRest(httpMethod: .post,
2✔
337
                                    urlPath: "users/%@/paypal-accounts/\(transferMethodToken)/status-transitions",
2✔
338
                                    payload: statusTransition,
2✔
339
                                    completionHandler: completion)
2✔
340
    }
2✔
341

342
    /// Deactivates the `HyperwalletVenmoAccount` linked to the transfer method token specified. The
343
    /// `HyperwalletVenmoAccount` being deactivated must belong to the User that is associated with the
344
    /// authentication token returned from
345
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
346
    ///
347
    /// The `completion: @escaping (HyperwalletStatusTransition?, HyperwalletErrorType?) -> Void` that is passed in to
348
    /// this method invocation will receive the successful response(HyperwalletStatusTransition) or
349
    /// error(HyperwalletErrorType) from processing the request.
350
    ///
351
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
352
    /// if the current one is expired or is about to expire.
353
    ///
354
    /// - Parameters:
355
    ///   - transferMethodToken: the Hyperwallet specific unique identifier for the `HyperwalletVenmoAccount`
356
    ///                          being deactivated
357
    ///   - notes: a note regarding the status change
358
    ///   - completion: the callback handler of responses from the Hyperwallet platform
359
    public func deactivateVenmoAccount(transferMethodToken: String,
360
                                       notes: String? = nil,
361
                                       completion: @escaping (HyperwalletStatusTransition?,
362
                                                              HyperwalletErrorType?) -> Void) {
2✔
363
        let statusTransition = HyperwalletStatusTransition.Builder(notes: notes, transition: .deactivated).build()
2✔
364
        httpTransaction.performRest(httpMethod: .post,
2✔
365
                                    urlPath: "users/%@/venmo-accounts/\(transferMethodToken)/status-transitions",
2✔
366
                                    payload: statusTransition,
2✔
367
                                    completionHandler: completion)
2✔
368
    }
2✔
369

370
    /// Schedules the `HyperwalletTransfer` linked to the transfer method token specified.
371
    ///
372
    /// The `completion: @escaping (HyperwalletStatusTransition?, HyperwalletErrorType?) -> Void` that is passed in to
373
    /// this method invocation will receive the successful response(HyperwalletStatusTransition) or
374
    /// error(HyperwalletErrorType) from processing the request.
375
    ///
376
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
377
    /// if the current one is expired or is about to expire.
378
    ///
379
    /// - Parameters:
380
    ///   - transferToken: the Hyperwallet specific unique identifier for the `HyperwalletTransfer`
381
    ///                    being commited
382
    ///   - notes: a note regarding the status change
383
    ///   - completion: the callback handler of responses from the Hyperwallet platform
384
    public func scheduleTransfer(transferToken: String,
385
                                 notes: String? = nil,
386
                                 completion: @escaping (HyperwalletStatusTransition?, HyperwalletErrorType?) -> Void) {
1✔
387
        let statusTransition = HyperwalletStatusTransition.Builder(notes: notes, transition: .scheduled).build()
1✔
388
        httpTransaction.performRest(httpMethod: .post,
1✔
389
                                    urlPath: "transfers/\(transferToken)/status-transitions",
1✔
390
                                    payload: statusTransition,
1✔
391
                                    completionHandler: completion)
1✔
392
    }
1✔
393

394
    /// Returns the `HyperwalletBankAccount` linked to the transfer method token specified, or nil if none exists.
395
    ///
396
    /// The `completion: @escaping (HyperwalletBankAccount?, HyperwalletErrorType?) -> Void` that is passed in to this
397
    /// method invocation will receive the successful response(HyperwalletBankAccount) or error(HyperwalletErrorType)
398
    /// from processing the request.
399
    ///
400
    /// - Parameters:
401
    ///   - transferMethodToken: the Hyperwallet specific unique identifier for the `HyperwalletBankAccount`
402
    ///                          being requested
403
    ///   - completion: the callback handler of responses from the Hyperwallet platform
404
    public func getBankAccount(transferMethodToken: String,
405
                               completion: @escaping (HyperwalletBankAccount?, HyperwalletErrorType?) -> Void) {
1✔
406
        httpTransaction.performRest(httpMethod: .get,
1✔
407
                                    urlPath: "users/%@/bank-accounts/\(transferMethodToken)",
1✔
408
                                    payload: "",
1✔
409
                                    completionHandler: completion)
1✔
410
    }
1✔
411

412
    /// Returns the `HyperwalletPaperCheck` linked to the transfer method token specified, or nil if none exists.
413
    ///
414
    /// The `completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void`
415
    /// that is passed in to this method invocation will receive the successful response(HyperwalletPaperCheck)
416
    /// or error(HyperwalletErrorType) from processing the request.
417
    ///
418
    /// - Parameters:
419
    ///   - transferMethodToken: the Hyperwallet specific unique identifier for the `HyperwalletPaperCheck`
420
    ///                          being requested
421
    ///   - completion: the callback handler of responses from the Hyperwallet platform
422
    public func getPaperCheck(
423
        transferMethodToken: String,
424
        completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void) {
1✔
425
        httpTransaction.performRest(httpMethod: .get,
1✔
426
                                    urlPath: "users/%@/paper-checks/\(transferMethodToken)",
1✔
427
                                    payload: "",
1✔
428
                                    completionHandler: completion)
1✔
429
    }
1✔
430

431
    /// Returns the `HyperwalletBankCard` linked to the transfer method token specified, or nil if none exists.
432
    ///
433
    /// The `completion: @escaping (HyperwalletBankCard?, HyperwalletErrorType?) -> Void` that is passed in to
434
    /// this method invocation will receive the successful response(HyperwalletBankCard) or error(HyperwalletErrorType)
435
    /// from processing the request.
436
    ///
437
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
438
    /// if the current one is expired or is about to expire.
439
    ///
440
    /// - Parameters:
441
    ///   - transferMethodToken: the Hyperwallet specific unique identifier for the `HyperwalletBankCard`
442
    ///                          being requested
443
    ///   - completion: the callback handler of responses from the Hyperwallet platform
444
    public func getBankCard(transferMethodToken: String,
445
                            completion: @escaping (HyperwalletBankCard?, HyperwalletErrorType?) -> Void) {
1✔
446
        httpTransaction.performRest(httpMethod: .get,
1✔
447
                                    urlPath: "users/%@/bank-cards/\(transferMethodToken)",
1✔
448
                                    payload: "",
1✔
449
                                    completionHandler: completion)
1✔
450
    }
1✔
451

452
    /// Returns the `HyperwalletPayPalAccount` linked to the transfer method token specified, or nil if none exists.
453
    ///
454
    /// The `completion: @escaping (HyperwalletPayPalAccount?, HyperwalletErrorType?) -> Void` that is passed in to this
455
    /// method invocation will receive the successful response(HyperwalletPayPalAccount) or error(HyperwalletErrorType)
456
    /// from processing the request.
457
    ///
458
    /// - Parameters:
459
    ///   - transferMethodToken: the Hyperwallet specific unique identifier for the `HyperwalletPayPalAccount`
460
    ///                          being requested
461
    ///   - completion: the callback handler of responses from the Hyperwallet platform
462
    public func getPayPalAccount(transferMethodToken: String,
463
                                 completion: @escaping (HyperwalletPayPalAccount?, HyperwalletErrorType?) -> Void) {
1✔
464
        httpTransaction.performRest(httpMethod: .get,
1✔
465
                                    urlPath: "users/%@/paypal-accounts/\(transferMethodToken)",
1✔
466
                                    payload: "",
1✔
467
                                    completionHandler: completion)
1✔
468
    }
1✔
469

470
    /// Returns the `HyperwalletPrepaidCard` linked to the transfer method token specified, or nil if none exists.
471
    ///
472
    /// The `completion: @escaping (HyperwalletPrepaidCard?, HyperwalletErrorType?) -> Void` that is passed in to
473
    /// this method invocation will receive the successful response(HyperwalletPrepaidCard) or
474
    /// error(HyperwalletErrorType) from processing the request.
475
    ///
476
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
477
    /// if the current one is expired or is about to expire.
478
    ///
479
    /// - Parameters:
480
    ///   - transferMethodToken: the Hyperwallet specific unique identifier for the `HyperwalletPrepaidCard`
481
    ///                          being requested
482
    ///   - completion: the callback handler of responses from the Hyperwallet platform
483
    public func getPrepaidCard(transferMethodToken: String,
484
                               completion: @escaping (HyperwalletPrepaidCard?, HyperwalletErrorType?) -> Void) {
1✔
485
        httpTransaction.performRest(httpMethod: .get,
1✔
486
                                    urlPath: "users/%@/prepaid-cards/\(transferMethodToken)",
1✔
487
                                    payload: "",
1✔
488
                                    completionHandler: completion)
1✔
489
    }
1✔
490

491
    /// Returns the `HyperwalletTransfer` linked to the transfer method token specified, or nil if none exists.
492
    ///
493
    /// The `completion: @escaping (HyperwalletTransfer?, HyperwalletErrorType?) -> Void` that is passed in to this
494
    /// method invocation will receive the successful response(HyperwalletTransfer) or error(HyperwalletErrorType)
495
    /// from processing the request.
496
    ///
497
    /// - Parameters:
498
    ///   - transferToken: the Hyperwallet specific unique identifier for the `HyperwalletTransfer`
499
    ///                    being requested
500
    ///   - completion: the callback handler of responses from the Hyperwallet platform
501
    public func getTransfer(transferToken: String,
502
                            completion: @escaping (HyperwalletTransfer?, HyperwalletErrorType?) -> Void) {
1✔
503
        httpTransaction.performRest(httpMethod: .get,
1✔
504
                                    urlPath: "transfers/\(transferToken)",
1✔
505
                                    payload: "",
1✔
506
                                    completionHandler: completion)
1✔
507
    }
1✔
508

509
    /// Returns the `HyperwalletVenmoAccount` linked to the transfer method token specified, or nil if none exists.
510
    ///
511
    /// The `completion: @escaping (HyperwalletVenmoAccount?, HyperwalletErrorType?) -> Void` that is passed in to this
512
    /// method invocation will receive the successful response(HyperwalletVenmoAccount) or error(HyperwalletErrorType)
513
    /// from processing the request.
514
    ///
515
    /// - Parameters:
516
    ///   - transferMethodToken: the Hyperwallet specific unique identifier for the `HyperwalletVenmoAccount`
517
    ///                          being requested
518
    ///   - completion: the callback handler of responses from the Hyperwallet platform
519
    public func getVenmoAccount(transferMethodToken: String,
520
                                completion: @escaping (HyperwalletVenmoAccount?, HyperwalletErrorType?) -> Void) {
1✔
521
        httpTransaction.performRest(httpMethod: .get,
1✔
522
                                    urlPath: "users/%@/venmo-accounts/\(transferMethodToken)",
1✔
523
                                    payload: "",
1✔
524
                                    completionHandler: completion)
1✔
525
    }
1✔
526

527
    /// Returns the list of `HyperwalletBankAccount`s for the User associated with the authentication token
528
    /// returned from
529
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`,
530
    /// or nil if non exist.
531
    ///
532
    /// The ordering and filtering of `HyperwalletBankAccount`s will be based on the criteria specified within
533
    /// the `HyperwalletBankAccountQueryParam` object, if it is not nil. Otherwise the default ordering and
534
    /// filtering will be applied:
535
    ///
536
    /// * Offset: 0
537
    /// * Limit: 10
538
    /// * Created Before: N/A
539
    /// * Created After: N/A
540
    /// * Type: Bank Account
541
    /// * Status: All
542
    /// * Sort By: Created On
543
    ///
544
    /// The `completion: @escaping (HyperwalletPageList<HyperwalletBankAccount>?, HyperwalletErrorType?) -> Void` that
545
    /// is passed in to this method invocation will receive the successful
546
    /// response(HyperwalletPageList<HyperwalletBankAccount>?) or error(HyperwalletErrorType) from processing the
547
    /// request.
548
    ///
549
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
550
    /// if the current one is expired or is about to expire.
551
    ///
552
    /// - Parameters:
553
    ///   - queryParam: the ordering and filtering criteria
554
    ///   - completion: the callback handler of responses from the Hyperwallet platform
555
    public func listBankAccounts(queryParam: HyperwalletBankAccountQueryParam? = nil,
556
                                 completion: @escaping (HyperwalletPageList<HyperwalletBankAccount>?,
557
        HyperwalletErrorType?) -> Void) {
2✔
558
        httpTransaction.performRest(httpMethod: .get,
2✔
559
                                    urlPath: "users/%@/bank-accounts",
2✔
560
                                    payload: "",
2✔
561
                                    queryParam: queryParam,
2✔
562
                                    completionHandler: completion)
2✔
563
    }
2✔
564

565
    /// Returns the list of `HyperwalletPaperCheck`s for the User associated with the authentication token
566
    /// returned from
567
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`,
568
    /// or nil if non exist.
569
    ///
570
    /// The ordering and filtering of `HyperwalletPaperCheck`s will be based on the criteria specified within
571
    /// the `HyperwalletPaperCheckQueryParam` object, if it is not nil. Otherwise the default ordering and
572
    /// filtering will be applied:
573
    ///
574
    /// * Offset: 0
575
    /// * Limit: 10
576
    /// * Created Before: N/A
577
    /// * Created After: N/A
578
    /// * Type: Paper Check
579
    /// * Status: All
580
    /// * Sort By: Created On
581
    ///
582
    /// The `completion: @escaping (HyperwalletPageList<HyperwalletPaperCheck>?, HyperwalletErrorType?) -> Void`
583
    /// that is passed in to this method invocation will receive the successful
584
    /// response(HyperwalletPageList<HyperwalletPaperCheck>?) or error(HyperwalletErrorType) from processing the
585
    /// request.
586
    ///
587
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
588
    /// if the current one is expired or is about to expire.
589
    ///
590
    /// - Parameters:
591
    ///   - queryParam: the ordering and filtering criteria
592
    ///   - completion: the callback handler of responses from the Hyperwallet platform
593
    public func listPaperChecks(queryParam: HyperwalletPaperCheckQueryParam? = nil,
594
                                completion: @escaping (HyperwalletPageList<HyperwalletPaperCheck>?,
595
        HyperwalletErrorType?) -> Void) {
2✔
596
        httpTransaction.performRest(httpMethod: .get,
2✔
597
                                    urlPath: "users/%@/paper-checks",
2✔
598
                                    payload: "",
2✔
599
                                    queryParam: queryParam,
2✔
600
                                    completionHandler: completion)
2✔
601
    }
2✔
602

603
    /// Returns the `HyperwalletBankCard` for the User associated with the authentication token returned from
604
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`,
605
    /// or nil if non exist.
606
    ///
607
    /// The ordering and filtering of `HyperwalletBankCard` will be based on the criteria specified within the
608
    /// `HyperwalletBankAccountQueryParam` object, if it is not nil. Otherwise the default ordering and
609
    /// filtering will be applied.
610
    ///
611
    /// * Offset: 0
612
    /// * Limit: 10
613
    /// * Created Before: N/A
614
    /// * Created After: N/A
615
    /// * Type: Bank Card
616
    /// * Status: All
617
    /// * Sort By: Created On
618
    ///
619
    /// The `completion: @escaping (HyperwalletPageList<HyperwalletBankCard>?, HyperwalletErrorType?) -> Void` that is
620
    /// passed in to this method invocation will receive the successful
621
    /// response(HyperwalletPageList<HyperwalletBankCard>?) or error(HyperwalletErrorType) from processing the request.
622
    ///
623
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
624
    /// if the current one is expired or is about to expire.
625
    ///
626
    /// - Parameters:
627
    ///   - queryParam: the ordering and filtering criteria
628
    ///   - completion: the callback handler of responses from the Hyperwallet platform
629
    public func listBankCards(queryParam: HyperwalletBankCardQueryParam? = nil,
630
                              completion: @escaping (HyperwalletPageList<HyperwalletBankCard>?,
631
                                                     HyperwalletErrorType?) -> Void) {
2✔
632
        httpTransaction.performRest(httpMethod: .get,
2✔
633
                                    urlPath: "users/%@/bank-cards",
2✔
634
                                    payload: "",
2✔
635
                                    queryParam: queryParam,
2✔
636
                                    completionHandler: completion)
2✔
637
    }
2✔
638

639
    /// Returns the `HyperwalletPayPalAccount` for the User associated with the authentication token returned from
640
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`,
641
    /// or nil if non exist.
642
    ///
643
    /// The ordering and filtering of `HyperwalletPayPalAccount` will be based on the criteria specified within the
644
    /// `HyperwalletPayPalAccountQueryParam` object, if it is not nil. Otherwise the default ordering and
645
    /// filtering will be applied.
646
    ///
647
    /// * Offset: 0
648
    /// * Limit: 10
649
    /// * Created Before: N/A
650
    /// * Created After: N/A
651
    /// * Status: All
652
    /// * Sort By: Created On
653
    ///
654
    /// The `completion: @escaping (HyperwalletPageList<HyperwalletPayPalAccount>?, HyperwalletErrorType?) -> Void`
655
    /// that is passed in to this method invocation will receive the successful
656
    /// response(HyperwalletPageList<HyperwalletPayPalAccount>?) or error(HyperwalletErrorType) from processing the
657
    /// request.
658
    ///
659
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
660
    /// if the current one is expired or is about to expire.
661
    ///
662
    /// - Parameters:
663
    ///   - queryParam: the ordering and filtering criteria
664
    ///   - completion: the callback handler of responses from the Hyperwallet platform
665
    public func listPayPalAccounts(queryParam: HyperwalletPayPalAccountQueryParam? = nil,
666
                                   completion: @escaping (HyperwalletPageList<HyperwalletPayPalAccount>?,
667
                                                          HyperwalletErrorType?) -> Void) {
2✔
668
        httpTransaction.performRest(httpMethod: .get,
2✔
669
                                    urlPath: "users/%@/paypal-accounts",
2✔
670
                                    payload: "",
2✔
671
                                    queryParam: queryParam,
2✔
672
                                    completionHandler: completion)
2✔
673
    }
2✔
674

675
    /// Returns the `HyperwalletTransferMethod` (Bank Account, Bank Card, PayPay Account, Prepaid Card, Paper Checks)
676
    /// for the User associated with the authentication token returned from
677
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`,
678
    /// or nil if non exist.
679
    ///
680
    /// The ordering and filtering of `HyperwalletBankCard` will be based on the criteria specified within the
681
    /// `HyperwalletBankAccountQueryParam` object, if it is not nil. Otherwise the default ordering and
682
    /// filtering will be applied.
683
    ///
684
    /// * Offset: 0
685
    /// * Limit: 10
686
    /// * Created Before: N/A
687
    /// * Created After: N/A
688
    /// * Type: All
689
    /// * Status: All
690
    /// * Sort By: Created On
691
    ///
692
    /// The `completion: @escaping (HyperwalletPageList<HyperwalletTransferMethod>?, HyperwalletErrorType?) -> Void`
693
    /// that is passed in to this method invocation will receive the successful
694
    /// response(HyperwalletPageList<HyperwalletTransferMethod>?) or error(HyperwalletErrorType) from processing
695
    /// the request.
696
    ///
697
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
698
    /// if the current one is expired or is about to expire.
699
    ///
700
    /// - Parameters:
701
    ///   - queryParam: the ordering and filtering criteria
702
    ///   - completion: the callback handler of responses from the Hyperwallet platform
703
    public func listTransferMethods(queryParam: HyperwalletTransferMethodQueryParam? = nil,
704
                                    completion: @escaping (HyperwalletPageList<HyperwalletTransferMethod>?,
705
        HyperwalletErrorType?) -> Void) {
2✔
706
        httpTransaction.performRest(httpMethod: .get,
2✔
707
                                    urlPath: "users/%@/transfer-methods",
2✔
708
                                    payload: "",
2✔
709
                                    queryParam: queryParam,
2✔
710
                                    completionHandler: completion)
2✔
711
    }
2✔
712

713
    /// Returns the `HyperwalletPrepaidCard`
714
    /// for the User associated with the authentication token returned from
715
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`,
716
    /// or nil if non exist.
717
    ///
718
    /// The ordering and filtering of `HyperwalletPrepaidCard` will be based on the criteria specified within the
719
    /// `HyperwalletPrepaidCardQueryParam` object, if it is not nil. Otherwise the default ordering and
720
    /// filtering will be applied.
721
    ///
722
    /// * Offset: 0
723
    /// * Limit: 10
724
    /// * Created Before: N/A
725
    /// * Created After: N/A
726
    /// * Status: All
727
    /// * Sort By: Created On
728
    ///
729
    /// The `completion: @escaping (HyperwalletPageList<HyperwalletPrepaidCard>?, HyperwalletErrorType?) -> Void`
730
    /// that is passed in to this method invocation will receive the successful
731
    /// response(HyperwalletPageList<HyperwalletPrepaidCard>?) or error(HyperwalletErrorType) from processing
732
    /// the request.
733
    ///
734
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
735
    /// if the current one is expired or is about to expire.
736
    ///
737
    /// - Parameters:
738
    ///   - queryParam: the ordering and filtering criteria
739
    ///   - completion: the callback handler of responses from the Hyperwallet platform
740
    public func listPrepaidCards(queryParam: HyperwalletPrepaidCardQueryParam? = nil,
741
                                 completion: @escaping (HyperwalletPageList<HyperwalletPrepaidCard>?,
742
        HyperwalletErrorType?) -> Void) {
2✔
743
        httpTransaction.performRest(httpMethod: .get,
2✔
744
                                    urlPath: "users/%@/prepaid-cards",
2✔
745
                                    payload: "",
2✔
746
                                    queryParam: queryParam,
2✔
747
                                    completionHandler: completion)
2✔
748
    }
2✔
749

750
    /// Returns the `HyperwalletVenmoAccount` for the User associated with the authentication token returned from
751
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`,
752
    /// or nil if non exist.
753
    ///
754
    /// The ordering and filtering of `HyperwalletVenmoAccount` will be based on the criteria specified within the
755
    /// `HyperwalletVenmoQueryParam` object, if it is not nil. Otherwise the default ordering and
756
    /// filtering will be applied.
757
    ///
758
    /// * Offset: 0
759
    /// * Limit: 10
760
    /// * Created Before: N/A
761
    /// * Created After: N/A
762
    /// * Status: All
763
    /// * Sort By: Created On
764
    ///
765
    /// The `completion: @escaping (HyperwalletPageList<HyperwalletVenmoAccount>?, HyperwalletErrorType?) -> Void`
766
    /// that is passed in to this method invocation will receive the successful
767
    /// response(HyperwalletPageList<HyperwalletVenmoAccount>?) or error(HyperwalletErrorType) from processing the
768
    /// request.
769
    ///
770
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
771
    /// if the current one is expired or is about to expire.
772
    ///
773
    /// - Parameters:
774
    ///   - queryParam: the ordering and filtering criteria
775
    ///   - completion: the callback handler of responses from the Hyperwallet platform
776
    public func listVenmoAccounts(queryParam: HyperwalletVenmoQueryParam? = nil,
777
                                  completion: @escaping (HyperwalletPageList<HyperwalletVenmoAccount>?,
778
                                                         HyperwalletErrorType?) -> Void) {
2✔
779
        httpTransaction.performRest(httpMethod: .get,
2✔
780
                                    urlPath: "users/%@/venmo-accounts",
2✔
781
                                    payload: "",
2✔
782
                                    queryParam: queryParam,
2✔
783
                                    completionHandler: completion)
2✔
784
    }
2✔
785

786
    /// Returns the list of receipts for the User associated with the authentication token.
787
    ///
788
    /// The ordering and filtering of `HyperwalletReceipt` will be based on the criteria specified within the
789
    /// `HyperwalletReceiptQueryParam` object, if it is not nil. Otherwise the default ordering and
790
    /// filtering will be applied.
791
    ///
792
    /// * Offset: 0
793
    /// * Limit: 10
794
    /// * Created Before: N/A
795
    /// * Created After: N/A
796
    /// * Currency: All
797
    /// * Sort By: Created On
798
    ///
799
    /// The `completion: @escaping (HyperwalletPageList<HyperwalletReceipt>?, HyperwalletErrorType?) -> Void`
800
    /// that is passed in to this method invocation will receive the successful
801
    /// response(HyperwalletPageList<HyperwalletReceipt>?) or error(HyperwalletErrorType) from processing
802
    /// the request.
803
    ///
804
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
805
    /// if the current one is expired or is about to expire.
806
    ///
807
    /// - Parameters:
808
    ///   - queryParam: the ordering and filtering criteria
809
    ///   - completion: the callback handler of responses from the Hyperwallet platform
810
    public func listUserReceipts(queryParam: HyperwalletReceiptQueryParam? = nil,
811
                                 completion: @escaping (HyperwalletPageList<HyperwalletReceipt>?,
812
        HyperwalletErrorType?) -> Void) {
1✔
813
        httpTransaction.performRest(httpMethod: .get,
1✔
814
                                    urlPath: "users/%@/receipts",
1✔
815
                                    payload: "",
1✔
816
                                    queryParam: queryParam,
1✔
817
                                    completionHandler: completion)
1✔
818
    }
1✔
819

820
    // Returns the list of receipts for the User associated with the Prepaid card token.
821
    ///
822
    /// The filtering of `HyperwalletReceipt` will be based on the criteria specified within the
823
    /// `HyperwalletReceiptQueryParam` object. CreatedAfter needs to be provided to get the receipts.
824
    /// Receipts are returned sorted in ascending order of creation date
825
    ///
826
    /// * Created Before: N/A
827
    /// * Created After: “Some Date”
828
    /// * Currency: All
829
    ///
830
    /// The `completion: @escaping (HyperwalletPageList<HyperwalletReceipt>?, HyperwalletErrorType?) -> Void`
831
    /// that is passed in to this method invocation will receive the successful
832
    /// response(HyperwalletPageList<HyperwalletReceipt>?) or error(HyperwalletErrorType) from processing
833
    /// the request.
834
    ///
835
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
836
    /// if the current one is expired or is about to expire.
837
    ///
838
    /// - Parameters:
839
    ///   - queryParam: the ordering and filtering criteria
840
    ///   - completion: the callback handler of responses from the Hyperwallet platform
841
    public func listPrepaidCardReceipts(prepaidCardToken: String,
842
                                        queryParam: HyperwalletReceiptQueryParam? = nil,
843
                                        completion: @escaping (HyperwalletPageList<HyperwalletReceipt>?,
844
        HyperwalletErrorType?) -> Void) {
1✔
845
        httpTransaction.performRest(httpMethod: .get,
1✔
846
                                    urlPath: "users/%@/prepaid-cards/\(prepaidCardToken)/receipts",
1✔
847
                                    payload: "",
1✔
848
                                    queryParam: queryParam,
1✔
849
                                    completionHandler: completion)
1✔
850
    }
1✔
851

852
    /// Returns the list of transfers for the User associated with the authentication token.
853
    ///
854
    /// The ordering and filtering of `HyperwalletTransfer` will be based on the criteria specified within the
855
    /// `HyperwalletTransferQueryParam` object, if it is not nil. Otherwise the default ordering and
856
    /// filtering will be applied.
857
    ///
858
    /// * Offset: 0
859
    /// * Limit: 10
860
    /// * Created Before: N/A
861
    /// * Created After: N/A
862
    /// * clientTransferId: N/A
863
    /// * destinationToken: N/A
864
    /// * sourceToken: N/A
865
    ///
866
    /// The `completion: @escaping (HyperwalletPageList<HyperwalletTransfer>?, HyperwalletErrorType?) -> Void`
867
    /// that is passed in to this method invocation will receive the successful
868
    /// response(HyperwalletPageList<HyperwalletTransfer>?) or error(HyperwalletErrorType) from processing
869
    /// the request.
870
    ///
871
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
872
    /// if the current one is expired or is about to expire.
873
    ///
874
    /// - Parameters:
875
    ///   - queryParam: the ordering and filtering criteria
876
    ///   - completion: the callback handler of responses from the Hyperwallet platform
877
    public func listTransfers(queryParam: HyperwalletTransferQueryParam? = nil,
878
                              completion: @escaping (HyperwalletPageList<HyperwalletTransfer>?,
879
        HyperwalletErrorType?) -> Void) {
2✔
880
        httpTransaction.performRest(httpMethod: .get,
2✔
881
                                    urlPath: "transfers",
2✔
882
                                    payload: "",
2✔
883
                                    queryParam: queryParam,
2✔
884
                                    completionHandler: completion)
2✔
885
    }
2✔
886

887
    /// Returns the transfer method configuration field set for the User that is associated with the authentication
888
    /// token returned from
889
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
890
    ///
891
    /// The `completion: @escaping (HyperwalletTransferMethodConfigurationField?, HyperwalletErrorType?) -> Void`
892
    /// that is passed in to this method invocation will receive the successful
893
    /// response(HyperwalletTransferMethodConfigurationField) or error(HyperwalletErrorType) from processing the
894
    /// request.
895
    ///
896
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
897
    /// if the current one is expired or is about to expire.
898
    ///
899
    /// - Parameters:
900
    ///   - request: containing a transfer method configuration key tuple of country, currency,
901
    ///              transfer method type and profile
902
    ///   - completion: the callback handler of responses from the Hyperwallet platform
903
    public func retrieveTransferMethodConfigurationFields(
904
        request: HyperwalletTransferMethodConfigurationFieldQuery,
905
        completion: @escaping (HyperwalletTransferMethodConfigurationField?, HyperwalletErrorType?) -> Void) {
1✔
906
        httpTransaction.performGraphQl(request,
1✔
907
                                       completionHandler: transferMethodConfigurationFieldResponseHandler(completion))
1✔
908
    }
1✔
909

910
    /// Returns the transfer method update configuration fields set for the User that is associated with
911
    /// the authentication token returned from
912
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
913
    ///
914
    /// The `completion: @escaping (HyperwalletTransferMethodUpdateConfigurationField?, HyperwalletErrorType?) -> Void`
915
    /// that is passed in to this method invocation will receive the successful
916
    /// response(HyperwalletTransferMethodUpdateConfigurationField) or error(HyperwalletErrorType) from processing the
917
    /// request.
918
    ///
919
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
920
    /// if the current one is expired or is about to expire.
921
    ///
922
    /// - Parameters:
923
    ///   - request: GraphQL query  containing  transfer method token  and required configuration fields
924
    ///   - completion: the callback handler of responses from the Hyperwallet platform
925
    public func retrieveTransferMethodUpdateConfigurationFields(
926
        request: HyperwalletTransferMethodUpdateConfigurationFieldQuery,
927
        completion: @escaping (HyperwalletTransferMethodUpdateConfigurationField?, HyperwalletErrorType?) -> Void) {
4✔
928
        httpTransaction.performGraphQl(request, completionHandler:
4✔
929
            transferMethodUpdateConfigurationFiledResponseHandler(completion))
4✔
930
    }
4✔
931

932
    /// Returns the transfer method configuration key set for the User that is associated
933
    /// with the authentication token returned from
934
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
935
    ///
936
    /// The `completion: @escaping (HyperwalletTransferMethodConfigurationKey?, HyperwalletErrorType?) -> Void`
937
    /// that is passed in to this method invocation will receive the successful
938
    /// response(HyperwalletTransferMethodConfigurationKey) or error(HyperwalletErrorType) from processing the
939
    /// request.
940
    ///
941
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
942
    /// if the current one is expired or is about to expire.
943
    ///
944
    /// - Parameters:
945
    ///   - request: containing the transfer method configuration key query
946
    ///   - completion: the callback handler of responses from the Hyperwallet platform
947
    public func retrieveTransferMethodConfigurationKeys(
948
        request: HyperwalletTransferMethodConfigurationKeysQuery,
949
        completion: @escaping (HyperwalletTransferMethodConfigurationKey?, HyperwalletErrorType?) -> Void) {
2✔
950
        httpTransaction.performGraphQl(request,
2✔
951
                                       completionHandler: transferMethodConfigurationKeyResponseHandler(completion))
2✔
952
    }
2✔
953

954
    /// Returns the transfer method types, processing times, and fees for the User that is associated
955
    /// with the authentication token returned from
956
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
957
    ///
958
    /// The `completion: @escaping (HyperwalletTransferMethodConfigurationKey?, HyperwalletErrorType?) -> Void`
959
    /// that is passed in to this method invocation will receive the successful
960
    /// response(HyperwalletTransferMethodConfigurationKey) or
961
    /// error(HyperwalletErrorType) from processing the
962
    /// request.
963
    ///
964
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
965
    /// if the current one is expired or is about to expire.
966
    ///
967
    /// - Parameters:
968
    ///   - request: containing the transfer method configuration key query
969
    ///   - completion: the callback handler of responses from the Hyperwallet platform
970
    public func retrieveTransferMethodTypesFeesAndProcessingTimes(
971
        request: HyperwalletTransferMethodTypesFeesAndProcessingTimesQuery,
972
        completion: @escaping (HyperwalletTransferMethodConfigurationKey?,
973
                               HyperwalletErrorType?) -> Void) {
1✔
974
        httpTransaction.performGraphQl(request,
1✔
975
                                       completionHandler: transferMethodConfigurationKeyResponseHandler(completion))
1✔
976
    }
1✔
977

978
    /// Updates the `HyperwalletBankAccount` for the User associated with the authentication token returned from
979
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
980
    ///
981
    /// To identify the `HyperwalletBankAccount` that is going to be updated, the transfer method token must be
982
    /// set as part of the `HyperwalletBankAccount` object passed in.
983
    ///
984
    /// The `completion: @escaping (HyperwalletBankAccount?, HyperwalletErrorType?) -> Void` that is passed in to this
985
    /// method invocation will receive the successful response(HyperwalletBankAccount) or error(HyperwalletErrorType)
986
    /// from processing the request.
987
    ///
988
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
989
    /// if the current one is expired or is about to expire.
990
    ///
991
    /// - parameters: account: the `HyperwalletBankAccount` to be updated
992
    /// - parameters: completion: the callback handler of responses from the Hyperwallet platform
993
    public func updateBankAccount(account: HyperwalletBankAccount,
994
                                  completion: @escaping (HyperwalletBankAccount?, HyperwalletErrorType?) -> Void) {
2✔
995
        let token = account.token ?? ""
2✔
996
        httpTransaction.performRest(httpMethod: .put,
2✔
997
                                    urlPath: "users/%@/bank-accounts/\(token)",
2✔
998
                                    payload: account,
2✔
999
                                    completionHandler: completion)
2✔
1000
    }
2✔
1001

1002
    /// Updates the `HyperwalletPaperCheck` for the User associated with the authentication token returned from
1003
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
1004
    ///
1005
    /// To identify the `HyperwalletPaperCheck` that is going to be updated, the transfer method token must be
1006
    /// set as part of the `HyperwalletPaperCheck` object passed in.
1007
    ///
1008
    /// The `completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void`
1009
    /// that is passed in to this method invocation will receive the successful response(HyperwalletPaperCheck)
1010
    /// or error(HyperwalletErrorType) from processing the request.
1011
    ///
1012
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
1013
    /// if the current one is expired or is about to expire.
1014
    ///
1015
    /// - parameters: account: the `HyperwalletPaperCheck` to be updated
1016
    /// - parameters: completion: the callback handler of responses from the Hyperwallet platform
1017
    public func updatePaperCheck(
1018
        account: HyperwalletPaperCheck,
1019
        completion: @escaping (HyperwalletPaperCheck?, HyperwalletErrorType?) -> Void) {
2✔
1020
        let token = account.token ?? ""
2✔
1021
        httpTransaction.performRest(httpMethod: .put,
2✔
1022
                                    urlPath: "users/%@/paper-checks/\(token)",
2✔
1023
                                    payload: account,
2✔
1024
                                    completionHandler: completion)
2✔
1025
    }
2✔
1026

1027
    /// Updates the `HyperwalletBankCard` for the User associated with the authentication token returned from
1028
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
1029
    ///
1030
    /// To identify the `HyperwalletBankCard` that is going to be updated, the transfer method token must be
1031
    /// set as part of the `HyperwalletBankCard` object passed in.
1032
    ///
1033
    /// The `completion: @escaping (HyperwalletBankCard?, HyperwalletErrorType?) -> Void` that is passed in to this
1034
    /// method invocation will receive the successful response(HyperwalletBankCard) or error(HyperwalletErrorType) from
1035
    /// processing the request.
1036
    ///
1037
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
1038
    /// if the current one is expired or is about to expire.
1039
    ///
1040
    /// - Parameters:
1041
    ///   - account: the `HyperwalletBankCard` to be updated
1042
    ///   - completion: the callback handler of responses from the Hyperwallet platform
1043
    public func updateBankCard(account: HyperwalletBankCard,
1044
                               completion: @escaping (HyperwalletBankCard?, HyperwalletErrorType?) -> Void) {
2✔
1045
        let token = account.token ?? ""
2✔
1046
        httpTransaction.performRest(httpMethod: .put,
2✔
1047
                                    urlPath: "users/%@/bank-cards/\(token)",
2✔
1048
                                    payload: account,
2✔
1049
                                    completionHandler: completion)
2✔
1050
    }
2✔
1051

1052
    /// Updates the `HyperwalletPayPalAccount` for the User associated with the authentication token returned from
1053
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
1054
    ///
1055
    /// To identify the `HyperwalletPayPalAccount` that is going to be updated, the transfer method token must be
1056
    /// set as part of the `HyperwalletPayPalAccount` object passed in.
1057
    ///
1058
    /// The `completion: @escaping (HyperwalletPayPalAccount?, HyperwalletErrorType?) -> Void` that is passed in to this
1059
    /// method invocation will receive the successful response(HyperwalletPayPalAccount) or error(HyperwalletErrorType)
1060
    /// from processing the request.
1061
    ///
1062
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
1063
    /// if the current one is expired or is about to expire.
1064
    ///
1065
    /// - Parameters:
1066
    ///   - account: the `HyperwalletPayPalAccount` to be updated
1067
    ///   - completion: the callback handler of responses from the Hyperwallet platform
1068
    public func updatePayPalAccount(account: HyperwalletPayPalAccount,
1069
                                    completion: @escaping (HyperwalletPayPalAccount?, HyperwalletErrorType?) -> Void) {
2✔
1070
        let token = account.token ?? ""
2✔
1071
        httpTransaction.performRest(httpMethod: .put,
2✔
1072
                                    urlPath: "users/%@/paypal-accounts/\(token)",
2✔
1073
                                    payload: account,
2✔
1074
                                    completionHandler: completion)
2✔
1075
    }
2✔
1076

1077
    /// Updates the `HyperwalletVenmoAccount` for the User associated with the authentication token returned from
1078
    /// `HyperwalletAuthenticationTokenProvider.retrieveAuthenticationToken(_ : @escaping CompletionHandler)`.
1079
    ///
1080
    /// To identify the `HyperwalletVenmoAccount` that is going to be updated, the transfer method token must be
1081
    /// set as part of the `HyperwalletVenmoAccount` object passed in.
1082
    ///
1083
    /// The `completion: @escaping (HyperwalletVenmoAccount?, HyperwalletErrorType?) -> Void` that is passed in to this
1084
    /// method invocation will receive the successful response(HyperwalletVenmoAccount) or error(HyperwalletErrorType)
1085
    /// from processing the request.
1086
    ///
1087
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
1088
    /// if the current one is expired or is about to expire.
1089
    ///
1090
    /// - Parameters:
1091
    ///   - account: the `HyperwalletVenmoAccount` to be updated
1092
    ///   - completion: the callback handler of responses from the Hyperwallet platform
1093
    public func updateVenmoAccount(account: HyperwalletVenmoAccount,
1094
                                   completion: @escaping (HyperwalletVenmoAccount?, HyperwalletErrorType?) -> Void) {
2✔
1095
        let token = account.token ?? ""
2✔
1096
        httpTransaction.performRest(httpMethod: .put,
2✔
1097
                                    urlPath: "users/%@/venmo-accounts/\(token)",
2✔
1098
                                    payload: account,
2✔
1099
                                    completionHandler: completion)
2✔
1100
    }
2✔
1101

1102
    /// Returns the list of balances for the User associated with the authentication token.
1103
    ///
1104
    /// The ordering and filtering of `HyperwalletBalance` will be based on the criteria specified within the
1105
    /// `HyperwalletBalanceQueryParam` object, if it is not nil. Otherwise the default ordering and
1106
    /// filtering will be applied.
1107
    ///
1108
    /// * Offset: 0
1109
    /// * Limit: 10
1110
    /// * Currency: All
1111
    /// * Sort By: currency
1112
    ///
1113
    /// The `completion: @escaping (HyperwalletPageList<HyperwalletBalance>?, HyperwalletErrorType?) -> Void`
1114
    /// that is passed in to this method invocation will receive the successful
1115
    /// response(HyperwalletPageList<HyperwalletBalance>?) or error(HyperwalletErrorType) from processing
1116
    /// the request.
1117
    ///
1118
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
1119
    /// if the current one is expired or is about to expire.
1120
    ///
1121
    /// - Parameters:
1122
    ///   - queryParam: the ordering and filtering criteria
1123
    ///   - completion: the callback handler of responses from the Hyperwallet platform
1124
    public func listUserBalances(queryParam: HyperwalletBalanceQueryParam? = nil,
1125
                                 completion: @escaping (HyperwalletPageList<HyperwalletBalance>?,
1126
        HyperwalletErrorType?) -> Void) {
5✔
1127
        httpTransaction.performRest(httpMethod: .get,
5✔
1128
                                    urlPath: "users/%@/balances",
5✔
1129
                                    payload: "",
5✔
1130
                                    queryParam: queryParam,
5✔
1131
                                    completionHandler: completion)
5✔
1132
    }
5✔
1133

1134
    /// Returns the list of prepaid card balances for the User associated with the authentication token.
1135
    ///
1136
    /// The ordering and filtering of `HyperwalletBalance` will be based on the criteria specified within the
1137
    /// `HyperwalletPrepaidCardBalanceQueryParam` object, if it is not nil. Otherwise the default ordering and
1138
    /// filtering will be applied.
1139
    ///
1140
    /// * Offset: 0
1141
    /// * Limit: 10
1142
    /// * Sort By: currency
1143
    ///
1144
    /// The `completion: @escaping (HyperwalletPageList<HyperwalletBalance>?, HyperwalletErrorType?) -> Void`
1145
    /// that is passed in to this method invocation will receive the successful
1146
    /// response(HyperwalletPageList<HyperwalletBalance>?) or error(HyperwalletErrorType) from processing
1147
    /// the request.
1148
    ///
1149
    /// This function will request a new authentication token via `HyperwalletAuthenticationTokenProvider`
1150
    /// if the current one is expired or is about to expire.
1151
    ///
1152
    /// - Parameters:
1153
    ///   - prepaidCardToken: the prepaid card token
1154
    ///   - queryParam: the ordering and filtering criteria
1155
    ///   - completion: the callback handler of responses from the Hyperwallet platform
1156
    public func listPrepaidCardBalances(prepaidCardToken: String,
1157
                                        queryParam: HyperwalletPrepaidCardBalanceQueryParam? = nil,
1158
                                        completion: @escaping (HyperwalletPageList<HyperwalletBalance>?,
1159
                                                               HyperwalletErrorType?) -> Void) {
2✔
1160
        httpTransaction.performRest(httpMethod: .get,
2✔
1161
                                    urlPath: "users/%@/prepaid-cards/\(prepaidCardToken)/balances",
2✔
1162
                                    payload: "",
2✔
1163
                                    queryParam: queryParam,
2✔
1164
                                    completionHandler: completion)
2✔
1165
    }
2✔
1166

1167
    private func transferMethodConfigurationFieldResponseHandler(_ completionHandler:
1168
            @escaping (TransferMethodConfigurationFieldResult?, HyperwalletErrorType?) -> Void)
1169
        -> (TransferMethodConfigurationField?, HyperwalletErrorType?) -> Void { { (response, error) in
1✔
1170
                let result =
1✔
1171
                    TransferMethodConfigurationFieldResult(response?.transferMethodCreateUIConfigurations?.nodes,
1✔
1172
                                                           response?.countries?.nodes?.first)
1✔
1173
                completionHandler(result, error)
1✔
1174
            }
1✔
1175
    }
1✔
1176

1177
    private func transferMethodUpdateConfigurationFiledResponseHandler(_ completionHandler:
1178
            @escaping (TransferMethodUpdateConfigurationFieldResult?, HyperwalletErrorType?) -> Void)
1179
        -> (TransferMethodUpdateConfigurationField?, HyperwalletErrorType?) -> Void { { (response, error) in
4✔
1180
                let result = TransferMethodUpdateConfigurationFieldResult(response?
4✔
1181
                    .transferMethodUpdateUIConfigurations?
4✔
1182
                    .nodes)
4✔
1183
                completionHandler(result, error)
4✔
1184
            }
4✔
1185
    }
4✔
1186

1187
    private func transferMethodConfigurationKeyResponseHandler(_ completionHandler:
1188
            @escaping (TransferMethodConfigurationKeyResult?, HyperwalletErrorType?) -> Void)
1189
        -> (TransferMethodConfigurationKey?, HyperwalletErrorType?) -> Void { { (response, error) in
3✔
1190
                completionHandler(TransferMethodConfigurationKeyResult(response?.countries?.nodes), error)
3✔
1191
            }
3✔
1192
    }
3✔
1193

1194
    private func retrieveAuthenticationTokenResponseHandler(
1195
        completion: @escaping (Configuration?, HyperwalletErrorType?) -> Void)
1196
        -> (String?, Error?) -> Void { {(authenticationToken, error) in
2✔
1197
            guard error == nil else {
2✔
1198
                completion(nil, ErrorTypeHelper.authenticationError(
1✔
1199
                    message: "Error occured while retrieving authentication token",
1✔
1200
                    for: error as? HyperwalletAuthenticationErrorType ?? HyperwalletAuthenticationErrorType
1✔
1201
                        .unexpected("Authentication token cannot be retrieved"))
×
1202
                )
1✔
1203
                return
1✔
1204
            }
1✔
1205
            do {
1✔
1206
                let configuration = try AuthenticationTokenDecoder.decode(from: authenticationToken)
1✔
1207
                self.httpTransaction.configuration = configuration
×
1208
                completion(configuration, nil)
×
1209
            } catch {
1✔
1210
                if let error = error as? HyperwalletErrorType {
1✔
1211
                    completion(nil, error)
1✔
1212
                }
1✔
1213
            }
1✔
1214
        }
1✔
1215
    }
2✔
1216
}
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