// File generated from our OpenAPI spec by Stainless.

package com.increase.api.models.exports

import com.increase.api.core.http.QueryParams
import java.time.OffsetDateTime
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

internal class ExportListParamsTest {

    @Test
    fun create() {
        ExportListParams.builder()
            .category(ExportListParams.Category.ACCOUNT_STATEMENT_OFX)
            .createdAt(
                ExportListParams.CreatedAt.builder()
                    .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                    .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                    .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                    .onOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                    .build()
            )
            .cursor("cursor")
            .form1099Int(ExportListParams.Form1099Int.builder().accountId("account_id").build())
            .form1099Misc(ExportListParams.Form1099Misc.builder().accountId("account_id").build())
            .idempotencyKey("x")
            .limit(1L)
            .status(
                ExportListParams.Status.builder().addIn(ExportListParams.Status.In.PENDING).build()
            )
            .build()
    }

    @Test
    fun queryParams() {
        val params =
            ExportListParams.builder()
                .category(ExportListParams.Category.ACCOUNT_STATEMENT_OFX)
                .createdAt(
                    ExportListParams.CreatedAt.builder()
                        .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                        .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                        .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                        .onOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                        .build()
                )
                .cursor("cursor")
                .form1099Int(ExportListParams.Form1099Int.builder().accountId("account_id").build())
                .form1099Misc(
                    ExportListParams.Form1099Misc.builder().accountId("account_id").build()
                )
                .idempotencyKey("x")
                .limit(1L)
                .status(
                    ExportListParams.Status.builder()
                        .addIn(ExportListParams.Status.In.PENDING)
                        .build()
                )
                .build()

        val queryParams = params._queryParams()

        assertThat(queryParams)
            .isEqualTo(
                QueryParams.builder()
                    .put("category", "account_statement_ofx")
                    .put("created_at.after", "2019-12-27T18:11:19.117Z")
                    .put("created_at.before", "2019-12-27T18:11:19.117Z")
                    .put("created_at.on_or_after", "2019-12-27T18:11:19.117Z")
                    .put("created_at.on_or_before", "2019-12-27T18:11:19.117Z")
                    .put("cursor", "cursor")
                    .put("form_1099_int.account_id", "account_id")
                    .put("form_1099_misc.account_id", "account_id")
                    .put("idempotency_key", "x")
                    .put("limit", "1")
                    .put("status.in", listOf("pending").joinToString(","))
                    .build()
            )
    }

    @Test
    fun queryParamsWithoutOptionalFields() {
        val params = ExportListParams.builder().build()

        val queryParams = params._queryParams()

        assertThat(queryParams).isEqualTo(QueryParams.builder().build())
    }
}
