getLinkUsage method
Shows one provider account's own usage dashboard.
Shows one provider account's own usage dashboard. It answers the time series for a SINGLE provider account — the windows in range plus the currently-open ones — as that provider's own meter reported it: "my plan is 47% through its 6h window, resets at 14:20". current is the newest instance of each lane (the headline); windows is the history behind it, both computed from ONE deduped read. provider is required; an unknown window class or range is 400, never a quiet fallback to a different one. When no series is available the response is a 200 with available:false and empty lists — an honest "we have no data", which is a different claim from zero usage.
Parameters:
-
String provider: Provider is the provider whose meter to read. Required.
-
String account: Account narrows to one account when a user has several with the provider.
-
String window: Window selects a window class: 6h, day, week or month. Empty reads all.
-
String range: Range is the period, one of 1h, 24h, 7d or 30d; empty means 24h, and an unknown label is 400, never a quiet fallback.
Implementation
Future<BoardResp?> getLinkUsage({ String? provider, String? account, String? window, String? range, }) async {
final response = await getLinkUsageWithHttpInfo( provider: provider, account: account, window: window, range: range, );
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), 'BoardResp',) as BoardResp;
}
return null;
}