getAccountData method

Future<Map<String, Object?>> getAccountData(
  1. String userId,
  2. String type
)
inherited

Get some account data for the client. This config is only visible to the user that set the account data.

userId The ID of the user to get account data for. The access token must be authorized to make requests for this user ID.

type The event type of the account data to get. Custom types should be namespaced to avoid clashes.

Implementation

Future<Map<String, Object?>> getAccountData(
    String userId, String type) async {
  final requestUri = Uri(
      path:
          '_api/client/v3/user/${Uri.encodeComponent(userId)}/account_data/${Uri.encodeComponent(type)}');
  final request = Request('GET', baseUri!.resolveUri(requestUri));
  request.headers['authorization'] = 'Bearer ${bearerToken!}';
  final response = await httpClient.send(request);
  final responseBody = await response.stream.toBytes();
  if (response.statusCode != 200) unexpectedResponse(response, responseBody);
  final responseString = utf8.decode(responseBody);
  final json = jsonDecode(responseString);
  return json as Map<String, Object?>;
}