update method

Future<AuthResponse<User>> update({
  1. String? name,
  2. String? image,
})

Updates the current user's account information.

name The new display name (optional). image The new profile image URL (optional).

Returns an AuthResponse containing the updated User on success.

Example:

final response = await authClient.account.update(
  name: 'John Doe',
  image: 'https://example.com/avatar.jpg',
);

if (response.isSuccess) {
  print('Profile updated: ${response.data!.name}');
}

Implementation

Future<AuthResponse<User>> update({
  String? name,
  String? image,
}) async {
  try {
    final response = await _dio.post(
      ApiEndpoints.updateAccount,
      data: {
        if (name != null) 'name': name,
        if (image != null) 'image': image,
      },
    );

    final user = User.fromJson(response.data['user'] ?? response.data);
    return AuthResponse.success(user);
  } on DioException catch (e) {
    return AuthResponse.error(AuthError.fromDio(e));
  }
}