getTransactionReport method

Future<List<Map<String, dynamic>>> getTransactionReport(
  1. String startDate,
  2. String endDate
)

Implementation

Future<List<Map<String, dynamic>>> getTransactionReport(
    String startDate, String endDate) async {
  if (_apiKey.isEmpty || _siteCode.isEmpty || _privateKey.isEmpty) {
    return [
      {
        'errorMessage':
            "Please call init and pass in the correct API, Private key and Site Code"
      }
    ];
  } else {
    var request = http.Request(
        'GET',
        Uri.parse(
            'https://api.ozow.com/GetTransactionReport?SiteCode=$_siteCode&StartDate=$startDate&EndDate=$endDate'));

    request.headers.addAll(
      {
        'ApiKey': _apiKey,
        'Accept': 'application/json',
      },
    );

    var response = await request.send();

    if (response.statusCode == 200) {
      var json = await response.stream.bytesToString();
      return List<Map<String, dynamic>>.from(jsonDecode(json));
    } else {
      return [
        {'errorMessage': "Could not get the report from the server"}
      ];
    }
  }
}