fee method Null safety
- SEP24FeeRequest request
Get the anchor's to reported fee that would be charged for a given deposit or withdraw operation. This is important to allow an anchor to accurately report fees to a user even when the fee schedule is complex. If a fee can be fully expressed with the fee_fixed, fee_percent or fee_minimum fields in the /info response, then an anchor will not implement this endpoint.
Throws a RequestErrorException if the server responds with an error and corresponding error message. Throws a SEP24AuthenticationRequiredException if the server responds with an authentication_required error.
Implementation
Future<SEP24FeeResponse> fee(SEP24FeeRequest request) async {
Uri serverURI = Util.appendEndpointToUrl(_transferServiceAddress, 'fee');
_FeeRequestBuilder requestBuilder =
_FeeRequestBuilder(httpClient, serverURI);
final Map<String, String> queryParams = {
"operation": request.operation,
"asset_code": request.assetCode,
"amount": request.amount.toString(),
};
if (request.type != null) {
queryParams["type"] = request.type!;
}
SEP24FeeResponse response;
try {
response = await requestBuilder
.forQueryParameters(queryParams)
.execute(request.jwt);
} on ErrorResponse catch (e) {
if (e.code == 403) {
_handleForbiddenResponse(e);
}
else if (e.code != 200) {
_handleErrorResponse(e);
}
throw e;
}
return response;
}