// --------------------------------------------------------------------------
// 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 file_length
// swiftlint:disable cyclomatic_complexity
// swiftlint:disable function_body_length
// swiftlint:disable type_body_length

internal final class ChatClientInternal: PipelineClient, PageableClient {
    internal func continuationUrl(forRequestUrl _: URL, withContinuationToken token: String) -> URL? {
        return URL(string: token)
    }

    /// Options provided to configure this `ChatClientInternal`.
    internal let options: AzureCommunicationChatClientOptionsInternal

    // MARK: Initializers

    /// Create a ChatClientInternal client.
    /// - Parameters:
    ///   - endpoint: Base URL for the ChatClientInternal.
    ///   - authPolicy: An `Authenticating` policy to use for authenticating client requests.
    ///   - options: Options used to configure the client.
    internal init(
        endpoint: URL,
        authPolicy: Authenticating,
        withOptions options: AzureCommunicationChatClientOptionsInternal
    ) throws {
        self.options = options
        super.init(
            endpoint: endpoint,
            transport: options.transportOptions.transport ?? URLSessionTransport(),
            policies: [
                UserAgentPolicy(for: ChatClientInternal.self, telemetryOptions: options.telemetryOptions),
                RequestIdPolicy(),
                AddDatePolicy(),
                authPolicy,
                ContentDecodePolicy(),
                LoggingPolicy(),
                NormalizeETagPolicy()
            ],
            logger: options.logger,
            options: options
        )
    }

    internal lazy var chat = Chat(client: self)
    internal lazy var chatThread = ChatThread(client: self)

    // MARK: Client Methods
}
