updateUserProfile method

Future<Map<String, dynamic>> updateUserProfile(
  1. String userId,
  2. String firstName,
  3. String lastName
)

Corresponds to: PUT /accounts/profiles/:user_id Body: { "first_name", "last_name" } Returns JSON like { "ok": true } on success.

Implementation

Future<Map<String, dynamic>> updateUserProfile(String userId, String firstName, String lastName) async {
  final uri = Uri.parse('$baseUrl/accounts/profiles/$userId');
  final body = {'first_name': firstName, 'last_name': lastName};

  final response = await http.put(uri, headers: _getHeaders(), body: jsonEncode(body));

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