// File generated from our OpenAPI spec by Stainless.

package com.openai.services.blocking

import com.openai.core.ClientOptions
import com.openai.services.blocking.beta.AssistantService
import com.openai.services.blocking.beta.AssistantServiceImpl
import com.openai.services.blocking.beta.ChatKitService
import com.openai.services.blocking.beta.ChatKitServiceImpl
import com.openai.services.blocking.beta.RealtimeService
import com.openai.services.blocking.beta.RealtimeServiceImpl
import com.openai.services.blocking.beta.ThreadService
import com.openai.services.blocking.beta.ThreadServiceImpl
import java.util.function.Consumer

class BetaServiceImpl internal constructor(private val clientOptions: ClientOptions) : BetaService {

    private val withRawResponse: BetaService.WithRawResponse by lazy {
        WithRawResponseImpl(clientOptions)
    }

    private val realtime: RealtimeService by lazy { RealtimeServiceImpl(clientOptions) }

    private val chatkit: ChatKitService by lazy { ChatKitServiceImpl(clientOptions) }

    private val assistants: AssistantService by lazy { AssistantServiceImpl(clientOptions) }

    private val threads: ThreadService by lazy { ThreadServiceImpl(clientOptions) }

    override fun withRawResponse(): BetaService.WithRawResponse = withRawResponse

    override fun withOptions(modifier: Consumer<ClientOptions.Builder>): BetaService =
        BetaServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build())

    @Deprecated(
        "Realtime has now launched and is generally available. The old beta API is now deprecated."
    )
    override fun realtime(): RealtimeService = realtime

    override fun chatkit(): ChatKitService = chatkit

    override fun assistants(): AssistantService = assistants

    @Deprecated("The Assistants API is deprecated in favor of the Responses API")
    override fun threads(): ThreadService = threads

    class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) :
        BetaService.WithRawResponse {

        private val realtime: RealtimeService.WithRawResponse by lazy {
            RealtimeServiceImpl.WithRawResponseImpl(clientOptions)
        }

        private val chatkit: ChatKitService.WithRawResponse by lazy {
            ChatKitServiceImpl.WithRawResponseImpl(clientOptions)
        }

        private val assistants: AssistantService.WithRawResponse by lazy {
            AssistantServiceImpl.WithRawResponseImpl(clientOptions)
        }

        private val threads: ThreadService.WithRawResponse by lazy {
            ThreadServiceImpl.WithRawResponseImpl(clientOptions)
        }

        override fun withOptions(
            modifier: Consumer<ClientOptions.Builder>
        ): BetaService.WithRawResponse =
            BetaServiceImpl.WithRawResponseImpl(
                clientOptions.toBuilder().apply(modifier::accept).build()
            )

        @Deprecated(
            "Realtime has now launched and is generally available. The old beta API is now deprecated."
        )
        override fun realtime(): RealtimeService.WithRawResponse = realtime

        override fun chatkit(): ChatKitService.WithRawResponse = chatkit

        override fun assistants(): AssistantService.WithRawResponse = assistants

        @Deprecated("The Assistants API is deprecated in favor of the Responses API")
        override fun threads(): ThreadService.WithRawResponse = threads
    }
}
