update method

Future<MollieCustomer?> update(
  1. String customerId,
  2. String name,
  3. String email
)

Update an existing customer.

Implementation

Future<MollieCustomer?> update(String customerId, String name, String email) async {
  Map data = {"name": name, "email": email};

  dynamic body = json.encode(data);

  var res = await http.patch(Uri.parse("$_apiEndpoint/$customerId"), headers: _headers, body: body);

  if (res.statusCode == 200 || res.statusCode == 201) {
    dynamic data = json.decode(res.body);
    return MollieCustomer.build(data);
  } else {
    throw Exception("Error updating customer ${res.statusCode} ${res.body}");
  }
}