-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsc_loan.dart
More file actions
85 lines (78 loc) · 2.6 KB
/
Copy pathsc_loan.dart
File metadata and controls
85 lines (78 loc) · 2.6 KB
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
import 'package:flutter/services.dart';
import 'dart:convert';
import 'sc_loan_props.dart';
import 'sc_loan_responses.dart';
import 'platform_exception_ext.dart';
export 'sc_loan.dart';
export 'sc_loan_responses.dart';
export 'sc_loan_props.dart';
class ScLoan {
static const _channel = MethodChannel('scloans');
static Future<ScLoanSuccess> setup(ScLoanConfig config) async {
try {
String? setupResponse = await _channel.invokeMethod(
'setup', <String, dynamic>{
"gateway": config.gateway,
"env": config.environment.index
});
return ScLoanSuccess.fromJson(setupResponse ?? "{}");
} on PlatformException catch (e) {
throw e.toScLoanError;
}
}
static Future<ScLoanSuccess> apply(ScLoanInfo loanInfo) async {
try {
String? applyResponse =
await _channel.invokeMethod('apply', <String, dynamic>{
"interactionToken": loanInfo.interactionToken,
});
return ScLoanSuccess.fromJson(applyResponse ?? "{}");
} on PlatformException catch (e) {
throw e.toScLoanError;
}
}
static Future<ScLoanSuccess> pay(ScLoanInfo loanInfo) async {
try {
String? payResponse =
await _channel.invokeMethod('pay', <String, dynamic>{
"interactionToken": loanInfo.interactionToken,
});
return ScLoanSuccess.fromJson(payResponse ?? "{}");
} on PlatformException catch (e) {
throw e.toScLoanError;
}
}
static Future<ScLoanSuccess> withdraw(ScLoanInfo loanInfo) async {
try {
String? withdrawResponse =
await _channel.invokeMethod('withdraw', <String, dynamic>{
"interactionToken": loanInfo.interactionToken,
});
return ScLoanSuccess.fromJson(withdrawResponse ?? "{}");
} on PlatformException catch (e) {
throw e.toScLoanError;
}
}
static Future<ScLoanSuccess> service(ScLoanInfo loanInfo) async {
try {
String? serviceResponse =
await _channel.invokeMethod('service', <String, dynamic>{
"interactionToken": loanInfo.interactionToken,
});
return ScLoanSuccess.fromJson(serviceResponse ?? "{}");
} on PlatformException catch (e) {
throw e.toScLoanError;
}
}
static Future<ScLoanSuccess> triggerInteraction(ScLoanInfo loanInfo) async {
try {
String? triggerInteractionResponse =
await _channel.invokeMethod('triggerInteraction', <String, dynamic>{
"interactionToken": loanInfo.interactionToken,
});
return ScLoanSuccess.fromJson(triggerInteractionResponse ?? "{}");
} on PlatformException catch (e) {
throw e.toScLoanError;
}
}
}