internal static CreateChatThreadResultInternal DeserializeCreateChatThreadResultInternal(JsonElement element)
        {
            Optional <ChatThreadPropertiesInternal> chatThread          = default;
            Optional <IReadOnlyList <ChatError> >   invalidParticipants = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("chatThread"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    chatThread = ChatThreadPropertiesInternal.DeserializeChatThreadPropertiesInternal(property.Value);
                    continue;
                }
                if (property.NameEquals("invalidParticipants"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ChatError> array = new List <ChatError>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ChatError.DeserializeChatError(item));
                    }
                    invalidParticipants = array;
                    continue;
                }
            }
            return(new CreateChatThreadResultInternal(chatThread.Value, Optional.ToList(invalidParticipants)));
        }
        internal static ChatErrorResponse DeserializeChatErrorResponse(JsonElement element)
        {
            ChatError error = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("error"))
                {
                    error = ChatError.DeserializeChatError(property.Value);
                    continue;
                }
            }
            return(new ChatErrorResponse(error));
        }