checkAllowedCountry static method

Future<CheckedAllowedCountryModel?> checkAllowedCountry({
  1. required String token,
  2. required String cardsixdigit,
})

Implementation

static Future<CheckedAllowedCountryModel?> checkAllowedCountry(
    {required String token, required String cardsixdigit}) async {
  final url = Uri.parse(
    ApiEndPoint.checkCountry,
  );
  Map<String, String> header = {'Content-Type': 'application/json', "Authorization": token};
  Map<String, String> body = {"cardsixdigit": cardsixdigit};
  CheckedAllowedCountryModel model = CheckedAllowedCountryModel(isAllowed: false, isDebitCard: false);
  var result = await http.post(
    url,
    headers: header,
    body: json.encode(body),
  );

  if (result.statusCode == 200) {
    var response = jsonDecode(result.body);
    model = CheckedAllowedCountryModel.fromJson(response);
    return model;
  } else {
    var response = jsonDecode(result.body);
    print(response);
  }
  return model;
}