// File generated from our OpenAPI spec by Stainless.

package com.increase.api.services.blocking

import com.increase.api.TestServerExtension
import com.increase.api.client.okhttp.IncreaseOkHttpClient
import com.increase.api.models.cardpushtransfers.CardPushTransferCreateParams
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith

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

    @Test
    fun create() {
        val client =
            IncreaseOkHttpClient.builder()
                .baseUrl(TestServerExtension.BASE_URL)
                .apiKey("My API Key")
                .build()
        val cardPushTransferService = client.cardPushTransfers()

        val cardPushTransfer =
            cardPushTransferService.create(
                CardPushTransferCreateParams.builder()
                    .businessApplicationIdentifier(
                        CardPushTransferCreateParams.BusinessApplicationIdentifier
                            .FUNDS_DISBURSEMENT
                    )
                    .cardTokenId("outbound_card_token_zlt0ml6youq3q7vcdlg0")
                    .merchantCategoryCode("5734")
                    .merchantCityName("New York")
                    .merchantName("Acme Corp")
                    .merchantNamePrefix("Acme")
                    .merchantPostalCode("10045")
                    .merchantState("NY")
                    .presentmentAmount(
                        CardPushTransferCreateParams.PresentmentAmount.builder()
                            .currency(CardPushTransferCreateParams.PresentmentAmount.Currency.USD)
                            .value("1234.56")
                            .build()
                    )
                    .recipientName("Ian Crease")
                    .senderAddressCity("New York")
                    .senderAddressLine1("33 Liberty Street")
                    .senderAddressPostalCode("10045")
                    .senderAddressState("NY")
                    .senderName("Ian Crease")
                    .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2")
                    .merchantLegalBusinessName("x6")
                    .merchantStreetAddress("merchant_street_address")
                    .recipientAddressCity("recipient_address_city")
                    .recipientAddressLine1("recipient_address_line1")
                    .recipientAddressPostalCode("x6")
                    .recipientAddressState("x6")
                    .requireApproval(true)
                    .build()
            )

        cardPushTransfer.validate()
    }

    @Test
    fun retrieve() {
        val client =
            IncreaseOkHttpClient.builder()
                .baseUrl(TestServerExtension.BASE_URL)
                .apiKey("My API Key")
                .build()
        val cardPushTransferService = client.cardPushTransfers()

        val cardPushTransfer =
            cardPushTransferService.retrieve("outbound_card_push_transfer_e0z9rdpamraczh4tvwye")

        cardPushTransfer.validate()
    }

    @Test
    fun list() {
        val client =
            IncreaseOkHttpClient.builder()
                .baseUrl(TestServerExtension.BASE_URL)
                .apiKey("My API Key")
                .build()
        val cardPushTransferService = client.cardPushTransfers()

        val page = cardPushTransferService.list()

        page.response().validate()
    }

    @Test
    fun approve() {
        val client =
            IncreaseOkHttpClient.builder()
                .baseUrl(TestServerExtension.BASE_URL)
                .apiKey("My API Key")
                .build()
        val cardPushTransferService = client.cardPushTransfers()

        val cardPushTransfer =
            cardPushTransferService.approve("outbound_card_push_transfer_e0z9rdpamraczh4tvwye")

        cardPushTransfer.validate()
    }

    @Test
    fun cancel() {
        val client =
            IncreaseOkHttpClient.builder()
                .baseUrl(TestServerExtension.BASE_URL)
                .apiKey("My API Key")
                .build()
        val cardPushTransferService = client.cardPushTransfers()

        val cardPushTransfer =
            cardPushTransferService.cancel("outbound_card_push_transfer_e0z9rdpamraczh4tvwye")

        cardPushTransfer.validate()
    }
}
