getAccount method

  1. @override
Future<Response<Account>> getAccount({
  1. String? authToken,
})
override

Retrieves account information from the EAN-DB API.

authToken is an optional authentication token for the API. If not provided, it will use the EAN_DB_API_KEY environment variable.

Returns a Response containing the Account information if successful, or an error if the request fails.

Implementation

@override
Future<Response<Account>> getAccount({String? authToken}) async {
  final response = await http.get(
    Uri.https('ean-db.com', 'api/v2/account'),
    headers: {
      'Authorization':
          'Bearer ${authToken ?? String.fromEnvironment('EAN_DB_API_KEY')}',
      'accept': 'application/json',
    },
  );

  return ResponseDto<AccountDto>.fromJson(
    response.body,
  ).toResponse<Account>();
}