// File generated from our OpenAPI spec by Stainless.

package com.increase.api.models.checktransfers

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

internal class CheckTransferCreateParamsTest {

    @Test
    fun create() {
        CheckTransferCreateParams.builder()
            .accountId("account_in71c4amph0vgo2qllky")
            .amount(1000L)
            .fulfillmentMethod(CheckTransferCreateParams.FulfillmentMethod.PHYSICAL_CHECK)
            .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2")
            .balanceCheck(CheckTransferCreateParams.BalanceCheck.FULL)
            .checkNumber("469")
            .physicalCheck(
                CheckTransferCreateParams.PhysicalCheck.builder()
                    .mailingAddress(
                        CheckTransferCreateParams.PhysicalCheck.MailingAddress.builder()
                            .city("New York")
                            .line1("33 Liberty Street")
                            .postalCode("10045")
                            .state("NY")
                            .line2("line2")
                            .name("Ian Crease")
                            .phone("+16505046304")
                            .build()
                    )
                    .memo("Check payment")
                    .payer(
                        listOf(
                            CheckTransferCreateParams.PhysicalCheck.Payer.builder()
                                .contents("National Phonograph Company")
                                .build(),
                            CheckTransferCreateParams.PhysicalCheck.Payer.builder()
                                .contents("33 Liberty Street")
                                .build(),
                            CheckTransferCreateParams.PhysicalCheck.Payer.builder()
                                .contents("New York, NY 10045")
                                .build(),
                        )
                    )
                    .recipientName("Ian Crease")
                    .attachmentFileId("attachment_file_id")
                    .checkVoucherImageFileId("check_voucher_image_file_id")
                    .note("note")
                    .returnAddress(
                        CheckTransferCreateParams.PhysicalCheck.ReturnAddress.builder()
                            .city("city")
                            .line1("line1")
                            .name("name")
                            .postalCode("21029-9469")
                            .state("x")
                            .line2("line2")
                            .phone("x")
                            .build()
                    )
                    .returnAddressName("return_address_name")
                    .shippingMethod(
                        CheckTransferCreateParams.PhysicalCheck.ShippingMethod.USPS_FIRST_CLASS
                    )
                    .signature(
                        CheckTransferCreateParams.PhysicalCheck.Signature.builder()
                            .imageFileId("image_file_id")
                            .text("Ian Crease")
                            .build()
                    )
                    .build()
            )
            .requireApproval(true)
            .thirdParty(CheckTransferCreateParams.ThirdParty.builder().recipientName("x").build())
            .validUntilDate(LocalDate.parse("2025-12-31"))
            .build()
    }

    @Test
    fun body() {
        val params =
            CheckTransferCreateParams.builder()
                .accountId("account_in71c4amph0vgo2qllky")
                .amount(1000L)
                .fulfillmentMethod(CheckTransferCreateParams.FulfillmentMethod.PHYSICAL_CHECK)
                .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2")
                .balanceCheck(CheckTransferCreateParams.BalanceCheck.FULL)
                .checkNumber("469")
                .physicalCheck(
                    CheckTransferCreateParams.PhysicalCheck.builder()
                        .mailingAddress(
                            CheckTransferCreateParams.PhysicalCheck.MailingAddress.builder()
                                .city("New York")
                                .line1("33 Liberty Street")
                                .postalCode("10045")
                                .state("NY")
                                .line2("line2")
                                .name("Ian Crease")
                                .phone("+16505046304")
                                .build()
                        )
                        .memo("Check payment")
                        .payer(
                            listOf(
                                CheckTransferCreateParams.PhysicalCheck.Payer.builder()
                                    .contents("National Phonograph Company")
                                    .build(),
                                CheckTransferCreateParams.PhysicalCheck.Payer.builder()
                                    .contents("33 Liberty Street")
                                    .build(),
                                CheckTransferCreateParams.PhysicalCheck.Payer.builder()
                                    .contents("New York, NY 10045")
                                    .build(),
                            )
                        )
                        .recipientName("Ian Crease")
                        .attachmentFileId("attachment_file_id")
                        .checkVoucherImageFileId("check_voucher_image_file_id")
                        .note("note")
                        .returnAddress(
                            CheckTransferCreateParams.PhysicalCheck.ReturnAddress.builder()
                                .city("city")
                                .line1("line1")
                                .name("name")
                                .postalCode("21029-9469")
                                .state("x")
                                .line2("line2")
                                .phone("x")
                                .build()
                        )
                        .returnAddressName("return_address_name")
                        .shippingMethod(
                            CheckTransferCreateParams.PhysicalCheck.ShippingMethod.USPS_FIRST_CLASS
                        )
                        .signature(
                            CheckTransferCreateParams.PhysicalCheck.Signature.builder()
                                .imageFileId("image_file_id")
                                .text("Ian Crease")
                                .build()
                        )
                        .build()
                )
                .requireApproval(true)
                .thirdParty(
                    CheckTransferCreateParams.ThirdParty.builder().recipientName("x").build()
                )
                .validUntilDate(LocalDate.parse("2025-12-31"))
                .build()

        val body = params._body()

        assertThat(body.accountId()).isEqualTo("account_in71c4amph0vgo2qllky")
        assertThat(body.amount()).isEqualTo(1000L)
        assertThat(body.fulfillmentMethod())
            .isEqualTo(CheckTransferCreateParams.FulfillmentMethod.PHYSICAL_CHECK)
        assertThat(body.sourceAccountNumberId()).isEqualTo("account_number_v18nkfqm6afpsrvy82b2")
        assertThat(body.balanceCheck()).contains(CheckTransferCreateParams.BalanceCheck.FULL)
        assertThat(body.checkNumber()).contains("469")
        assertThat(body.physicalCheck())
            .contains(
                CheckTransferCreateParams.PhysicalCheck.builder()
                    .mailingAddress(
                        CheckTransferCreateParams.PhysicalCheck.MailingAddress.builder()
                            .city("New York")
                            .line1("33 Liberty Street")
                            .postalCode("10045")
                            .state("NY")
                            .line2("line2")
                            .name("Ian Crease")
                            .phone("+16505046304")
                            .build()
                    )
                    .memo("Check payment")
                    .payer(
                        listOf(
                            CheckTransferCreateParams.PhysicalCheck.Payer.builder()
                                .contents("National Phonograph Company")
                                .build(),
                            CheckTransferCreateParams.PhysicalCheck.Payer.builder()
                                .contents("33 Liberty Street")
                                .build(),
                            CheckTransferCreateParams.PhysicalCheck.Payer.builder()
                                .contents("New York, NY 10045")
                                .build(),
                        )
                    )
                    .recipientName("Ian Crease")
                    .attachmentFileId("attachment_file_id")
                    .checkVoucherImageFileId("check_voucher_image_file_id")
                    .note("note")
                    .returnAddress(
                        CheckTransferCreateParams.PhysicalCheck.ReturnAddress.builder()
                            .city("city")
                            .line1("line1")
                            .name("name")
                            .postalCode("21029-9469")
                            .state("x")
                            .line2("line2")
                            .phone("x")
                            .build()
                    )
                    .returnAddressName("return_address_name")
                    .shippingMethod(
                        CheckTransferCreateParams.PhysicalCheck.ShippingMethod.USPS_FIRST_CLASS
                    )
                    .signature(
                        CheckTransferCreateParams.PhysicalCheck.Signature.builder()
                            .imageFileId("image_file_id")
                            .text("Ian Crease")
                            .build()
                    )
                    .build()
            )
        assertThat(body.requireApproval()).contains(true)
        assertThat(body.thirdParty())
            .contains(CheckTransferCreateParams.ThirdParty.builder().recipientName("x").build())
        assertThat(body.validUntilDate()).contains(LocalDate.parse("2025-12-31"))
    }

    @Test
    fun bodyWithoutOptionalFields() {
        val params =
            CheckTransferCreateParams.builder()
                .accountId("account_in71c4amph0vgo2qllky")
                .amount(1000L)
                .fulfillmentMethod(CheckTransferCreateParams.FulfillmentMethod.PHYSICAL_CHECK)
                .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2")
                .build()

        val body = params._body()

        assertThat(body.accountId()).isEqualTo("account_in71c4amph0vgo2qllky")
        assertThat(body.amount()).isEqualTo(1000L)
        assertThat(body.fulfillmentMethod())
            .isEqualTo(CheckTransferCreateParams.FulfillmentMethod.PHYSICAL_CHECK)
        assertThat(body.sourceAccountNumberId()).isEqualTo("account_number_v18nkfqm6afpsrvy82b2")
    }
}
