getUserProfile method

Future<Map<String, dynamic>> getUserProfile(
  1. String userId
)

Corresponds to: GET /accounts/profiles/:user_id Returns user profile JSON, e.g. { "id", "first_name", "last_name", "email" } on success or throws an error if not found.

Implementation

Future<Map<String, dynamic>> getUserProfile(String userId) async {
  final uri = Uri.parse('$baseUrl/accounts/profiles/$userId');
  final response = await http.get(uri, headers: _getHeaders());

  if (response.statusCode >= 400) {
    throw MeshagentException('Failed to get user profile. Status code: ${response.statusCode}, body: ${response.body}');
  }
  return jsonDecode(response.body) as Map<String, dynamic>;
}