getAccounts method
Future<Map>
getAccounts(
- String token,
- String? accountStatus,
- String? email,
- String? fromCreatedAt,
- String? identifier,
- String? metadata,
- String? pageNumber,
- String? pageSize,
- String? toCreatedAt,
override
Implementation
@override
Future<Map> getAccounts(
String token,
String? accountStatus,
String? email,
String? fromCreatedAt,
String? identifier,
String? metadata,
String? pageNumber,
String? pageSize,
String? toCreatedAt) async {
final String baseUrl = await getBaseUrl;
var filters = [];
var prefixes = [];
if (accountStatus != null) {
filters.add(accountStatus);
prefixes.add("account_status=");
}
if (email != null) {
filters.add(email);
prefixes.add("email=");
}
if (fromCreatedAt != null) {
filters.add(fromCreatedAt);
prefixes.add("from_created_at=");
}
if (identifier != null) {
filters.add(identifier);
prefixes.add("identifier=");
}
if (metadata != null) {
filters.add(metadata);
prefixes.add("metadata=");
}
if (pageNumber != null) {
filters.add(pageNumber);
prefixes.add("page_num=");
}
if (pageSize != null) {
filters.add(pageSize);
prefixes.add("page_size=");
}
if (toCreatedAt != null) {
filters.add(toCreatedAt);
prefixes.add("to_created_at=");
}
String params = addFilter(filters, prefixes);
var url = Uri.parse("$baseUrl/api/v1/accounts$params");
var response = await http.get(
url,
headers: {"Authorization": "Bearer $token", "headers": "[object Object]"},
);
var data = jsonDecode(response.body);
return data;
}