esimsGetUsage method
Get eSIM usage
Returns the current data, SMS and voice usage of an eSIM. Reads the live usage when the request is made and returns the allowed and remaining data (MB), SMS and voice (seconds), including top-ups. When the usage cannot be read live, or the plan does not report live usage, it returns the last known usage. An ICCID that is not one of your eSIMs gives 404 / 10004.
Parameters:
- String iccid (required):
The eSIM's ICCID, from the order item's
fulfillment.result.details.iccid.
Implementation
Future<EsimCurrentUsage?> esimsGetUsage(String iccid, { Future<void>? abortTrigger, }) async {
final response = await esimsGetUsageWithHttpInfo(iccid, abortTrigger: abortTrigger,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'EsimCurrentUsage',) as EsimCurrentUsage;
}
return null;
}