// 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.realtimepaymentstransfers.RealTimePaymentsTransferCreateParams
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith

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

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

        val realTimePaymentsTransferFuture =
            realTimePaymentsTransferServiceAsync.create(
                RealTimePaymentsTransferCreateParams.builder()
                    .amount(100L)
                    .creditorName("Ian Crease")
                    .sourceAccountNumberId("account_number_v18nkfqm6afpsrvy82b2")
                    .unstructuredRemittanceInformation("Invoice 29582")
                    .accountNumber("987654321")
                    .debtorName("debtor_name")
                    .externalAccountId("external_account_id")
                    .requireApproval(true)
                    .routingNumber("101050001")
                    .ultimateCreditorName("ultimate_creditor_name")
                    .ultimateDebtorName("ultimate_debtor_name")
                    .build()
            )

        val realTimePaymentsTransfer = realTimePaymentsTransferFuture.get()
        realTimePaymentsTransfer.validate()
    }

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

        val realTimePaymentsTransferFuture =
            realTimePaymentsTransferServiceAsync.retrieve(
                "real_time_payments_transfer_iyuhl5kdn7ssmup83mvq"
            )

        val realTimePaymentsTransfer = realTimePaymentsTransferFuture.get()
        realTimePaymentsTransfer.validate()
    }

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

        val pageFuture = realTimePaymentsTransferServiceAsync.list()

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

    @Test
    fun approve() {
        val client =
            IncreaseOkHttpClientAsync.builder()
                .baseUrl(TestServerExtension.BASE_URL)
                .apiKey("My API Key")
                .build()
        val realTimePaymentsTransferServiceAsync = client.realTimePaymentsTransfers()

        val realTimePaymentsTransferFuture =
            realTimePaymentsTransferServiceAsync.approve(
                "real_time_payments_transfer_iyuhl5kdn7ssmup83mvq"
            )

        val realTimePaymentsTransfer = realTimePaymentsTransferFuture.get()
        realTimePaymentsTransfer.validate()
    }

    @Test
    fun cancel() {
        val client =
            IncreaseOkHttpClientAsync.builder()
                .baseUrl(TestServerExtension.BASE_URL)
                .apiKey("My API Key")
                .build()
        val realTimePaymentsTransferServiceAsync = client.realTimePaymentsTransfers()

        val realTimePaymentsTransferFuture =
            realTimePaymentsTransferServiceAsync.cancel(
                "real_time_payments_transfer_iyuhl5kdn7ssmup83mvq"
            )

        val realTimePaymentsTransfer = realTimePaymentsTransferFuture.get()
        realTimePaymentsTransfer.validate()
    }
}
