retrieveAllCharges property

Future<List<ChargeObject>> retrieveAllCharges

Returns a list of the Charges associated with the Coinbase account TODO: The List of retrieved charges should be looped through

Implementation

Future<List<ChargeObject>> get retrieveAllCharges async {
  List<ChargeObject> coinbaseResponse;
  List data;
  Map response = await getFromDB(
    api: 'https://api.commerce.coinbase.com/charges',
    apiKey: _apiKey,
  );
  if (response.containsKey('error')) {
    data = response['error'];
  } else {
    data = response['data'];
  }

  coinbaseResponse = List.generate(
      data.length, (index) => ChargeObject.fromJson(data[index]));

  Logger(debug).displayLog(coinbaseResponse.toString());
  return coinbaseResponse;
}