// File generated from our OpenAPI spec by Stainless.

package com.increase.api.services.async

import com.increase.api.TestServerExtension
import com.increase.api.client.okhttp.IncreaseOkHttpClientAsync
import com.increase.api.models.exports.ExportCreateParams
import java.time.LocalDate
import java.time.OffsetDateTime
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith

@ExtendWith(TestServerExtension::class)
internal class ExportServiceAsyncTest {

    @Test
    fun create() {
        val client =
            IncreaseOkHttpClientAsync.builder()
                .baseUrl(TestServerExtension.BASE_URL)
                .apiKey("My API Key")
                .build()
        val exportServiceAsync = client.exports()

        val exportFuture =
            exportServiceAsync.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()
            )

        val export = exportFuture.get()
        export.validate()
    }

    @Test
    fun retrieve() {
        val client =
            IncreaseOkHttpClientAsync.builder()
                .baseUrl(TestServerExtension.BASE_URL)
                .apiKey("My API Key")
                .build()
        val exportServiceAsync = client.exports()

        val exportFuture = exportServiceAsync.retrieve("export_8s4m48qz3bclzje0zwh9")

        val export = exportFuture.get()
        export.validate()
    }

    @Test
    fun list() {
        val client =
            IncreaseOkHttpClientAsync.builder()
                .baseUrl(TestServerExtension.BASE_URL)
                .apiKey("My API Key")
                .build()
        val exportServiceAsync = client.exports()

        val pageFuture = exportServiceAsync.list()

        val page = pageFuture.get()
        page.response().validate()
    }
}
