listPayments method

Future<List<MolliePaymentResponse>> listPayments()

Retrieve all payments. TODO fix payments attributes changing depending on order or payment api

Implementation

Future<List<MolliePaymentResponse>> listPayments() async {
  var res = await http.get(
    Uri.parse(_apiEndpoint),
    headers: _headers,
  );

  List<MolliePaymentResponse> subs = [];

  dynamic data = json.decode(res.body);

  for (int i = 0; i < data["count"]; i++) {
    subs.add(MolliePaymentResponse.build(data["_embedded"]["payments"][i]));
  }

  return subs;
}