// File generated from our OpenAPI spec by Stainless.

package com.increase.api.models.exports

import java.time.LocalDate
import java.time.OffsetDateTime
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

internal class ExportCreateParamsTest {

    @Test
    fun create() {
        ExportCreateParams.builder()
            .category(ExportCreateParams.Category.TRANSACTION_CSV)
            .accountStatementBai2(
                ExportCreateParams.AccountStatementBai2.builder()
                    .accountId("account_id")
                    .effectiveDate(LocalDate.parse("2019-12-27"))
                    .programId("program_id")
                    .build()
            )
            .accountStatementOfx(
                ExportCreateParams.AccountStatementOfx.builder()
                    .accountId("account_id")
                    .createdAt(
                        ExportCreateParams.AccountStatementOfx.CreatedAt.builder()
                            .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                            .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                            .build()
                    )
                    .build()
            )
            .accountVerificationLetter(
                ExportCreateParams.AccountVerificationLetter.builder()
                    .accountNumberId("account_number_id")
                    .balanceDate(LocalDate.parse("2019-12-27"))
                    .build()
            )
            .bookkeepingAccountBalanceCsv(
                ExportCreateParams.BookkeepingAccountBalanceCsv.builder()
                    .bookkeepingAccountId("bookkeeping_account_id")
                    .onOrAfterDate(LocalDate.parse("2019-12-27"))
                    .onOrBeforeDate(LocalDate.parse("2019-12-27"))
                    .build()
            )
            .dailyAccountBalanceCsv(
                ExportCreateParams.DailyAccountBalanceCsv.builder()
                    .accountId("account_id")
                    .onOrAfterDate(LocalDate.parse("2019-12-27"))
                    .onOrBeforeDate(LocalDate.parse("2019-12-27"))
                    .build()
            )
            .entityCsv(ExportCreateParams.EntityCsv.builder().build())
            .feeCsv(
                ExportCreateParams.FeeCsv.builder()
                    .createdAt(
                        ExportCreateParams.FeeCsv.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()
                    )
                    .programId("program_id")
                    .build()
            )
            .fundingInstructions(
                ExportCreateParams.FundingInstructions.builder()
                    .accountNumberId("account_number_id")
                    .build()
            )
            .transactionCsv(
                ExportCreateParams.TransactionCsv.builder()
                    .accountId("account_in71c4amph0vgo2qllky")
                    .createdAt(
                        ExportCreateParams.TransactionCsv.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()
                    )
                    .build()
            )
            .vendorCsv(ExportCreateParams.VendorCsv.builder().build())
            .voidedCheck(
                ExportCreateParams.VoidedCheck.builder()
                    .accountNumberId("account_number_id")
                    .addPayer(ExportCreateParams.VoidedCheck.Payer.builder().line("line").build())
                    .build()
            )
            .build()
    }

    @Test
    fun body() {
        val params =
            ExportCreateParams.builder()
                .category(ExportCreateParams.Category.TRANSACTION_CSV)
                .accountStatementBai2(
                    ExportCreateParams.AccountStatementBai2.builder()
                        .accountId("account_id")
                        .effectiveDate(LocalDate.parse("2019-12-27"))
                        .programId("program_id")
                        .build()
                )
                .accountStatementOfx(
                    ExportCreateParams.AccountStatementOfx.builder()
                        .accountId("account_id")
                        .createdAt(
                            ExportCreateParams.AccountStatementOfx.CreatedAt.builder()
                                .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                .build()
                        )
                        .build()
                )
                .accountVerificationLetter(
                    ExportCreateParams.AccountVerificationLetter.builder()
                        .accountNumberId("account_number_id")
                        .balanceDate(LocalDate.parse("2019-12-27"))
                        .build()
                )
                .bookkeepingAccountBalanceCsv(
                    ExportCreateParams.BookkeepingAccountBalanceCsv.builder()
                        .bookkeepingAccountId("bookkeeping_account_id")
                        .onOrAfterDate(LocalDate.parse("2019-12-27"))
                        .onOrBeforeDate(LocalDate.parse("2019-12-27"))
                        .build()
                )
                .dailyAccountBalanceCsv(
                    ExportCreateParams.DailyAccountBalanceCsv.builder()
                        .accountId("account_id")
                        .onOrAfterDate(LocalDate.parse("2019-12-27"))
                        .onOrBeforeDate(LocalDate.parse("2019-12-27"))
                        .build()
                )
                .entityCsv(ExportCreateParams.EntityCsv.builder().build())
                .feeCsv(
                    ExportCreateParams.FeeCsv.builder()
                        .createdAt(
                            ExportCreateParams.FeeCsv.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()
                        )
                        .programId("program_id")
                        .build()
                )
                .fundingInstructions(
                    ExportCreateParams.FundingInstructions.builder()
                        .accountNumberId("account_number_id")
                        .build()
                )
                .transactionCsv(
                    ExportCreateParams.TransactionCsv.builder()
                        .accountId("account_in71c4amph0vgo2qllky")
                        .createdAt(
                            ExportCreateParams.TransactionCsv.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()
                        )
                        .build()
                )
                .vendorCsv(ExportCreateParams.VendorCsv.builder().build())
                .voidedCheck(
                    ExportCreateParams.VoidedCheck.builder()
                        .accountNumberId("account_number_id")
                        .addPayer(
                            ExportCreateParams.VoidedCheck.Payer.builder().line("line").build()
                        )
                        .build()
                )
                .build()

        val body = params._body()

        assertThat(body.category()).isEqualTo(ExportCreateParams.Category.TRANSACTION_CSV)
        assertThat(body.accountStatementBai2())
            .contains(
                ExportCreateParams.AccountStatementBai2.builder()
                    .accountId("account_id")
                    .effectiveDate(LocalDate.parse("2019-12-27"))
                    .programId("program_id")
                    .build()
            )
        assertThat(body.accountStatementOfx())
            .contains(
                ExportCreateParams.AccountStatementOfx.builder()
                    .accountId("account_id")
                    .createdAt(
                        ExportCreateParams.AccountStatementOfx.CreatedAt.builder()
                            .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                            .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                            .build()
                    )
                    .build()
            )
        assertThat(body.accountVerificationLetter())
            .contains(
                ExportCreateParams.AccountVerificationLetter.builder()
                    .accountNumberId("account_number_id")
                    .balanceDate(LocalDate.parse("2019-12-27"))
                    .build()
            )
        assertThat(body.bookkeepingAccountBalanceCsv())
            .contains(
                ExportCreateParams.BookkeepingAccountBalanceCsv.builder()
                    .bookkeepingAccountId("bookkeeping_account_id")
                    .onOrAfterDate(LocalDate.parse("2019-12-27"))
                    .onOrBeforeDate(LocalDate.parse("2019-12-27"))
                    .build()
            )
        assertThat(body.dailyAccountBalanceCsv())
            .contains(
                ExportCreateParams.DailyAccountBalanceCsv.builder()
                    .accountId("account_id")
                    .onOrAfterDate(LocalDate.parse("2019-12-27"))
                    .onOrBeforeDate(LocalDate.parse("2019-12-27"))
                    .build()
            )
        assertThat(body.entityCsv()).contains(ExportCreateParams.EntityCsv.builder().build())
        assertThat(body.feeCsv())
            .contains(
                ExportCreateParams.FeeCsv.builder()
                    .createdAt(
                        ExportCreateParams.FeeCsv.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()
                    )
                    .programId("program_id")
                    .build()
            )
        assertThat(body.fundingInstructions())
            .contains(
                ExportCreateParams.FundingInstructions.builder()
                    .accountNumberId("account_number_id")
                    .build()
            )
        assertThat(body.transactionCsv())
            .contains(
                ExportCreateParams.TransactionCsv.builder()
                    .accountId("account_in71c4amph0vgo2qllky")
                    .createdAt(
                        ExportCreateParams.TransactionCsv.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()
                    )
                    .build()
            )
        assertThat(body.vendorCsv()).contains(ExportCreateParams.VendorCsv.builder().build())
        assertThat(body.voidedCheck())
            .contains(
                ExportCreateParams.VoidedCheck.builder()
                    .accountNumberId("account_number_id")
                    .addPayer(ExportCreateParams.VoidedCheck.Payer.builder().line("line").build())
                    .build()
            )
    }

    @Test
    fun bodyWithoutOptionalFields() {
        val params =
            ExportCreateParams.builder()
                .category(ExportCreateParams.Category.TRANSACTION_CSV)
                .build()

        val body = params._body()

        assertThat(body.category()).isEqualTo(ExportCreateParams.Category.TRANSACTION_CSV)
    }
}
