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)));
        }
Esempio n. 2
0
 internal ChatError(string code, string message, string target, IReadOnlyList <ChatError> details, ChatError innerError)
 {
     Code       = code;
     Message    = message;
     Target     = target;
     Details    = details;
     InnerError = innerError;
 }
        internal ChatErrorResponse(ChatError error)
        {
            if (error == null)
            {
                throw new ArgumentNullException(nameof(error));
            }

            Error = error;
        }
        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));
        }
 public static ChatError ChatError(string code = default, string message = default, string target = default, IReadOnlyList <ChatError> details = default, ChatError innerError = default)
 {
     details ??= new List <ChatError>();
     return(new ChatError(code, message, target, details, innerError));
 }
        public static ChatError ChatError(string code = null, string message = null, string target = null, IEnumerable <ChatError> details = null, ChatError innerError = null)
        {
            details ??= new List <ChatError>();

            return(new ChatError(code, message, target, details?.ToList(), innerError));
        }