get method

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

Implementation

get({
  required bool testMode,
  required String customerId,
  required String apiKey,
  required void Function(Map<String, dynamic>) onError,
  required void Function(SavedCardsModel data) onDone,
}) async {
  String url = testMode
      ? "https://uatcheckout.thawani.om/api/v1/payment_methods"
      : "https://checkout.thawani.om/api/v1/payment_methods";

  await Request.get(url: "$url?customer_id=$customerId", headers: {
    'Content-Type': "application/json",
    'thawani-api-key': apiKey
  }).then((value) {
    if (value['code'] == 2000) {

      onDone(SavedCardsModel.fromJson(value));
    } else if(value['code'] ==4003) {
      onDone(SavedCardsModel.fromJson(value));

    }else {

      onError(value);
    }
  });
}