create method

Future<MollieCustomer?> create(
  1. String name,
  2. String email
)

Creates a simple minimal representation of a customer in the Mollie API to use for the Mollie Checkout and Recurring features. These customers will appear in your Mollie Dashboard where you can manage their details, and also see their payments and subscriptions.

Implementation

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

  dynamic body = json.encode(data);

  var res = await http.post(Uri.parse(_apiEndpoint), 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 creating customer ${res.statusCode} ${res.body}");
  }
}