// --------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// --------------------------------------------------------------------------

import AzureCore
import Foundation
// swiftlint:disable superfluous_disable_command
// swiftlint:disable identifier_name
// swiftlint:disable line_length
// swiftlint:disable cyclomatic_complexity

/// Request payload for creating a chat thread.
internal struct CreateChatThreadRequestInternal: Codable {
    // MARK: Properties

    /// The chat thread topic.
    internal let topic: String
    /// Participants to be added to the chat thread.
    internal let participants: [ChatParticipantInternal]?

    // MARK: Initializers

    /// Initialize a `CreateChatThreadRequestInternal` structure.
    /// - Parameters:
    ///   - topic: The chat thread topic.
    ///   - participants: Participants to be added to the chat thread.
    internal init(
        topic: String, participants: [ChatParticipantInternal]? = nil
    ) {
        self.topic = topic
        self.participants = participants
    }

    // MARK: Codable

    enum CodingKeys: String, CodingKey {
        case topic = "topic"
        case participants = "participants"
    }

    /// Initialize a `CreateChatThreadRequestInternal` structure from decoder
    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        self.topic = try container.decode(String.self, forKey: .topic)
        self.participants = try? container.decode([ChatParticipantInternal].self, forKey: .participants)
    }

    /// Encode a `CreateChatThreadRequestInternal` structure
    public func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)
        try container.encode(topic, forKey: .topic)
        if participants != nil { try? container.encode(participants, forKey: .participants) }
    }
}
