// 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 CardUpdateParamsTest {

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

    @Test
    fun pathParams() {
        val params = CardUpdateParams.builder().cardId("card_oubs0hwk5rn6knuecxg2").build()

        assertThat(params._pathParam(0)).isEqualTo("card_oubs0hwk5rn6knuecxg2")
        // out-of-bound path param
        assertThat(params._pathParam(1)).isEqualTo("")
    }

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

        val body = params._body()

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

    @Test
    fun bodyWithoutOptionalFields() {
        val params = CardUpdateParams.builder().cardId("card_oubs0hwk5rn6knuecxg2").build()

        val body = params._body()
    }
}
