getCustomer method
Implementation
Future<SuccessResponse> getCustomer(
String? name, String? email, String? phoneNumber) async {
var successResponse = SuccessResponse();
var queryParameters = {
'name.EQ': name,
'email.EQ': email,
'phoneNumber.EQ': phoneNumber,
};
var url =
Uri.https(Constant.testBaseURL, Constant.getCustomer, 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 customerList;
successResponse.responseCode = "${response.statusCode}";
if (response.statusCode == 200) {
var jsonList = result["entity"]["content"] as List;
customerList = jsonList.map((json) => Customer.fromJson(json)).toList();
}
successResponse.responseBody = response.statusCode == 200
? result["entity"]
: result;
successResponse.contentList = response.statusCode == 200 &&
result != null &&
result.toString().isNotEmpty
? customerList
: [];
return successResponse;
}