-
Notifications
You must be signed in to change notification settings - Fork 4
/
ModelDataProvider.swift
594 lines (533 loc) · 28.5 KB
/
ModelDataProvider.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
//
// ModelDataProvider.swift
// AptoSDK
//
// Created by Takeichi Kanzaki on 14/06/2018.
//
//
import Foundation
@testable import AptoSDK
@testable import AptoUISDK
import SwiftyJSON
class ModelDataProvider {
static let provider: ModelDataProvider = ModelDataProvider()
private init() {
}
lazy var emptyJSON = JSON()
lazy var user = ShiftUser(userId: "userId", accessToken: AccessToken(token: "AccessToken",
primaryCredential: .email,
secondaryCredential: .phoneNumber))
lazy var userJSON = JSON(dictionaryLiteral: ("user_id", "user_id"), ("user_token", "user_token"))
lazy var teamConfig = TeamConfiguration(logoUrl: nil, name: "Test team")
lazy var amountRangeConfiguration = AmountRangeConfiguration(min: 0, max: 1000, def: 100, inc: 100)
lazy var workflowAction: WorkflowAction = {
let configuration = SelectBalanceStoreActionConfiguration(allowedBalanceTypes: [balanceType],
assetUrl: nil)
return WorkflowAction(actionId: nil,
name: nil,
order: nil,
status: nil,
actionType: .selectBalanceStore,
configuration: configuration)
}()
lazy var waitListAction: WorkflowAction = {
let configuration = WaitListActionConfiguration(asset: "asset", backgroundImage: "image", backgroundColor: "color")
return WorkflowAction(actionId: nil,
name: nil,
order: nil,
status: nil,
actionType: .waitList,
configuration: configuration)
}()
lazy var projectBranding: ProjectBranding = {
return ProjectBranding(uiBackgroundPrimaryColor: "ffffff",
uiBackgroundSecondaryColor: "ffffff",
iconPrimaryColor: "ffffff",
iconSecondaryColor: "ffffff",
iconTertiaryColor: "ffffff",
textPrimaryColor: "ffffff",
textSecondaryColor: "ffffff",
textTertiaryColor: "ffffff",
textTopBarPrimaryColor: "ffffff",
textTopBarSecondaryColor: "ffffff",
textLinkColor: "ffffff",
textLinkUnderlined: true,
textButtonColor: "ffffff",
buttonCornerRadius: 12,
uiPrimaryColor: "ffffff",
uiSecondaryColor: "ffffff",
uiTertiaryColor: "ffffff",
uiErrorColor: "ffffff",
uiSuccessColor: "ffffff",
uiNavigationPrimaryColor: "ffffff",
uiNavigationSecondaryColor: "ffffff",
uiBackgroundOverlayColor: "ffffff",
textMessageColor: "ffffff",
badgeBackgroundPositiveColor: "ffffff",
badgeBackgroundNegativeColor: "ffffff",
showToastTitle: true,
transactionDetailsCollapsable: true,
disclaimerBackgroundColor: "ffffff",
uiStatusBarStyle: "auto",
logoUrl: nil,
uiTheme: "theme_1")
}()
lazy var projectConfiguration: ProjectConfiguration = {
return ProjectConfiguration(name: "Test project",
summary: nil,
allowUserLogin: true,
primaryAuthCredential: .email,
secondaryAuthCredential: .phoneNumber,
skipSteps: true,
strictAddressValidation: false,
defaultCountryCode: 1,
products: [.link],
incomeTypes: [IncomeType(incomeTypeId: 1)],
housingTypes: [HousingType(housingTypeId: 1)],
salaryFrequencies: [SalaryFrequency(salaryFrequencyId: 1)],
timeAtAddressOptions: [TimeAtAddressOption(timeAtAddressId: 1)],
creditScoreOptions: [CreditScoreOption(creditScoreId: 1)],
grossIncomeRange: amountRangeConfiguration,
welcomeScreenAction: workflowAction,
supportEmailAddress: nil,
branding: projectBranding,
allowedCountries: [Country(isoCode: "US", name: "United States")],
isTrackerActive: false,
trackerAccessToken: nil)
}()
lazy var contextConfiguration = ContextConfiguration(teamConfiguration: teamConfig,
projectConfiguration: projectConfiguration)
lazy var uiConfig: UIConfig = UIConfig(projectConfiguration: projectConfiguration)
lazy var phoneDataPoint: DataPoint = DataPoint(type: .phoneNumber, verified: true, notSpecified: false)
lazy var emailDataPoint: DataPoint = DataPoint(type: .email, verified: true, notSpecified: false)
lazy var phoneNumberDataPointList: DataPointList = {
let list = DataPointList()
_ = list.getForcingDataPointOf(type: .phoneNumber, defaultValue: PhoneNumber())
return list
}()
lazy var emailDataPointList: DataPointList = {
let list = DataPointList()
_ = list.getForcingDataPointOf(type: .email, defaultValue: Email())
return list
}()
lazy var birthDateDataPointList: DataPointList = {
let list = DataPointList()
_ = list.getForcingDataPointOf(type: .birthDate, defaultValue: BirthDate())
return list
}()
lazy var ssnDataPointList: DataPointList = {
let list = DataPointList()
_ = list.getForcingDataPointOf(type: .idDocument, defaultValue: IdDocument())
return list
}()
lazy var cardApplication: CardApplication = CardApplication(id: "id",
status: .created,
applicationDate: Date(),
workflowObjectId: "workflow_id",
nextAction: workflowAction)
lazy var waitListCardApplication = CardApplication(id: "id",
status: .created,
applicationDate: Date(),
workflowObjectId: "workflow_id",
nextAction: waitListAction)
lazy var cardJSON = JSON(dictionaryLiteral: ("account_id", "account_id"), ("state", "created"), ("last_four", "1234"))
lazy var card: Card = {
let card = Card(accountId: "card_id",
cardProductId: "card_product_id",
cardNetwork: .other,
cardIssuer: .shift,
cardBrand: "Shift",
state: .active,
cardHolder: "Holder Name",
lastFourDigits: "7890",
spendableToday: Amount(value: 12.34, currency: "GBP"),
nativeSpendableToday: Amount(value: 0.034, currency: "BTC"),
totalBalance: Amount(value: 12.34, currency: "GBP"),
nativeTotalBalance: Amount(value: 0.034, currency: "BTC"),
kyc: .passed,
orderedStatus: .received,
panToken: "pan_token",
cvvToken: "cvv_token",
verified: true)
card.details = cardDetails
return card
}()
lazy var cardWithoutCardProductId: Card = {
let card = Card(accountId: "card_id",
cardProductId: nil,
cardNetwork: .other,
cardIssuer: .shift,
cardBrand: "Shift",
state: .active,
cardHolder: "Holder Name",
lastFourDigits: "7890",
spendableToday: Amount(value: 12.34, currency: "GBP"),
nativeSpendableToday: Amount(value: 0.034, currency: "BTC"),
totalBalance: Amount(value: 12.34, currency: "GBP"),
nativeTotalBalance: Amount(value: 0.034, currency: "BTC"),
kyc: .passed,
orderedStatus: .received,
panToken: "pan_token",
cvvToken: "cvv_token",
verified: true)
card.details = cardDetails
return card
}()
lazy var cardWithoutDetails: Card = Card(accountId: "card_id",
cardProductId: "card_product_id",
cardNetwork: .other,
cardIssuer: .shift,
cardBrand: "Shift",
state: .active,
cardHolder: "Holder Name",
lastFourDigits: "7890",
spendableToday: Amount(value: 12.34, currency: "GBP"),
nativeSpendableToday: Amount(value: 0.034, currency: "BTC"),
totalBalance: Amount(value: 12.34, currency: "GBP"),
nativeTotalBalance: Amount(value: 0.034, currency: "BTC"),
kyc: .passed,
orderedStatus: .received,
panToken: "pan_token",
cvvToken: "cvv_token",
verified: true)
lazy var cardWithIVR: Card = {
let phoneNumber = PhoneNumber(countryCode: 1, phoneNumber: "2342303796")
let ivr = IVR(status: .enabled, phone: phoneNumber)
let features = CardFeatures(setPin: FeatureAction(source: .ivr(ivr), status: .enabled),
getPin: FeatureAction(source: .ivr(ivr), status: .enabled),
allowedBalanceTypes: [balanceType], activation: nil, ivrSupport: ivr)
let card = Card(accountId: "card_id",
cardProductId: "card_product_id",
cardNetwork: .other,
cardIssuer: .shift,
cardBrand: "Shift",
state: .active,
cardHolder: "Holder Name",
lastFourDigits: "7890",
spendableToday: Amount(value: 12.34, currency: "GBP"),
nativeSpendableToday: Amount(value: 0.034, currency: "BTC"),
totalBalance: Amount(value: 12.34, currency: "GBP"),
nativeTotalBalance: Amount(value: 0.034, currency: "BTC"),
kyc: .passed,
orderedStatus: .received,
features: features,
panToken: "pan_token",
cvvToken: "cvv_token",
verified: true)
return card
}()
lazy var cardWithVoIP: Card = {
let phoneNumber = PhoneNumber(countryCode: 1, phoneNumber: "2342303796")
let ivr = IVR(status: .enabled, phone: phoneNumber)
let features = CardFeatures(setPin: FeatureAction(source: .voIP, status: .enabled),
getPin: FeatureAction(source: .voIP, status: .enabled),
allowedBalanceTypes: [balanceType], activation: nil, ivrSupport: ivr)
let card = Card(accountId: "card_id",
cardProductId: "card_product_id",
cardNetwork: .other,
cardIssuer: .shift,
cardBrand: "Shift",
state: .active,
cardHolder: "Holder Name",
lastFourDigits: "7890",
spendableToday: Amount(value: 12.34, currency: "GBP"),
nativeSpendableToday: Amount(value: 0.034, currency: "BTC"),
totalBalance: Amount(value: 12.34, currency: "GBP"),
nativeTotalBalance: Amount(value: 0.034, currency: "BTC"),
kyc: .passed,
orderedStatus: .received,
features: features,
panToken: "pan_token",
cvvToken: "cvv_token",
verified: true)
return card
}()
lazy var cardWithChangePIN: Card = {
let phoneNumber = PhoneNumber(countryCode: 1, phoneNumber: "2342303796")
let ivr = IVR(status: .enabled, phone: phoneNumber)
let features = CardFeatures(setPin: FeatureAction(source: .api, status: .enabled),
getPin: FeatureAction(source: .api, status: .enabled),
allowedBalanceTypes: [balanceType], activation: nil, ivrSupport: ivr)
let card = Card(accountId: "card_id",
cardProductId: "card_product_id",
cardNetwork: .other,
cardIssuer: .shift,
cardBrand: "Shift",
state: .active,
cardHolder: "Holder Name",
lastFourDigits: "7890",
spendableToday: Amount(value: 12.34, currency: "GBP"),
nativeSpendableToday: Amount(value: 0.034, currency: "BTC"),
totalBalance: Amount(value: 12.34, currency: "GBP"),
nativeTotalBalance: Amount(value: 0.034, currency: "BTC"),
kyc: .passed,
orderedStatus: .received,
features: features,
panToken: "pan_token",
cvvToken: "cvv_token",
verified: true)
return card
}()
lazy var cardWithChangePINAndIVR: Card = {
let phoneNumber = PhoneNumber(countryCode: 1, phoneNumber: "2342303796")
let ivr = IVR(status: .enabled, phone: phoneNumber)
let features = CardFeatures(setPin: FeatureAction(source: .api, status: .enabled),
getPin: FeatureAction(source: .ivr(ivr), status: .enabled),
allowedBalanceTypes: [balanceType], activation: nil, ivrSupport: ivr)
let card = Card(accountId: "card_id",
cardProductId: "card_product_id",
cardNetwork: .other,
cardIssuer: .shift,
cardBrand: "Shift",
state: .active,
cardHolder: "Holder Name",
lastFourDigits: "7890",
spendableToday: Amount(value: 12.34, currency: "GBP"),
nativeSpendableToday: Amount(value: 0.034, currency: "BTC"),
totalBalance: Amount(value: 12.34, currency: "GBP"),
nativeTotalBalance: Amount(value: 0.034, currency: "BTC"),
kyc: .passed,
orderedStatus: .received,
features: features,
panToken: "pan_token",
cvvToken: "cvv_token",
verified: true)
return card
}()
lazy var cardWithUnknownSource: Card = {
let phoneNumber = PhoneNumber(countryCode: 1, phoneNumber: "2342303796")
let ivr = IVR(status: .enabled, phone: phoneNumber)
let features = CardFeatures(setPin: FeatureAction(source: .unknown, status: .enabled),
getPin: FeatureAction(source: .unknown, status: .enabled),
allowedBalanceTypes: [balanceType], activation: nil, ivrSupport: ivr)
let card = Card(accountId: "card_id",
cardProductId: "card_product_id",
cardNetwork: .other,
cardIssuer: .shift,
cardBrand: "Shift",
state: .active,
cardHolder: "Holder Name",
lastFourDigits: "7890",
spendableToday: Amount(value: 12.34, currency: "GBP"),
nativeSpendableToday: Amount(value: 0.034, currency: "BTC"),
totalBalance: Amount(value: 12.34, currency: "GBP"),
nativeTotalBalance: Amount(value: 0.034, currency: "BTC"),
kyc: .passed,
orderedStatus: .received,
features: features,
panToken: "pan_token",
cvvToken: "cvv_token",
verified: true)
return card
}()
lazy var orderedCard: Card = {
let card = Card(accountId: "card_id",
cardProductId: "card_product_id",
cardNetwork: .other,
cardIssuer: .shift,
cardBrand: "Shift",
state: .active,
cardHolder: "Holder Name",
lastFourDigits: "7890",
spendableToday: Amount(value: 12.34, currency: "GBP"),
nativeSpendableToday: Amount(value: 0.034, currency: "BTC"),
totalBalance: Amount(value: 12.34, currency: "GBP"),
nativeTotalBalance: Amount(value: 0.034, currency: "BTC"),
kyc: .passed,
orderedStatus: .ordered,
panToken: "pan_token",
cvvToken: "cvv_token",
verified: true)
return card
}()
lazy var waitListedCard: Card = {
let card = Card(accountId: "card_id",
cardProductId: "card_product_id",
cardNetwork: .other,
cardIssuer: .shift,
cardBrand: "Shift",
state: .active,
cardHolder: "Holder Name",
lastFourDigits: "7890",
spendableToday: Amount(value: 12.34, currency: "GBP"),
nativeSpendableToday: Amount(value: 0.034, currency: "BTC"),
totalBalance: Amount(value: 12.34, currency: "GBP"),
nativeTotalBalance: Amount(value: 0.034, currency: "BTC"),
kyc: .passed,
orderedStatus: .ordered,
panToken: "pan_token",
cvvToken: "cvv_token",
verified: true,
isInWaitList: true)
return card
}()
lazy var cardInactive: Card = {
let card = Card(accountId: "card_id", cardProductId: "card_product_id", cardNetwork: .other, cardIssuer: .shift,
cardBrand: "Shift", state: .inactive, cardHolder: "Holder Name", lastFourDigits: "7890",
spendableToday: Amount(value: 12.34, currency: "GBP"),
nativeSpendableToday: Amount(value: 0.034, currency: "BTC"),
totalBalance: Amount(value: 12.34, currency: "GBP"),
nativeTotalBalance: Amount(value: 0.034, currency: "BTC"), kyc: .passed, orderedStatus: .received,
panToken: "pan_token", cvvToken: "cvv_token", verified: true)
card.details = cardDetails
return card
}()
lazy var cardDetails = CardDetails(expiration: "99-03", pan: "1234234134124123", cvv: "123")
lazy var transaction = transactionWith(transactionId: "transactionId")
func transactionWith(transactionId: String) -> Transaction {
return Transaction(transactionId: transactionId,
transactionType: .purchase,
createdAt: Date(),
transactionDescription: "transactionDescription",
lastMessage: "lastMessage",
declineCode: nil,
merchant: nil,
store: nil,
localAmount: Amount(value: 10, currency: "USD"),
billingAmount: Amount(value: 10, currency: "USD"),
holdAmount: nil,
cashbackAmount: nil,
feeAmount: nil,
nativeBalance: Amount(value: 0.001, currency: "BTC"),
settlement: nil,
ecommerce: true,
international: false,
cardPresent: false,
emv: false,
cardNetwork: .visa,
state: .complete,
adjustments: nil,
fundingSourceName: "Bitcoin")
}
lazy var fundingSource = FundingSource(fundingSourceId: "fundingSourceId",
type: .custodianWallet,
balance: Amount(value: 1000, currency: "USD"),
amountHold: nil,
state: .valid)
lazy var invalidFundingSource = FundingSource(fundingSourceId: "fundingSourceId",
type: .custodianWallet,
balance: Amount(value: 1000, currency: "USD"),
amountHold: nil,
state: .invalid)
lazy var externalOauthModuleConfig = ExternalOAuthModuleConfig(title: "title",
explanation: "explanation",
callToAction: "callToAction",
newUserAction: "newUserAction",
allowedBalanceTypes: [balanceType],
assetUrl: url,
oauthErrorMessageKeys: nil)
lazy var custodian = Custodian(custodianType: "custodian", name: "Custodian")
lazy var oauthCredential = OauthCredential(oauthTokenId: "oauth_token_id")
lazy var oauthAttempt = OauthAttempt(id: "attempt_id",
status: .passed,
url: url,
credentials: oauthCredential,
error: nil,
errorMessage: nil)
lazy var oauthErrorAttempt = OauthAttempt(id: "attempt_id",
status: .failed,
url: nil,
credentials: nil,
error: "unauthorised_access",
errorMessage: "unauthorised_access")
lazy var usa = Country(isoCode: "US", name: "United States")
lazy var balanceType = AllowedBalanceType(type: "custodian", baseUri: "baseUri")
lazy var url = URL(string: "https://shiftpayments.com")! // swiftlint:disable:this implicitly_unwrapped_optional
lazy var categorySpending = CategorySpending(categoryId: .food,
spending: Amount(value: 100, currency: "USD"),
difference: 10)
func monthlySpending(date: Date, previousSpendingExists: Bool = true, nextSpendingExists: Bool = true) -> MonthlySpending {
return MonthlySpending(previousSpendingExists: previousSpendingExists,
nextSpendingExists: nextSpendingExists,
spending: [categorySpending],
date: date)
}
lazy var monthlySpendingJSON = JSON(parseJSON:"""
{
"next_spending_exists": false,
"prev_spending_exists": true,
"spending": {
"data": [
{
"category_id": "plane",
"difference": "-13.13",
"spending": {
"amount": 90,
"currency": "USD",
"type": "money"
},
"type": "category_spending"
}
],
"has_more": false,
"page": 0,
"rows": 12,
"total_count": 1,
"type": "list"
},
"type": "monthly_spending"
}
""")
lazy var cardProduct = CardProduct(id: "id",
teamId: "teamId",
name: "Name",
summary: "Summary",
website: nil,
cardholderAgreement: .plainText("cardholder agreement"),
privacyPolicy: .plainText("privacy policy"),
termsAndConditions: .plainText("terms and conditions"),
faq: .plainText("faq"),
status: .enabled,
shared: false,
disclaimerAction: workflowAction,
cardIssuer: "Shift",
waitListBackgroundImage: "image",
waitListBackgroundColor: "color",
waitListAsset: "asset")
lazy var paymentSuccessfulGroup = NotificationGroup(groupId: .paymentSuccessful,
category: .cardActivity,
state: .disabled,
channel: NotificationGroup.Channel(push: true, email: true))
lazy var atmWithdrawalGroup = NotificationGroup(groupId: .atmWithdrawal,
category: .cardActivity,
state: .enabled,
channel: NotificationGroup.Channel(push: true, email: false))
lazy var notificationPreferences = NotificationPreferences(preferences: [paymentSuccessfulGroup, atmWithdrawalGroup])
lazy var oauthUserData = OAuthUserData(userData: phoneNumberDataPointList)
lazy var oauthSaveUserDataSucceed = OAuthSaveUserDataResult(result: .valid,
userData: nil)
lazy var oauthSaveUserDataFailure = OAuthSaveUserDataResult(result: .invalid,
userData: phoneNumberDataPointList)
lazy var voIPToken = VoIPToken(accessToken: "access_token", requestToken: "request_token", provider: "twilio")
lazy var monthlyStatementReportJSON = JSON(dictionaryLiteral: ("type", "monthly_statement_report"), ("id", "id"),
("month", 2), ("year", 2019),
("download_url", "https://aptopayments.com"),
("url_expiration", "2019-02-11T17:17:13.564128+00:00"))
lazy var monthlyStatementReport = MonthlyStatementReport(id: "id", month: 2, year: 2019,
downloadUrl: "https://aptopyaments.com",
urlExpirationDate: Date().add(3, units: .month))
lazy var monthlyStatementReportExpired = MonthlyStatementReport(id: "id", month: 2, year: 2019,
downloadUrl: "https://aptopyaments.com",
urlExpirationDate: Date.distantPast)
lazy var monthlyStatementReportWithoutUrl = MonthlyStatementReport(id: "id", month: 2, year: 2019, downloadUrl: nil,
urlExpirationDate: Date.distantPast)
lazy var monthlyStatementReportWithoutExpiration = MonthlyStatementReport(id: "id", month: 2, year: 2019,
downloadUrl: nil, urlExpirationDate: nil)
lazy var monthJSON: JSON = ["type": "month", "month": 2, "year": 2019]
lazy var month = Month(month: 2, year: 2019)
lazy var monthlyStatementsPeriodJSON: JSON = [
"type": "monthly_statements_period",
"start": [
"type": "month",
"year": 2019,
"month": 5
],
"end": [
"type": "month",
"year": 2019,
"month": 9
]
]
lazy var monthlyStatementsPeriod = MonthlyStatementsPeriod(start: Month(month: 5, year: 2019),
end: Month(month: 9, year: 2019))
}