generateLinkAsync function
Future<GenerateLink?>
generateLinkAsync(
- BuildContext context,
- String languageCode,
- GenerateLinkRequestModel model,
- String refererKey,
Implementation
Future<GenerateLink?> generateLinkAsync(
BuildContext context,
String languageCode,
GenerateLinkRequestModel model,
String refererKey) async {
final url = Uri.parse(AppConfig.generateLinkUrl);
GenerateLink? responseData;
try {
final response = await http.post(url,
headers: {
"Content-Type": "application/json",
"token": AppConfig.token,
"X-referrer-Key": refererKey
},
body: jsonEncode({
"bank_id": model.bankId,
"subscription_no": model.subscriptionNo
}));
if (response.statusCode == 200) {
responseData = generateLinkFromJson(response.body);
debugPrint(responseData.toString());
} else {
debugPrint(response.body);
B24DirectDebitSdk.showErrorMessage(
// ignore: use_build_context_synchronously
context,
languageCode,
errorConnectBank,
errorConnectBankKh);
}
} catch (ex) {
debugPrint(ex.toString());
B24DirectDebitSdk.showErrorMessage(
// ignore: use_build_context_synchronously
context,
languageCode,
errorMessage,
errorMessageKh);
}
return responseData;
}