// File generated from our OpenAPI spec by Stainless.

package com.openai.models.realtime.clientsecrets

import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
import com.openai.core.JsonValue
import com.openai.core.jsonMapper
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

internal class ClientSecretCreateResponseTest {

    @Test
    fun create() {
        val clientSecretCreateResponse =
            ClientSecretCreateResponse.builder()
                .expiresAt(0L)
                .session(
                    RealtimeSessionCreateResponse.builder()
                        .id("id")
                        .audio(
                            RealtimeSessionCreateResponse.Audio.builder()
                                .input(
                                    RealtimeSessionCreateResponse.Audio.Input.builder()
                                        .format("format")
                                        .noiseReduction(
                                            RealtimeSessionCreateResponse.Audio.Input.NoiseReduction
                                                .builder()
                                                .type(
                                                    RealtimeSessionCreateResponse.Audio.Input
                                                        .NoiseReduction
                                                        .Type
                                                        .NEAR_FIELD
                                                )
                                                .build()
                                        )
                                        .transcription(
                                            RealtimeSessionCreateResponse.Audio.Input.Transcription
                                                .builder()
                                                .language("language")
                                                .model("model")
                                                .prompt("prompt")
                                                .build()
                                        )
                                        .turnDetection(
                                            RealtimeSessionCreateResponse.Audio.Input.TurnDetection
                                                .builder()
                                                .prefixPaddingMs(0L)
                                                .silenceDurationMs(0L)
                                                .threshold(0.0)
                                                .type("type")
                                                .build()
                                        )
                                        .build()
                                )
                                .output(
                                    RealtimeSessionCreateResponse.Audio.Output.builder()
                                        .format("format")
                                        .speed(0.0)
                                        .voice(
                                            RealtimeSessionCreateResponse.Audio.Output.Voice.ALLOY
                                        )
                                        .build()
                                )
                                .build()
                        )
                        .expiresAt(0L)
                        .addInclude(
                            RealtimeSessionCreateResponse.Include
                                .ITEM_INPUT_AUDIO_TRANSCRIPTION_LOGPROBS
                        )
                        .instructions("instructions")
                        .maxOutputTokens(0L)
                        .model("model")
                        .object_("object")
                        .addOutputModality(RealtimeSessionCreateResponse.OutputModality.TEXT)
                        .toolChoice("tool_choice")
                        .addTool(
                            RealtimeSessionCreateResponse.Tool.builder()
                                .description("description")
                                .name("name")
                                .parameters(JsonValue.from(mapOf<String, Any>()))
                                .type(RealtimeSessionCreateResponse.Tool.Type.FUNCTION)
                                .build()
                        )
                        .tracingAuto()
                        .turnDetection(
                            RealtimeSessionCreateResponse.TurnDetection.builder()
                                .prefixPaddingMs(0L)
                                .silenceDurationMs(0L)
                                .threshold(0.0)
                                .type("type")
                                .build()
                        )
                        .build()
                )
                .value("value")
                .build()

        assertThat(clientSecretCreateResponse.expiresAt()).isEqualTo(0L)
        assertThat(clientSecretCreateResponse.session())
            .isEqualTo(
                ClientSecretCreateResponse.Session.ofRealtimeSessionCreateResponse(
                    RealtimeSessionCreateResponse.builder()
                        .id("id")
                        .audio(
                            RealtimeSessionCreateResponse.Audio.builder()
                                .input(
                                    RealtimeSessionCreateResponse.Audio.Input.builder()
                                        .format("format")
                                        .noiseReduction(
                                            RealtimeSessionCreateResponse.Audio.Input.NoiseReduction
                                                .builder()
                                                .type(
                                                    RealtimeSessionCreateResponse.Audio.Input
                                                        .NoiseReduction
                                                        .Type
                                                        .NEAR_FIELD
                                                )
                                                .build()
                                        )
                                        .transcription(
                                            RealtimeSessionCreateResponse.Audio.Input.Transcription
                                                .builder()
                                                .language("language")
                                                .model("model")
                                                .prompt("prompt")
                                                .build()
                                        )
                                        .turnDetection(
                                            RealtimeSessionCreateResponse.Audio.Input.TurnDetection
                                                .builder()
                                                .prefixPaddingMs(0L)
                                                .silenceDurationMs(0L)
                                                .threshold(0.0)
                                                .type("type")
                                                .build()
                                        )
                                        .build()
                                )
                                .output(
                                    RealtimeSessionCreateResponse.Audio.Output.builder()
                                        .format("format")
                                        .speed(0.0)
                                        .voice(
                                            RealtimeSessionCreateResponse.Audio.Output.Voice.ALLOY
                                        )
                                        .build()
                                )
                                .build()
                        )
                        .expiresAt(0L)
                        .addInclude(
                            RealtimeSessionCreateResponse.Include
                                .ITEM_INPUT_AUDIO_TRANSCRIPTION_LOGPROBS
                        )
                        .instructions("instructions")
                        .maxOutputTokens(0L)
                        .model("model")
                        .object_("object")
                        .addOutputModality(RealtimeSessionCreateResponse.OutputModality.TEXT)
                        .toolChoice("tool_choice")
                        .addTool(
                            RealtimeSessionCreateResponse.Tool.builder()
                                .description("description")
                                .name("name")
                                .parameters(JsonValue.from(mapOf<String, Any>()))
                                .type(RealtimeSessionCreateResponse.Tool.Type.FUNCTION)
                                .build()
                        )
                        .tracingAuto()
                        .turnDetection(
                            RealtimeSessionCreateResponse.TurnDetection.builder()
                                .prefixPaddingMs(0L)
                                .silenceDurationMs(0L)
                                .threshold(0.0)
                                .type("type")
                                .build()
                        )
                        .build()
                )
            )
        assertThat(clientSecretCreateResponse.value()).isEqualTo("value")
    }

    @Test
    fun roundtrip() {
        val jsonMapper = jsonMapper()
        val clientSecretCreateResponse =
            ClientSecretCreateResponse.builder()
                .expiresAt(0L)
                .session(
                    RealtimeSessionCreateResponse.builder()
                        .id("id")
                        .audio(
                            RealtimeSessionCreateResponse.Audio.builder()
                                .input(
                                    RealtimeSessionCreateResponse.Audio.Input.builder()
                                        .format("format")
                                        .noiseReduction(
                                            RealtimeSessionCreateResponse.Audio.Input.NoiseReduction
                                                .builder()
                                                .type(
                                                    RealtimeSessionCreateResponse.Audio.Input
                                                        .NoiseReduction
                                                        .Type
                                                        .NEAR_FIELD
                                                )
                                                .build()
                                        )
                                        .transcription(
                                            RealtimeSessionCreateResponse.Audio.Input.Transcription
                                                .builder()
                                                .language("language")
                                                .model("model")
                                                .prompt("prompt")
                                                .build()
                                        )
                                        .turnDetection(
                                            RealtimeSessionCreateResponse.Audio.Input.TurnDetection
                                                .builder()
                                                .prefixPaddingMs(0L)
                                                .silenceDurationMs(0L)
                                                .threshold(0.0)
                                                .type("type")
                                                .build()
                                        )
                                        .build()
                                )
                                .output(
                                    RealtimeSessionCreateResponse.Audio.Output.builder()
                                        .format("format")
                                        .speed(0.0)
                                        .voice(
                                            RealtimeSessionCreateResponse.Audio.Output.Voice.ALLOY
                                        )
                                        .build()
                                )
                                .build()
                        )
                        .expiresAt(0L)
                        .addInclude(
                            RealtimeSessionCreateResponse.Include
                                .ITEM_INPUT_AUDIO_TRANSCRIPTION_LOGPROBS
                        )
                        .instructions("instructions")
                        .maxOutputTokens(0L)
                        .model("model")
                        .object_("object")
                        .addOutputModality(RealtimeSessionCreateResponse.OutputModality.TEXT)
                        .toolChoice("tool_choice")
                        .addTool(
                            RealtimeSessionCreateResponse.Tool.builder()
                                .description("description")
                                .name("name")
                                .parameters(JsonValue.from(mapOf<String, Any>()))
                                .type(RealtimeSessionCreateResponse.Tool.Type.FUNCTION)
                                .build()
                        )
                        .tracingAuto()
                        .turnDetection(
                            RealtimeSessionCreateResponse.TurnDetection.builder()
                                .prefixPaddingMs(0L)
                                .silenceDurationMs(0L)
                                .threshold(0.0)
                                .type("type")
                                .build()
                        )
                        .build()
                )
                .value("value")
                .build()

        val roundtrippedClientSecretCreateResponse =
            jsonMapper.readValue(
                jsonMapper.writeValueAsString(clientSecretCreateResponse),
                jacksonTypeRef<ClientSecretCreateResponse>(),
            )

        assertThat(roundtrippedClientSecretCreateResponse).isEqualTo(clientSecretCreateResponse)
    }
}
