ift method Null safety

Future<BankReponse> ift(
  1. {required String referenceNumber,
  2. required String accountNumber,
  3. required double amount,
  4. required String callBackUrl,
  5. String transactionCurrency = 'KES',
  6. required String transactionDescription,
  7. required String accessToken}
)

Implements InterFundsTransfer(IFT) end point, which enables transactions from the configured account baseAccountNo to s co-op bank account It has a return type of BankReponse & the raw response can be gotten by calling BankReponse.rawResponceBody Sample success response;

{
  'MessageReference': '40ca18c6765086089a1',
  'MessageDateTime': '2017-12-04T09:27:00',
  'MessageCode': '0',
  'MessageDescription': 'REQUEST ACCEPTED SUCCESSFULLY'
}

Implementation

Future<BankReponse> ift({
  required String referenceNumber,
  required String accountNumber,
  required double amount,
  required String callBackUrl,
  String transactionCurrency = 'KES',
  required String transactionDescription,
  required String accessToken,
})async{
  Map<String, String> _header ={
    'content-type': 'application/json',
    'Authorization': 'Bearer $accessToken'
  };

  Map<String, dynamic> _payload = {
    'MessageReference': referenceNumber,
    'CallBackUrl': callBackUrl,
    'Source': transactionSource(amount, transactionDescription),
    'Destinations': [
      {
        'ReferenceNumber': '${referenceNumber}_1',
        'AccountNumber': accountNumber,
        'Amount': amount,
        'TransactionCurrency': transactionCurrency,
        'Narration': transactionDescription
      }
    ]
  };

  try {
    return await pesalinkProcessTransaction(iftUrl, _header, _payload, applicationMode);
  } catch (e) {
    rethrow;
  }

}