getCharges method
Future<Map>
getCharges(
- String token,
- String? currencyCode,
- String? fromCreatedAt,
- String? pageNumber,
- String? pageSize,
- String? requestId,
- String? source,
- String? status,
- String? toCreatedAt,
override
Implementation
@override
Future<Map> getCharges(
String token,
String? currencyCode,
String? fromCreatedAt,
String? pageNumber,
String? pageSize,
String? requestId,
String? source,
String? status,
String? toCreatedAt) async {
final String baseUrl = await getBaseUrl;
var filters = [];
var prefixes = [];
if (currencyCode != null) {
filters.add(currencyCode);
prefixes.add("currency=");
}
if (fromCreatedAt != null) {
filters.add(fromCreatedAt);
prefixes.add("from_created_at=");
}
if (pageNumber != null) {
filters.add(pageNumber);
prefixes.add("page_num=");
}
if (pageSize != null) {
filters.add(pageSize);
prefixes.add("page_size=");
}
if (requestId != null) {
filters.add(requestId);
prefixes.add("request_id=");
}
if (source != null) {
filters.add(source);
prefixes.add("source=");
}
if (status != null) {
filters.add(status);
prefixes.add("status=");
}
if (toCreatedAt != null) {
filters.add(toCreatedAt);
prefixes.add("to_created_at=");
}
String params = addFilter(filters, prefixes);
var url = Uri.parse("$baseUrl/api/v1/charges$params");
var response = await http.get(
url,
headers: {"Authorization": "Bearer $token"},
);
var data = jsonDecode(response.body);
return data;
}