// File generated from our OpenAPI spec by Stainless.

package com.increase.api.models.cards

import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

internal class CardCreateParamsTest {

    @Test
    fun create() {
        CardCreateParams.builder()
            .accountId("account_in71c4amph0vgo2qllky")
            .authorizationControls(
                CardCreateParams.AuthorizationControls.builder()
                    .merchantAcceptorIdentifier(
                        CardCreateParams.AuthorizationControls.MerchantAcceptorIdentifier.builder()
                            .addAllowed(
                                CardCreateParams.AuthorizationControls.MerchantAcceptorIdentifier
                                    .Allowed
                                    .builder()
                                    .identifier("x")
                                    .build()
                            )
                            .addBlocked(
                                CardCreateParams.AuthorizationControls.MerchantAcceptorIdentifier
                                    .Blocked
                                    .builder()
                                    .identifier("x")
                                    .build()
                            )
                            .build()
                    )
                    .merchantCategoryCode(
                        CardCreateParams.AuthorizationControls.MerchantCategoryCode.builder()
                            .addAllowed(
                                CardCreateParams.AuthorizationControls.MerchantCategoryCode.Allowed
                                    .builder()
                                    .code("0253")
                                    .build()
                            )
                            .addBlocked(
                                CardCreateParams.AuthorizationControls.MerchantCategoryCode.Blocked
                                    .builder()
                                    .code("0253")
                                    .build()
                            )
                            .build()
                    )
                    .merchantCountry(
                        CardCreateParams.AuthorizationControls.MerchantCountry.builder()
                            .addAllowed(
                                CardCreateParams.AuthorizationControls.MerchantCountry.Allowed
                                    .builder()
                                    .country("xx")
                                    .build()
                            )
                            .addBlocked(
                                CardCreateParams.AuthorizationControls.MerchantCountry.Blocked
                                    .builder()
                                    .country("xx")
                                    .build()
                            )
                            .build()
                    )
                    .usage(
                        CardCreateParams.AuthorizationControls.Usage.builder()
                            .category(
                                CardCreateParams.AuthorizationControls.Usage.Category.SINGLE_USE
                            )
                            .multiUse(
                                CardCreateParams.AuthorizationControls.Usage.MultiUse.builder()
                                    .addSpendingLimit(
                                        CardCreateParams.AuthorizationControls.Usage.MultiUse
                                            .SpendingLimit
                                            .builder()
                                            .interval(
                                                CardCreateParams.AuthorizationControls.Usage
                                                    .MultiUse
                                                    .SpendingLimit
                                                    .Interval
                                                    .ALL_TIME
                                            )
                                            .settlementAmount(0L)
                                            .addMerchantCategoryCode(
                                                CardCreateParams.AuthorizationControls.Usage
                                                    .MultiUse
                                                    .SpendingLimit
                                                    .MerchantCategoryCode
                                                    .builder()
                                                    .code("x")
                                                    .build()
                                            )
                                            .build()
                                    )
                                    .build()
                            )
                            .singleUse(
                                CardCreateParams.AuthorizationControls.Usage.SingleUse.builder()
                                    .settlementAmount(
                                        CardCreateParams.AuthorizationControls.Usage.SingleUse
                                            .SettlementAmount
                                            .builder()
                                            .comparison(
                                                CardCreateParams.AuthorizationControls.Usage
                                                    .SingleUse
                                                    .SettlementAmount
                                                    .Comparison
                                                    .EQUALS
                                            )
                                            .value(0L)
                                            .build()
                                    )
                                    .build()
                            )
                            .build()
                    )
                    .build()
            )
            .billingAddress(
                CardCreateParams.BillingAddress.builder()
                    .city("x")
                    .line1("x")
                    .postalCode("x")
                    .state("x")
                    .line2("x")
                    .build()
            )
            .description("Card for Ian Crease")
            .digitalWallet(
                CardCreateParams.DigitalWallet.builder()
                    .digitalCardProfileId("digital_card_profile_id")
                    .email("dev@stainless.com")
                    .phone("x")
                    .build()
            )
            .entityId("entity_id")
            .build()
    }

    @Test
    fun body() {
        val params =
            CardCreateParams.builder()
                .accountId("account_in71c4amph0vgo2qllky")
                .authorizationControls(
                    CardCreateParams.AuthorizationControls.builder()
                        .merchantAcceptorIdentifier(
                            CardCreateParams.AuthorizationControls.MerchantAcceptorIdentifier
                                .builder()
                                .addAllowed(
                                    CardCreateParams.AuthorizationControls
                                        .MerchantAcceptorIdentifier
                                        .Allowed
                                        .builder()
                                        .identifier("x")
                                        .build()
                                )
                                .addBlocked(
                                    CardCreateParams.AuthorizationControls
                                        .MerchantAcceptorIdentifier
                                        .Blocked
                                        .builder()
                                        .identifier("x")
                                        .build()
                                )
                                .build()
                        )
                        .merchantCategoryCode(
                            CardCreateParams.AuthorizationControls.MerchantCategoryCode.builder()
                                .addAllowed(
                                    CardCreateParams.AuthorizationControls.MerchantCategoryCode
                                        .Allowed
                                        .builder()
                                        .code("0253")
                                        .build()
                                )
                                .addBlocked(
                                    CardCreateParams.AuthorizationControls.MerchantCategoryCode
                                        .Blocked
                                        .builder()
                                        .code("0253")
                                        .build()
                                )
                                .build()
                        )
                        .merchantCountry(
                            CardCreateParams.AuthorizationControls.MerchantCountry.builder()
                                .addAllowed(
                                    CardCreateParams.AuthorizationControls.MerchantCountry.Allowed
                                        .builder()
                                        .country("xx")
                                        .build()
                                )
                                .addBlocked(
                                    CardCreateParams.AuthorizationControls.MerchantCountry.Blocked
                                        .builder()
                                        .country("xx")
                                        .build()
                                )
                                .build()
                        )
                        .usage(
                            CardCreateParams.AuthorizationControls.Usage.builder()
                                .category(
                                    CardCreateParams.AuthorizationControls.Usage.Category.SINGLE_USE
                                )
                                .multiUse(
                                    CardCreateParams.AuthorizationControls.Usage.MultiUse.builder()
                                        .addSpendingLimit(
                                            CardCreateParams.AuthorizationControls.Usage.MultiUse
                                                .SpendingLimit
                                                .builder()
                                                .interval(
                                                    CardCreateParams.AuthorizationControls.Usage
                                                        .MultiUse
                                                        .SpendingLimit
                                                        .Interval
                                                        .ALL_TIME
                                                )
                                                .settlementAmount(0L)
                                                .addMerchantCategoryCode(
                                                    CardCreateParams.AuthorizationControls.Usage
                                                        .MultiUse
                                                        .SpendingLimit
                                                        .MerchantCategoryCode
                                                        .builder()
                                                        .code("x")
                                                        .build()
                                                )
                                                .build()
                                        )
                                        .build()
                                )
                                .singleUse(
                                    CardCreateParams.AuthorizationControls.Usage.SingleUse.builder()
                                        .settlementAmount(
                                            CardCreateParams.AuthorizationControls.Usage.SingleUse
                                                .SettlementAmount
                                                .builder()
                                                .comparison(
                                                    CardCreateParams.AuthorizationControls.Usage
                                                        .SingleUse
                                                        .SettlementAmount
                                                        .Comparison
                                                        .EQUALS
                                                )
                                                .value(0L)
                                                .build()
                                        )
                                        .build()
                                )
                                .build()
                        )
                        .build()
                )
                .billingAddress(
                    CardCreateParams.BillingAddress.builder()
                        .city("x")
                        .line1("x")
                        .postalCode("x")
                        .state("x")
                        .line2("x")
                        .build()
                )
                .description("Card for Ian Crease")
                .digitalWallet(
                    CardCreateParams.DigitalWallet.builder()
                        .digitalCardProfileId("digital_card_profile_id")
                        .email("dev@stainless.com")
                        .phone("x")
                        .build()
                )
                .entityId("entity_id")
                .build()

        val body = params._body()

        assertThat(body.accountId()).isEqualTo("account_in71c4amph0vgo2qllky")
        assertThat(body.authorizationControls())
            .contains(
                CardCreateParams.AuthorizationControls.builder()
                    .merchantAcceptorIdentifier(
                        CardCreateParams.AuthorizationControls.MerchantAcceptorIdentifier.builder()
                            .addAllowed(
                                CardCreateParams.AuthorizationControls.MerchantAcceptorIdentifier
                                    .Allowed
                                    .builder()
                                    .identifier("x")
                                    .build()
                            )
                            .addBlocked(
                                CardCreateParams.AuthorizationControls.MerchantAcceptorIdentifier
                                    .Blocked
                                    .builder()
                                    .identifier("x")
                                    .build()
                            )
                            .build()
                    )
                    .merchantCategoryCode(
                        CardCreateParams.AuthorizationControls.MerchantCategoryCode.builder()
                            .addAllowed(
                                CardCreateParams.AuthorizationControls.MerchantCategoryCode.Allowed
                                    .builder()
                                    .code("0253")
                                    .build()
                            )
                            .addBlocked(
                                CardCreateParams.AuthorizationControls.MerchantCategoryCode.Blocked
                                    .builder()
                                    .code("0253")
                                    .build()
                            )
                            .build()
                    )
                    .merchantCountry(
                        CardCreateParams.AuthorizationControls.MerchantCountry.builder()
                            .addAllowed(
                                CardCreateParams.AuthorizationControls.MerchantCountry.Allowed
                                    .builder()
                                    .country("xx")
                                    .build()
                            )
                            .addBlocked(
                                CardCreateParams.AuthorizationControls.MerchantCountry.Blocked
                                    .builder()
                                    .country("xx")
                                    .build()
                            )
                            .build()
                    )
                    .usage(
                        CardCreateParams.AuthorizationControls.Usage.builder()
                            .category(
                                CardCreateParams.AuthorizationControls.Usage.Category.SINGLE_USE
                            )
                            .multiUse(
                                CardCreateParams.AuthorizationControls.Usage.MultiUse.builder()
                                    .addSpendingLimit(
                                        CardCreateParams.AuthorizationControls.Usage.MultiUse
                                            .SpendingLimit
                                            .builder()
                                            .interval(
                                                CardCreateParams.AuthorizationControls.Usage
                                                    .MultiUse
                                                    .SpendingLimit
                                                    .Interval
                                                    .ALL_TIME
                                            )
                                            .settlementAmount(0L)
                                            .addMerchantCategoryCode(
                                                CardCreateParams.AuthorizationControls.Usage
                                                    .MultiUse
                                                    .SpendingLimit
                                                    .MerchantCategoryCode
                                                    .builder()
                                                    .code("x")
                                                    .build()
                                            )
                                            .build()
                                    )
                                    .build()
                            )
                            .singleUse(
                                CardCreateParams.AuthorizationControls.Usage.SingleUse.builder()
                                    .settlementAmount(
                                        CardCreateParams.AuthorizationControls.Usage.SingleUse
                                            .SettlementAmount
                                            .builder()
                                            .comparison(
                                                CardCreateParams.AuthorizationControls.Usage
                                                    .SingleUse
                                                    .SettlementAmount
                                                    .Comparison
                                                    .EQUALS
                                            )
                                            .value(0L)
                                            .build()
                                    )
                                    .build()
                            )
                            .build()
                    )
                    .build()
            )
        assertThat(body.billingAddress())
            .contains(
                CardCreateParams.BillingAddress.builder()
                    .city("x")
                    .line1("x")
                    .postalCode("x")
                    .state("x")
                    .line2("x")
                    .build()
            )
        assertThat(body.description()).contains("Card for Ian Crease")
        assertThat(body.digitalWallet())
            .contains(
                CardCreateParams.DigitalWallet.builder()
                    .digitalCardProfileId("digital_card_profile_id")
                    .email("dev@stainless.com")
                    .phone("x")
                    .build()
            )
        assertThat(body.entityId()).contains("entity_id")
    }

    @Test
    fun bodyWithoutOptionalFields() {
        val params = CardCreateParams.builder().accountId("account_in71c4amph0vgo2qllky").build()

        val body = params._body()

        assertThat(body.accountId()).isEqualTo("account_in71c4amph0vgo2qllky")
    }
}
