accounts method
This endpoint will return a list of accounts that the JWT allows access to. See: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0030.md#get-accounts
Implementation
Future<SEP30AccountsResponse> accounts(String jwt, {String? after}) async {
Uri requestURI = after == null
? Util.appendEndpointToUrl(_serviceAddress, 'accounts')
: Util.appendEndpointToUrl(_serviceAddress, 'accounts')
.replace(queryParameters: {'after': after});
Map<String, String> headers = {...RequestBuilder.headers};
headers["Authorization"] = "Bearer " + jwt;
headers.putIfAbsent("Content-Type", () => "application/json");
SEP30AccountsResponse result =
await httpClient.get(requestURI, headers: headers).then((response) {
switch (response.statusCode) {
case 200:
return SEP30AccountsResponse.fromJson(json.decode(response.body));
case 400:
throw SEP30BadRequestResponseException(
errorFromResponseBody(response.body));
case 401:
throw SEP30UnauthorizedResponseException(
errorFromResponseBody(response.body));
case 404:
throw SEP30NotFoundResponseException(
errorFromResponseBody(response.body));
case 409:
throw SEP30ConflictResponseException(
errorFromResponseBody(response.body));
default:
throw new SEP30UnknownResponseException(
response.statusCode, response.body);
}
}).catchError((onError) {
throw onError;
});
return result;
}