createGlobalAccountDeposit method

  1. @override
Future<Map> createGlobalAccountDeposit(
  1. String token,
  2. String amount,
  3. String globalAccountId,
  4. String? payerBank,
  5. String? payerCountry,
  6. String? payerName,
  7. String? reference,
  8. String? status,
)
override

Implementation

@override
Future<Map> createGlobalAccountDeposit(
    String token,
    String amount,
    String globalAccountId,
    String? payerBank,
    String? payerCountry,
    String? payerName,
    String? reference,
    String? status) async {
  final String baseUrl = await getBaseUrl;
  var url = Uri.parse("$baseUrl/api/v1/simulation/deposit/create");
  var bodyData = {
    "amount": amount,
    "global_account_id": globalAccountId,
  };
  if (payerBank != null) {
    bodyData.addAll({"payer_bankname": payerBank});
  }
  if (payerCountry != null) {
    bodyData.addAll({"payer_country": payerCountry});
  }
  if (payerName != null) {
    bodyData.addAll({"payer_name": payerName});
  }
  if (reference != null) {
    bodyData.addAll({"reference": reference});
  }
  if (status != null) {
    bodyData.addAll({"status": status});
  }
  var jsonBody = jsonEncode(bodyData);
  var response = await http.post(
    url,
    headers: {
      "Content-Type": "application/json",
      "Authorization": "Bearer $token"
    },
    body: jsonBody,
  );
  var data = jsonDecode(response.body);
  return data;
}