create method

dynamic create({
  1. required bool testMode,
  2. required String apiKey,
  3. required String customerId,
  4. required void onError(
    1. Map<String, dynamic>
    ),
  5. required void onDone(
    1. CreateCustomerModel data
    ),
})

Implementation

create({
  required bool testMode,
  required String apiKey,
  required String customerId,
  required void Function(Map<String, dynamic>) onError,
  required void Function(CreateCustomerModel data) onDone,
}) async {
  final String url = testMode
      ? 'https://uatcheckout.thawani.om/api/v1/customers'
      : 'https://checkout.thawani.om/api/v1/customers';
  await Request.post(url: url, data: {
    'client_customer_id': customerId
  }, headers: {
    'Content-Type': "application/json",
    'thawani-api-key': apiKey
  }).then((value) {
    // print(value);
    if (value['status'] == 200) {
      onDone(CreateCustomerModel.fromJson(value['data']));
    } else {
      onError(value);
    }
  });
}