# This file is auto-generated by oagen. Do not edit.

"""Model round-trip tests: from_dict(to_dict()) preserves data."""

from tests.generated_helpers import load_fixture
from workos.user_management.models import (
    AuthenticateResponse,
    AuthenticateResponseImpersonator,
    AuthenticateResponseOAuthToken,
    AuthorizedConnectApplicationListData,
    CORSOriginResponse,
    DeviceAuthorizationResponse,
    EmailChange,
    EmailChangeConfirmation,
    EmailChangeConfirmationUser,
    EmailVerification,
    Invitation,
    JwksResponse,
    JwksResponseKeys,
    JWTTemplateResponse,
    MagicAuth,
    MagicAuthSendMagicAuthCodeAndReturnResponse,
    PasswordReset,
    RadarChallenge,
    RedirectUri,
    ResetPasswordResponse,
    SendRadarSmsChallengeResponse,
    SendVerificationEmailResponse,
    User,
    UserApiKey,
    UserApiKeyOwner,
    UserApiKeyWithValue,
    UserApiKeyWithValueOwner,
    UserCreateResponse,
    UserIdentitiesGetItem,
    UserInvite,
    UserSessionsImpersonator,
    UserSessionsListItem,
    VerifyEmailResponse,
)


class TestModelRoundTrip:
    def test_user_round_trip(self):
        data = load_fixture("user.json")
        instance = User.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = User.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_user_minimal_payload(self):
        data = {
            "object": "user",
            "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "first_name": None,
            "last_name": None,
            "profile_picture_url": None,
            "email": "marcelina.davis@example.com",
            "email_verified": True,
            "external_id": None,
            "last_sign_in_at": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = User.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["first_name"] == data["first_name"]
        assert serialized["last_name"] == data["last_name"]
        assert serialized["profile_picture_url"] == data["profile_picture_url"]
        assert serialized["email"] == data["email"]
        assert serialized["email_verified"] == data["email_verified"]
        assert serialized["external_id"] == data["external_id"]
        assert serialized["last_sign_in_at"] == data["last_sign_in_at"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]

    def test_user_omits_absent_optional_non_nullable_fields(self):
        data = {
            "object": "user",
            "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "first_name": "Marcelina",
            "last_name": "Davis",
            "name": "Marcelina Davis",
            "profile_picture_url": "https://workoscdn.com/images/v1/123abc",
            "email": "marcelina.davis@example.com",
            "email_verified": True,
            "external_id": "f1ffa2b2-c20b-4d39-be5c-212726e11222",
            "last_sign_in_at": "2025-06-25T19:07:33.000Z",
            "locale": "en-US",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = User.from_dict(data)
        serialized = instance.to_dict()
        assert "metadata" not in serialized

    def test_user_preserves_nullable_fields(self):
        data = {
            "object": "user",
            "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "first_name": None,
            "last_name": None,
            "name": None,
            "profile_picture_url": None,
            "email": "marcelina.davis@example.com",
            "email_verified": True,
            "external_id": None,
            "metadata": {"timezone": "America/New_York"},
            "last_sign_in_at": None,
            "locale": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = User.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["first_name"] is None
        assert serialized["last_name"] is None
        assert serialized["name"] is None
        assert serialized["profile_picture_url"] is None
        assert serialized["external_id"] is None
        assert serialized["last_sign_in_at"] is None
        assert serialized["locale"] is None

    def test_cors_origin_response_round_trip(self):
        data = load_fixture("cors_origin_response.json")
        instance = CORSOriginResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = CORSOriginResponse.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_cors_origin_response_minimal_payload(self):
        data = {
            "object": "cors_origin",
            "id": "cors_origin_01HXYZ123456789ABCDEFGHIJ",
            "origin": "https://example.com",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = CORSOriginResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["origin"] == data["origin"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]

    def test_radar_challenge_round_trip(self):
        data = load_fixture("radar_challenge.json")
        instance = RadarChallenge.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = RadarChallenge.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_radar_challenge_minimal_payload(self):
        data = {
            "object": "radar_challenge",
            "id": "radar_challenge_01HWZBQZY2M3AMQW166Q22K88F",
            "type": "email",
            "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "email": "marcelina.davis@example.com",
            "expires_at": "2026-01-15T12:00:00.000Z",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "code": "123456",
        }
        instance = RadarChallenge.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["type"] == data["type"]
        assert serialized["user_id"] == data["user_id"]
        assert serialized["email"] == data["email"]
        assert serialized["expires_at"] == data["expires_at"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]
        assert serialized["code"] == data["code"]

    def test_send_radar_sms_challenge_response_round_trip(self):
        data = load_fixture("send_radar_sms_challenge_response.json")
        instance = SendRadarSmsChallengeResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = SendRadarSmsChallengeResponse.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_send_radar_sms_challenge_response_minimal_payload(self):
        data = {
            "verification_id": "vrf_01HXYZ123456789ABCDEFGHIJ",
            "phone_number": "+15555550123",
        }
        instance = SendRadarSmsChallengeResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["verification_id"] == data["verification_id"]
        assert serialized["phone_number"] == data["phone_number"]

    def test_redirect_uri_round_trip(self):
        data = load_fixture("redirect_uri.json")
        instance = RedirectUri.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = RedirectUri.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_redirect_uri_minimal_payload(self):
        data = {
            "object": "redirect_uri",
            "id": "redir_01EHZNVPK3SFK441A1RGBFSHRT",
            "uri": "https://example.com/callback",
            "default": True,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = RedirectUri.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["uri"] == data["uri"]
        assert serialized["default"] == data["default"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]

    def test_magic_auth_round_trip(self):
        data = load_fixture("magic_auth.json")
        instance = MagicAuth.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = MagicAuth.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_magic_auth_minimal_payload(self):
        data = {
            "object": "magic_auth",
            "id": "magic_auth_01HWZBQZY2M3AMQW166Q22K88F",
            "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "email": "marcelina.davis@example.com",
            "expires_at": "2026-01-15T12:00:00.000Z",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "code": "123456",
        }
        instance = MagicAuth.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["user_id"] == data["user_id"]
        assert serialized["email"] == data["email"]
        assert serialized["expires_at"] == data["expires_at"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]
        assert serialized["code"] == data["code"]

    def test_user_invite_round_trip(self):
        data = load_fixture("user_invite.json")
        instance = UserInvite.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = UserInvite.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_user_invite_minimal_payload(self):
        data = {
            "object": "invitation",
            "id": "invitation_01E4ZCR3C56J083X43JQXF3JK5",
            "email": "marcelina.davis@example.com",
            "state": "pending",
            "accepted_at": None,
            "revoked_at": None,
            "expires_at": "2026-01-15T12:00:00.000Z",
            "organization_id": None,
            "inviter_user_id": None,
            "accepted_user_id": None,
            "role_slug": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "token": "Z1uX3RbwcIl5fIGJJJCXXisdI",
            "accept_invitation_url": "https://your-app.com/invite?invitation_token=Z1uX3RbwcIl5fIGJJJCXXisdI",
        }
        instance = UserInvite.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["email"] == data["email"]
        assert serialized["state"] == data["state"]
        assert serialized["accepted_at"] == data["accepted_at"]
        assert serialized["revoked_at"] == data["revoked_at"]
        assert serialized["expires_at"] == data["expires_at"]
        assert serialized["organization_id"] == data["organization_id"]
        assert serialized["inviter_user_id"] == data["inviter_user_id"]
        assert serialized["accepted_user_id"] == data["accepted_user_id"]
        assert serialized["role_slug"] == data["role_slug"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]
        assert serialized["token"] == data["token"]
        assert serialized["accept_invitation_url"] == data["accept_invitation_url"]

    def test_user_invite_preserves_nullable_fields(self):
        data = {
            "object": "invitation",
            "id": "invitation_01E4ZCR3C56J083X43JQXF3JK5",
            "email": "marcelina.davis@example.com",
            "state": "pending",
            "accepted_at": None,
            "revoked_at": None,
            "expires_at": "2026-01-15T12:00:00.000Z",
            "organization_id": None,
            "inviter_user_id": None,
            "accepted_user_id": None,
            "role_slug": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "token": "Z1uX3RbwcIl5fIGJJJCXXisdI",
            "accept_invitation_url": "https://your-app.com/invite?invitation_token=Z1uX3RbwcIl5fIGJJJCXXisdI",
        }
        instance = UserInvite.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["accepted_at"] is None
        assert serialized["revoked_at"] is None
        assert serialized["organization_id"] is None
        assert serialized["inviter_user_id"] is None
        assert serialized["accepted_user_id"] is None
        assert serialized["role_slug"] is None

    def test_user_invite_round_trips_unknown_enum_values(self):
        data = {
            "object": "invitation",
            "id": "invitation_01E4ZCR3C56J083X43JQXF3JK5",
            "email": "marcelina.davis@example.com",
            "state": "unexpected_user_invite_state",
            "accepted_at": None,
            "revoked_at": None,
            "expires_at": "2026-01-15T12:00:00.000Z",
            "organization_id": "org_01E4ZCR3C56J083X43JQXF3JK5",
            "inviter_user_id": "user_01HYGBX8ZGD19949T3BM4FW1C3",
            "accepted_user_id": None,
            "role_slug": "admin",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "token": "Z1uX3RbwcIl5fIGJJJCXXisdI",
            "accept_invitation_url": "https://your-app.com/invite?invitation_token=Z1uX3RbwcIl5fIGJJJCXXisdI",
        }
        instance = UserInvite.from_dict(data)
        assert instance.to_dict() == data

    def test_user_api_key_round_trip(self):
        data = load_fixture("user_api_key.json")
        instance = UserApiKey.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = UserApiKey.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_user_api_key_minimal_payload(self):
        data = {
            "object": "api_key",
            "id": "api_key_01EHZNVPK3SFK441A1RGBFSHRT",
            "owner": {
                "type": "user",
                "id": "user_01EHZNVPK3SFK441A1RGBFSHRT",
                "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT",
            },
            "name": "Production API Key",
            "obfuscated_value": "sk_...3456",
            "last_used_at": None,
            "expires_at": None,
            "permissions": ["posts:read", "posts:write"],
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = UserApiKey.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["owner"] == data["owner"]
        assert serialized["name"] == data["name"]
        assert serialized["obfuscated_value"] == data["obfuscated_value"]
        assert serialized["last_used_at"] == data["last_used_at"]
        assert serialized["expires_at"] == data["expires_at"]
        assert serialized["permissions"] == data["permissions"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]

    def test_user_api_key_preserves_nullable_fields(self):
        data = {
            "object": "api_key",
            "id": "api_key_01EHZNVPK3SFK441A1RGBFSHRT",
            "owner": {
                "type": "user",
                "id": "user_01EHZNVPK3SFK441A1RGBFSHRT",
                "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT",
            },
            "name": "Production API Key",
            "obfuscated_value": "sk_...3456",
            "last_used_at": None,
            "expires_at": None,
            "permissions": ["posts:read", "posts:write"],
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = UserApiKey.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["last_used_at"] is None
        assert serialized["expires_at"] is None

    def test_user_api_key_with_value_round_trip(self):
        data = load_fixture("user_api_key_with_value.json")
        instance = UserApiKeyWithValue.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = UserApiKeyWithValue.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_user_api_key_with_value_minimal_payload(self):
        data = {
            "object": "api_key",
            "id": "api_key_01EHZNVPK3SFK441A1RGBFSHRT",
            "owner": {
                "type": "user",
                "id": "user_01EHZNVPK3SFK441A1RGBFSHRT",
                "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT",
            },
            "name": "Production API Key",
            "obfuscated_value": "sk_...3456",
            "last_used_at": None,
            "expires_at": None,
            "permissions": ["posts:read", "posts:write"],
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "value": "sk_abcdefghijklmnop123456",
        }
        instance = UserApiKeyWithValue.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["owner"] == data["owner"]
        assert serialized["name"] == data["name"]
        assert serialized["obfuscated_value"] == data["obfuscated_value"]
        assert serialized["last_used_at"] == data["last_used_at"]
        assert serialized["expires_at"] == data["expires_at"]
        assert serialized["permissions"] == data["permissions"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]
        assert serialized["value"] == data["value"]

    def test_user_api_key_with_value_preserves_nullable_fields(self):
        data = {
            "object": "api_key",
            "id": "api_key_01EHZNVPK3SFK441A1RGBFSHRT",
            "owner": {
                "type": "user",
                "id": "user_01EHZNVPK3SFK441A1RGBFSHRT",
                "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT",
            },
            "name": "Production API Key",
            "obfuscated_value": "sk_...3456",
            "last_used_at": None,
            "expires_at": None,
            "permissions": ["posts:read", "posts:write"],
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "value": "sk_abcdefghijklmnop123456",
        }
        instance = UserApiKeyWithValue.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["last_used_at"] is None
        assert serialized["expires_at"] is None

    def test_email_verification_round_trip(self):
        data = load_fixture("email_verification.json")
        instance = EmailVerification.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = EmailVerification.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_email_verification_minimal_payload(self):
        data = {
            "object": "email_verification",
            "id": "email_verification_01E4ZCR3C56J083X43JQXF3JK5",
            "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "email": "marcelina.davis@example.com",
            "expires_at": "2026-01-15T12:00:00.000Z",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "code": "123456",
        }
        instance = EmailVerification.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["user_id"] == data["user_id"]
        assert serialized["email"] == data["email"]
        assert serialized["expires_at"] == data["expires_at"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]
        assert serialized["code"] == data["code"]

    def test_send_verification_email_response_round_trip(self):
        data = load_fixture("send_verification_email_response.json")
        instance = SendVerificationEmailResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = SendVerificationEmailResponse.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_send_verification_email_response_minimal_payload(self):
        data = {
            "user": {
                "object": "user",
                "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
                "first_name": "Marcelina",
                "last_name": "Davis",
                "name": "Marcelina Davis",
                "profile_picture_url": "https://workoscdn.com/images/v1/123abc",
                "email": "marcelina.davis@example.com",
                "email_verified": True,
                "external_id": "f1ffa2b2-c20b-4d39-be5c-212726e11222",
                "metadata": {"timezone": "America/New_York"},
                "last_sign_in_at": "2025-06-25T19:07:33.000Z",
                "locale": "en-US",
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
            }
        }
        instance = SendVerificationEmailResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["user"] == data["user"]

    def test_verify_email_response_round_trip(self):
        data = load_fixture("verify_email_response.json")
        instance = VerifyEmailResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = VerifyEmailResponse.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_verify_email_response_minimal_payload(self):
        data = {
            "user": {
                "object": "user",
                "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
                "first_name": "Marcelina",
                "last_name": "Davis",
                "name": "Marcelina Davis",
                "profile_picture_url": "https://workoscdn.com/images/v1/123abc",
                "email": "marcelina.davis@example.com",
                "email_verified": True,
                "external_id": "f1ffa2b2-c20b-4d39-be5c-212726e11222",
                "metadata": {"timezone": "America/New_York"},
                "last_sign_in_at": "2025-06-25T19:07:33.000Z",
                "locale": "en-US",
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
            }
        }
        instance = VerifyEmailResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["user"] == data["user"]

    def test_password_reset_round_trip(self):
        data = load_fixture("password_reset.json")
        instance = PasswordReset.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = PasswordReset.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_password_reset_minimal_payload(self):
        data = {
            "object": "password_reset",
            "id": "password_reset_01E4ZCR3C56J083X43JQXF3JK5",
            "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "email": "marcelina.davis@example.com",
            "expires_at": "2026-01-15T12:00:00.000Z",
            "created_at": "2026-01-15T12:00:00.000Z",
            "password_reset_token": "Z1uX3RbwcIl5fIGJJJCXXisdI",
            "password_reset_url": "https://your-app.com/reset-password?token=Z1uX3RbwcIl5fIGJJJCXXisdI",
        }
        instance = PasswordReset.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["user_id"] == data["user_id"]
        assert serialized["email"] == data["email"]
        assert serialized["expires_at"] == data["expires_at"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["password_reset_token"] == data["password_reset_token"]
        assert serialized["password_reset_url"] == data["password_reset_url"]

    def test_reset_password_response_round_trip(self):
        data = load_fixture("reset_password_response.json")
        instance = ResetPasswordResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = ResetPasswordResponse.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_reset_password_response_minimal_payload(self):
        data = {
            "user": {
                "object": "user",
                "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
                "first_name": "Marcelina",
                "last_name": "Davis",
                "name": "Marcelina Davis",
                "profile_picture_url": "https://workoscdn.com/images/v1/123abc",
                "email": "marcelina.davis@example.com",
                "email_verified": True,
                "external_id": "f1ffa2b2-c20b-4d39-be5c-212726e11222",
                "metadata": {"timezone": "America/New_York"},
                "last_sign_in_at": "2025-06-25T19:07:33.000Z",
                "locale": "en-US",
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
            }
        }
        instance = ResetPasswordResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["user"] == data["user"]

    def test_email_change_round_trip(self):
        data = load_fixture("email_change.json")
        instance = EmailChange.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = EmailChange.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_email_change_minimal_payload(self):
        data = {
            "object": "email_change",
            "user": {
                "object": "user",
                "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
                "first_name": "Marcelina",
                "last_name": "Davis",
                "name": "Marcelina Davis",
                "profile_picture_url": "https://workoscdn.com/images/v1/123abc",
                "email": "marcelina.davis@example.com",
                "email_verified": True,
                "external_id": "f1ffa2b2-c20b-4d39-be5c-212726e11222",
                "metadata": {"timezone": "America/New_York"},
                "last_sign_in_at": "2025-06-25T19:07:33.000Z",
                "locale": "en-US",
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
            },
            "new_email": "new.email@example.com",
            "expires_at": "2026-01-15T12:00:00.000Z",
            "created_at": "2026-01-15T12:00:00.000Z",
        }
        instance = EmailChange.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["user"] == data["user"]
        assert serialized["new_email"] == data["new_email"]
        assert serialized["expires_at"] == data["expires_at"]
        assert serialized["created_at"] == data["created_at"]

    def test_authenticate_response_round_trip(self):
        data = load_fixture("authenticate_response.json")
        instance = AuthenticateResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AuthenticateResponse.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_authenticate_response_minimal_payload(self):
        data = {
            "user": {
                "object": "user",
                "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
                "first_name": "Marcelina",
                "last_name": "Davis",
                "name": "Marcelina Davis",
                "profile_picture_url": "https://workoscdn.com/images/v1/123abc",
                "email": "marcelina.davis@example.com",
                "email_verified": True,
                "external_id": "f1ffa2b2-c20b-4d39-be5c-212726e11222",
                "metadata": {"timezone": "America/New_York"},
                "last_sign_in_at": "2025-06-25T19:07:33.000Z",
                "locale": "en-US",
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
            },
            "access_token": "eyJhb.nNzb19vaWRjX2tleV9.lc5Uk4yWVk5In0",
            "refresh_token": "yAjhKk123NLIjdrBdGZPf8pLIDvK",
        }
        instance = AuthenticateResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["user"] == data["user"]
        assert serialized["access_token"] == data["access_token"]
        assert serialized["refresh_token"] == data["refresh_token"]

    def test_authenticate_response_omits_absent_optional_non_nullable_fields(self):
        data = {
            "user": {
                "object": "user",
                "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
                "first_name": "Marcelina",
                "last_name": "Davis",
                "name": "Marcelina Davis",
                "profile_picture_url": "https://workoscdn.com/images/v1/123abc",
                "email": "marcelina.davis@example.com",
                "email_verified": True,
                "external_id": "f1ffa2b2-c20b-4d39-be5c-212726e11222",
                "metadata": {"timezone": "America/New_York"},
                "last_sign_in_at": "2025-06-25T19:07:33.000Z",
                "locale": "en-US",
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
            },
            "access_token": "eyJhb.nNzb19vaWRjX2tleV9.lc5Uk4yWVk5In0",
            "refresh_token": "yAjhKk123NLIjdrBdGZPf8pLIDvK",
        }
        instance = AuthenticateResponse.from_dict(data)
        serialized = instance.to_dict()
        assert "organization_id" not in serialized
        assert "authkit_authorization_code" not in serialized
        assert "authentication_method" not in serialized
        assert "impersonator" not in serialized
        assert "oauth_tokens" not in serialized

    def test_authenticate_response_round_trips_unknown_enum_values(self):
        data = {
            "user": {
                "object": "user",
                "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
                "first_name": "Marcelina",
                "last_name": "Davis",
                "name": "Marcelina Davis",
                "profile_picture_url": "https://workoscdn.com/images/v1/123abc",
                "email": "marcelina.davis@example.com",
                "email_verified": True,
                "external_id": "f1ffa2b2-c20b-4d39-be5c-212726e11222",
                "metadata": {"timezone": "America/New_York"},
                "last_sign_in_at": "2025-06-25T19:07:33.000Z",
                "locale": "en-US",
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
            },
            "organization_id": "org_01H945H0YD4F97JN9MATX7BYAG",
            "authkit_authorization_code": "authkit_authz_code_abc123",
            "access_token": "eyJhb.nNzb19vaWRjX2tleV9.lc5Uk4yWVk5In0",
            "refresh_token": "yAjhKk123NLIjdrBdGZPf8pLIDvK",
            "authentication_method": "unexpected_authenticate_response_authentication_method",
            "impersonator": {
                "email": "admin@foocorp.com",
                "reason": "Investigating an issue with the customer's account.",
            },
            "oauth_tokens": {
                "provider": "GoogleOAuth",
                "refresh_token": "1//04g...",
                "access_token": "ya29.a0ARrdaM...",
                "expires_at": 1735141800,
                "scopes": ["profile", "email", "openid"],
            },
        }
        instance = AuthenticateResponse.from_dict(data)
        assert instance.to_dict() == data

    def test_device_authorization_response_round_trip(self):
        data = load_fixture("device_authorization_response.json")
        instance = DeviceAuthorizationResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = DeviceAuthorizationResponse.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_device_authorization_response_minimal_payload(self):
        data = {
            "device_code": "CVE2wOfIFK4vhmiDBntpX9s8KT2f0qngpWYL0LGy9HxYgBRXUKIUkZB9BgIFho5h",
            "user_code": "BCDF-GHJK",
            "verification_uri": "https://authkit_domain/device",
            "expires_in": 300,
        }
        instance = DeviceAuthorizationResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["device_code"] == data["device_code"]
        assert serialized["user_code"] == data["user_code"]
        assert serialized["verification_uri"] == data["verification_uri"]
        assert serialized["expires_in"] == data["expires_in"]

    def test_device_authorization_response_omits_absent_optional_non_nullable_fields(
        self,
    ):
        data = {
            "device_code": "CVE2wOfIFK4vhmiDBntpX9s8KT2f0qngpWYL0LGy9HxYgBRXUKIUkZB9BgIFho5h",
            "user_code": "BCDF-GHJK",
            "verification_uri": "https://authkit_domain/device",
            "expires_in": 300,
        }
        instance = DeviceAuthorizationResponse.from_dict(data)
        serialized = instance.to_dict()
        assert "verification_uri_complete" not in serialized
        assert "interval" not in serialized

    def test_jwks_response_round_trip(self):
        data = load_fixture("jwks_response.json")
        instance = JwksResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = JwksResponse.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_jwks_response_minimal_payload(self):
        data = {
            "keys": [
                {
                    "alg": "RS256",
                    "kty": "RSA",
                    "use": "sig",
                    "x5c": ["MIIDQjCCAiqgAwIBAgIGATz/FuLiMA0GCSqGSIb3DQEBCwUA..."],
                    "n": "0vx7agoebGc...eKnNs",
                    "e": "AQAB",
                    "kid": "key_01HXYZ123456789ABCDEFGHIJ",
                    "x5t#S256": "ZjQzYjI0OT...NmNjU0",
                }
            ]
        }
        instance = JwksResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["keys"] == data["keys"]

    def test_jwt_template_response_round_trip(self):
        data = load_fixture("jwt_template_response.json")
        instance = JWTTemplateResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = JWTTemplateResponse.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_jwt_template_response_minimal_payload(self):
        data = {
            "object": "jwt_template",
            "content": '{"urn:myapp:full_name": "{{user.first_name}} {{user.last_name}}", "urn:myapp:email": "{{user.email}}"}',
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = JWTTemplateResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["content"] == data["content"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]

    def test_jwks_response_keys_round_trip(self):
        data = load_fixture("jwks_response_keys.json")
        instance = JwksResponseKeys.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = JwksResponseKeys.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_jwks_response_keys_minimal_payload(self):
        data = {
            "alg": "RS256",
            "kty": "RSA",
            "use": "sig",
            "x5c": ["MIIDQjCCAiqgAwIBAgIGATz/FuLiMA0GCSqGSIb3DQEBCwUA..."],
            "n": "0vx7agoebGc...eKnNs",
            "e": "AQAB",
            "kid": "key_01HXYZ123456789ABCDEFGHIJ",
            "x5t#S256": "ZjQzYjI0OT...NmNjU0",
        }
        instance = JwksResponseKeys.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["alg"] == data["alg"]
        assert serialized["kty"] == data["kty"]
        assert serialized["use"] == data["use"]
        assert serialized["x5c"] == data["x5c"]
        assert serialized["n"] == data["n"]
        assert serialized["e"] == data["e"]
        assert serialized["kid"] == data["kid"]
        assert serialized["x5t#S256"] == data["x5t#S256"]

    def test_authenticate_response_impersonator_round_trip(self):
        data = load_fixture("authenticate_response_impersonator.json")
        instance = AuthenticateResponseImpersonator.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AuthenticateResponseImpersonator.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_authenticate_response_impersonator_minimal_payload(self):
        data = {"email": "admin@foocorp.com", "reason": None}
        instance = AuthenticateResponseImpersonator.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["email"] == data["email"]
        assert serialized["reason"] == data["reason"]

    def test_authenticate_response_impersonator_preserves_nullable_fields(self):
        data = {"email": "admin@foocorp.com", "reason": None}
        instance = AuthenticateResponseImpersonator.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["reason"] is None

    def test_authenticate_response_oauth_token_round_trip(self):
        data = load_fixture("authenticate_response_oauth_token.json")
        instance = AuthenticateResponseOAuthToken.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AuthenticateResponseOAuthToken.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_authenticate_response_oauth_token_minimal_payload(self):
        data = {
            "provider": "GoogleOAuth",
            "refresh_token": "1//04g...",
            "access_token": "ya29.a0ARrdaM...",
            "expires_at": 1735141800,
            "scopes": ["profile", "email", "openid"],
        }
        instance = AuthenticateResponseOAuthToken.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["provider"] == data["provider"]
        assert serialized["refresh_token"] == data["refresh_token"]
        assert serialized["access_token"] == data["access_token"]
        assert serialized["expires_at"] == data["expires_at"]
        assert serialized["scopes"] == data["scopes"]

    def test_user_api_key_with_value_owner_round_trip(self):
        data = load_fixture("user_api_key_with_value_owner.json")
        instance = UserApiKeyWithValueOwner.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = UserApiKeyWithValueOwner.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_user_api_key_with_value_owner_minimal_payload(self):
        data = {
            "type": "user",
            "id": "user_01EHZNVPK3SFK441A1RGBFSHRT",
            "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT",
        }
        instance = UserApiKeyWithValueOwner.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["type"] == data["type"]
        assert serialized["id"] == data["id"]
        assert serialized["organization_id"] == data["organization_id"]

    def test_user_api_key_owner_round_trip(self):
        data = load_fixture("user_api_key_owner.json")
        instance = UserApiKeyOwner.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = UserApiKeyOwner.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_user_api_key_owner_minimal_payload(self):
        data = {
            "type": "user",
            "id": "user_01EHZNVPK3SFK441A1RGBFSHRT",
            "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT",
        }
        instance = UserApiKeyOwner.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["type"] == data["type"]
        assert serialized["id"] == data["id"]
        assert serialized["organization_id"] == data["organization_id"]

    def test_authorized_connect_application_list_data_round_trip(self):
        data = load_fixture("authorized_connect_application_list_data.json")
        instance = AuthorizedConnectApplicationListData.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AuthorizedConnectApplicationListData.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_authorized_connect_application_list_data_minimal_payload(self):
        data = {
            "object": "authorized_connect_application",
            "id": "authorized_connect_app_01HXYZ123456789ABCDEFGHIJ",
            "granted_scopes": ["openid", "profile", "email"],
            "application": {
                "object": "connect_application",
                "id": "conn_app_01HXYZ123456789ABCDEFGHIJ",
                "client_id": "client_01HXYZ123456789ABCDEFGHIJ",
                "description": "An application for managing user access",
                "name": "My Application",
                "scopes": ["openid", "profile", "email"],
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
                "application_type": "oauth",
                "redirect_uris": [
                    {"uri": "https://example.com/callback", "default": True}
                ],
                "uses_pkce": True,
                "is_first_party": True,
                "was_dynamically_registered": True,
                "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT",
            },
        }
        instance = AuthorizedConnectApplicationListData.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["granted_scopes"] == data["granted_scopes"]
        assert serialized["application"] == data["application"]

    def test_authorized_connect_application_list_data_omits_absent_optional_non_nullable_fields(
        self,
    ):
        data = {
            "object": "authorized_connect_application",
            "id": "authorized_connect_app_01HXYZ123456789ABCDEFGHIJ",
            "granted_scopes": ["openid", "profile", "email"],
            "application": {
                "object": "connect_application",
                "id": "conn_app_01HXYZ123456789ABCDEFGHIJ",
                "client_id": "client_01HXYZ123456789ABCDEFGHIJ",
                "description": "An application for managing user access",
                "name": "My Application",
                "scopes": ["openid", "profile", "email"],
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
                "application_type": "oauth",
                "redirect_uris": [
                    {"uri": "https://example.com/callback", "default": True}
                ],
                "uses_pkce": True,
                "is_first_party": True,
                "was_dynamically_registered": True,
                "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT",
            },
        }
        instance = AuthorizedConnectApplicationListData.from_dict(data)
        serialized = instance.to_dict()
        assert "oauth_resource" not in serialized

    def test_invitation_round_trip(self):
        data = load_fixture("invitation.json")
        instance = Invitation.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = Invitation.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_invitation_minimal_payload(self):
        data = {
            "object": "invitation",
            "id": "invitation_01E4ZCR3C56J083X43JQXF3JK5",
            "email": "marcelina.davis@example.com",
            "state": "accepted",
            "accepted_at": None,
            "revoked_at": None,
            "expires_at": "2026-01-15T12:00:00.000Z",
            "organization_id": None,
            "inviter_user_id": None,
            "accepted_user_id": None,
            "role_slug": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "token": "Z1uX3RbwcIl5fIGJJJCXXisdI",
            "accept_invitation_url": "https://your-app.com/invite?invitation_token=Z1uX3RbwcIl5fIGJJJCXXisdI",
        }
        instance = Invitation.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["email"] == data["email"]
        assert serialized["state"] == data["state"]
        assert serialized["accepted_at"] == data["accepted_at"]
        assert serialized["revoked_at"] == data["revoked_at"]
        assert serialized["expires_at"] == data["expires_at"]
        assert serialized["organization_id"] == data["organization_id"]
        assert serialized["inviter_user_id"] == data["inviter_user_id"]
        assert serialized["accepted_user_id"] == data["accepted_user_id"]
        assert serialized["role_slug"] == data["role_slug"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]
        assert serialized["token"] == data["token"]
        assert serialized["accept_invitation_url"] == data["accept_invitation_url"]

    def test_invitation_preserves_nullable_fields(self):
        data = {
            "object": "invitation",
            "id": "invitation_01E4ZCR3C56J083X43JQXF3JK5",
            "email": "marcelina.davis@example.com",
            "state": "accepted",
            "accepted_at": None,
            "revoked_at": None,
            "expires_at": "2026-01-15T12:00:00.000Z",
            "organization_id": None,
            "inviter_user_id": None,
            "accepted_user_id": None,
            "role_slug": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "token": "Z1uX3RbwcIl5fIGJJJCXXisdI",
            "accept_invitation_url": "https://your-app.com/invite?invitation_token=Z1uX3RbwcIl5fIGJJJCXXisdI",
        }
        instance = Invitation.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["accepted_at"] is None
        assert serialized["revoked_at"] is None
        assert serialized["organization_id"] is None
        assert serialized["inviter_user_id"] is None
        assert serialized["accepted_user_id"] is None
        assert serialized["role_slug"] is None

    def test_invitation_round_trips_unknown_enum_values(self):
        data = {
            "object": "invitation",
            "id": "invitation_01E4ZCR3C56J083X43JQXF3JK5",
            "email": "marcelina.davis@example.com",
            "state": "unexpected_invitation_state",
            "accepted_at": "2026-01-15T12:00:00.000Z",
            "revoked_at": None,
            "expires_at": "2026-01-15T12:00:00.000Z",
            "organization_id": "org_01E4ZCR3C56J083X43JQXF3JK5",
            "inviter_user_id": "user_01HYGBX8ZGD19949T3BM4FW1C3",
            "accepted_user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "role_slug": "admin",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "token": "Z1uX3RbwcIl5fIGJJJCXXisdI",
            "accept_invitation_url": "https://your-app.com/invite?invitation_token=Z1uX3RbwcIl5fIGJJJCXXisdI",
        }
        instance = Invitation.from_dict(data)
        assert instance.to_dict() == data

    def test_magic_auth_send_magic_auth_code_and_return_response_round_trip(self):
        data = load_fixture("magic_auth_send_magic_auth_code_and_return_response.json")
        instance = MagicAuthSendMagicAuthCodeAndReturnResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = MagicAuthSendMagicAuthCodeAndReturnResponse.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_magic_auth_send_magic_auth_code_and_return_response_minimal_payload(self):
        data = {
            "object": "magic_auth",
            "id": "magic_auth_01HWZBQZY2M3AMQW166Q22K88F",
            "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "email": "marcelina.davis@example.com",
            "expires_at": "2026-01-15T12:00:00.000Z",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "code": "123456",
        }
        instance = MagicAuthSendMagicAuthCodeAndReturnResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["user_id"] == data["user_id"]
        assert serialized["email"] == data["email"]
        assert serialized["expires_at"] == data["expires_at"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]
        assert serialized["code"] == data["code"]

    def test_magic_auth_send_magic_auth_code_and_return_response_omits_absent_optional_non_nullable_fields(
        self,
    ):
        data = {
            "object": "magic_auth",
            "id": "magic_auth_01HWZBQZY2M3AMQW166Q22K88F",
            "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "email": "marcelina.davis@example.com",
            "expires_at": "2026-01-15T12:00:00.000Z",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "code": "123456",
        }
        instance = MagicAuthSendMagicAuthCodeAndReturnResponse.from_dict(data)
        serialized = instance.to_dict()
        assert "radar_auth_attempt_id" not in serialized

    def test_user_create_response_round_trip(self):
        data = load_fixture("user_create_response.json")
        instance = UserCreateResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = UserCreateResponse.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_user_create_response_minimal_payload(self):
        data = {
            "object": "user",
            "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "first_name": None,
            "last_name": None,
            "profile_picture_url": None,
            "email": "marcelina.davis@example.com",
            "email_verified": True,
            "external_id": None,
            "last_sign_in_at": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = UserCreateResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["first_name"] == data["first_name"]
        assert serialized["last_name"] == data["last_name"]
        assert serialized["profile_picture_url"] == data["profile_picture_url"]
        assert serialized["email"] == data["email"]
        assert serialized["email_verified"] == data["email_verified"]
        assert serialized["external_id"] == data["external_id"]
        assert serialized["last_sign_in_at"] == data["last_sign_in_at"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]

    def test_user_create_response_omits_absent_optional_non_nullable_fields(self):
        data = {
            "object": "user",
            "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "first_name": "Marcelina",
            "last_name": "Davis",
            "name": "Marcelina Davis",
            "profile_picture_url": "https://workoscdn.com/images/v1/123abc",
            "email": "marcelina.davis@example.com",
            "email_verified": True,
            "external_id": "f1ffa2b2-c20b-4d39-be5c-212726e11222",
            "last_sign_in_at": "2025-06-25T19:07:33.000Z",
            "locale": "en-US",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = UserCreateResponse.from_dict(data)
        serialized = instance.to_dict()
        assert "metadata" not in serialized
        assert "radar_auth_attempt_id" not in serialized

    def test_user_create_response_preserves_nullable_fields(self):
        data = {
            "object": "user",
            "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "first_name": None,
            "last_name": None,
            "name": None,
            "profile_picture_url": None,
            "email": "marcelina.davis@example.com",
            "email_verified": True,
            "external_id": None,
            "metadata": {"timezone": "America/New_York"},
            "last_sign_in_at": None,
            "locale": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "radar_auth_attempt_id": "radar_auth_attempt_01HXYZ123456789ABCDEFGHIJ",
        }
        instance = UserCreateResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["first_name"] is None
        assert serialized["last_name"] is None
        assert serialized["name"] is None
        assert serialized["profile_picture_url"] is None
        assert serialized["external_id"] is None
        assert serialized["last_sign_in_at"] is None
        assert serialized["locale"] is None

    def test_email_change_confirmation_round_trip(self):
        data = load_fixture("email_change_confirmation.json")
        instance = EmailChangeConfirmation.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = EmailChangeConfirmation.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_email_change_confirmation_minimal_payload(self):
        data = {
            "object": "email_change_confirmation",
            "user": {
                "object": "user",
                "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
                "first_name": "Marcelina",
                "last_name": "Davis",
                "name": "Marcelina Davis",
                "profile_picture_url": "https://workoscdn.com/images/v1/123abc",
                "email": "new.email@example.com",
                "email_verified": True,
                "external_id": "f1ffa2b2-c20b-4d39-be5c-212726e11222",
                "metadata": {"timezone": "America/New_York"},
                "last_sign_in_at": "2025-06-25T19:07:33.000Z",
                "locale": "en-US",
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
            },
        }
        instance = EmailChangeConfirmation.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["user"] == data["user"]

    def test_email_change_confirmation_user_round_trip(self):
        data = load_fixture("email_change_confirmation_user.json")
        instance = EmailChangeConfirmationUser.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = EmailChangeConfirmationUser.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_email_change_confirmation_user_minimal_payload(self):
        data = {
            "object": "user",
            "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "first_name": None,
            "last_name": None,
            "profile_picture_url": None,
            "email": "new.email@example.com",
            "email_verified": True,
            "external_id": None,
            "last_sign_in_at": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = EmailChangeConfirmationUser.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["first_name"] == data["first_name"]
        assert serialized["last_name"] == data["last_name"]
        assert serialized["profile_picture_url"] == data["profile_picture_url"]
        assert serialized["email"] == data["email"]
        assert serialized["email_verified"] == data["email_verified"]
        assert serialized["external_id"] == data["external_id"]
        assert serialized["last_sign_in_at"] == data["last_sign_in_at"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]

    def test_email_change_confirmation_user_omits_absent_optional_non_nullable_fields(
        self,
    ):
        data = {
            "object": "user",
            "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "first_name": "Marcelina",
            "last_name": "Davis",
            "name": "Marcelina Davis",
            "profile_picture_url": "https://workoscdn.com/images/v1/123abc",
            "email": "new.email@example.com",
            "email_verified": True,
            "external_id": "f1ffa2b2-c20b-4d39-be5c-212726e11222",
            "last_sign_in_at": "2025-06-25T19:07:33.000Z",
            "locale": "en-US",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = EmailChangeConfirmationUser.from_dict(data)
        serialized = instance.to_dict()
        assert "metadata" not in serialized

    def test_email_change_confirmation_user_preserves_nullable_fields(self):
        data = {
            "object": "user",
            "id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "first_name": None,
            "last_name": None,
            "name": None,
            "profile_picture_url": None,
            "email": "new.email@example.com",
            "email_verified": True,
            "external_id": None,
            "metadata": {"timezone": "America/New_York"},
            "last_sign_in_at": None,
            "locale": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = EmailChangeConfirmationUser.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["first_name"] is None
        assert serialized["last_name"] is None
        assert serialized["name"] is None
        assert serialized["profile_picture_url"] is None
        assert serialized["external_id"] is None
        assert serialized["last_sign_in_at"] is None
        assert serialized["locale"] is None

    def test_user_identities_get_item_round_trip(self):
        data = load_fixture("user_identities_get_item.json")
        instance = UserIdentitiesGetItem.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = UserIdentitiesGetItem.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_user_identities_get_item_minimal_payload(self):
        data = {
            "idp_id": "4F42ABDE-1E44-4B66-824A-5F733C037A6D",
            "type": "OAuth",
            "provider": "MicrosoftOAuth",
        }
        instance = UserIdentitiesGetItem.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["idp_id"] == data["idp_id"]
        assert serialized["type"] == data["type"]
        assert serialized["provider"] == data["provider"]

    def test_user_identities_get_item_round_trips_unknown_enum_values(self):
        data = {
            "idp_id": "4F42ABDE-1E44-4B66-824A-5F733C037A6D",
            "type": "OAuth",
            "provider": "unexpected_user_identities_get_item_provider",
        }
        instance = UserIdentitiesGetItem.from_dict(data)
        assert instance.to_dict() == data

    def test_user_sessions_list_item_round_trip(self):
        data = load_fixture("user_sessions_list_item.json")
        instance = UserSessionsListItem.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = UserSessionsListItem.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_user_sessions_list_item_minimal_payload(self):
        data = {
            "object": "session",
            "id": "session_01H93ZY4F80QPBEZ1R5B2SHQG8",
            "ip_address": None,
            "user_agent": None,
            "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "auth_method": "sso",
            "status": "active",
            "expires_at": "2026-01-15T12:00:00.000Z",
            "ended_at": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = UserSessionsListItem.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["ip_address"] == data["ip_address"]
        assert serialized["user_agent"] == data["user_agent"]
        assert serialized["user_id"] == data["user_id"]
        assert serialized["auth_method"] == data["auth_method"]
        assert serialized["status"] == data["status"]
        assert serialized["expires_at"] == data["expires_at"]
        assert serialized["ended_at"] == data["ended_at"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]

    def test_user_sessions_list_item_omits_absent_optional_non_nullable_fields(self):
        data = {
            "object": "session",
            "id": "session_01H93ZY4F80QPBEZ1R5B2SHQG8",
            "ip_address": "198.51.100.42",
            "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36",
            "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "auth_method": "sso",
            "status": "active",
            "expires_at": "2026-01-15T12:00:00.000Z",
            "ended_at": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = UserSessionsListItem.from_dict(data)
        serialized = instance.to_dict()
        assert "impersonator" not in serialized
        assert "organization_id" not in serialized

    def test_user_sessions_list_item_preserves_nullable_fields(self):
        data = {
            "object": "session",
            "id": "session_01H93ZY4F80QPBEZ1R5B2SHQG8",
            "impersonator": {
                "email": "admin@foocorp.com",
                "reason": "Investigating an issue with the customer's account.",
            },
            "ip_address": None,
            "organization_id": "org_01H945H0YD4F97JN9MATX7BYAG",
            "user_agent": None,
            "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "auth_method": "sso",
            "status": "active",
            "expires_at": "2026-01-15T12:00:00.000Z",
            "ended_at": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = UserSessionsListItem.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["ip_address"] is None
        assert serialized["user_agent"] is None
        assert serialized["ended_at"] is None

    def test_user_sessions_list_item_round_trips_unknown_enum_values(self):
        data = {
            "object": "session",
            "id": "session_01H93ZY4F80QPBEZ1R5B2SHQG8",
            "impersonator": {
                "email": "admin@foocorp.com",
                "reason": "Investigating an issue with the customer's account.",
            },
            "ip_address": "198.51.100.42",
            "organization_id": "org_01H945H0YD4F97JN9MATX7BYAG",
            "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36",
            "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "auth_method": "unexpected_user_sessions_list_item_auth_method",
            "status": "active",
            "expires_at": "2026-01-15T12:00:00.000Z",
            "ended_at": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = UserSessionsListItem.from_dict(data)
        assert instance.to_dict() == data

    def test_user_sessions_impersonator_round_trip(self):
        data = load_fixture("user_sessions_impersonator.json")
        instance = UserSessionsImpersonator.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = UserSessionsImpersonator.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_user_sessions_impersonator_minimal_payload(self):
        data = {"email": "admin@foocorp.com", "reason": None}
        instance = UserSessionsImpersonator.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["email"] == data["email"]
        assert serialized["reason"] == data["reason"]

    def test_user_sessions_impersonator_preserves_nullable_fields(self):
        data = {"email": "admin@foocorp.com", "reason": None}
        instance = UserSessionsImpersonator.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["reason"] is None
