getSavedCards method

Future<List<SavedCardResponse>> getSavedCards(
  1. String customerGid
)

Implementation

Future<List<SavedCardResponse>> getSavedCards(String customerGid) async {
  var queryParameters = {
    'customerGid.EQ': customerGid,
    'isSaved.EQ': "true",
  };
  var url = Uri.https(
      Constant.testBaseURL, Constant.createPaymentMethod, queryParameters);
  final response = await http.get(url, headers: {
    "Content-Type": "application/json",
    "accept": "application/json",
    "x-api-key": SwirepaySdk.secretKey
  });
  final result = jsonDecode(response.body);
  var jsonList = result["entity"]["content"] as List;

  List<SavedCardResponse> savedCardList = response.statusCode == 200 &&
          result != null &&
          result.toString().isNotEmpty
      ? jsonList.map((json) => SavedCardResponse.fromJson(json)).toList()
      : [];
  return savedCardList;
}