# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from stripe._createable_api_resource import CreateableAPIResource
from stripe._expandable_field import ExpandableField
from stripe._list_object import ListObject
from stripe._listable_api_resource import ListableAPIResource
from stripe._stripe_object import StripeObject, UntypedStripeObject
from stripe._test_helpers import APIResourceTestHelpers
from stripe._updateable_api_resource import UpdateableAPIResource
from stripe._util import class_method_variant, sanitize_id
from typing import ClassVar, List, Optional, cast, overload
from typing_extensions import Literal, Type, Unpack, TYPE_CHECKING

if TYPE_CHECKING:
    from stripe._balance_transaction import BalanceTransaction
    from stripe._file import File
    from stripe.issuing._transaction import Transaction
    from stripe.params.issuing._dispute_close_params import DisputeCloseParams
    from stripe.params.issuing._dispute_create_params import (
        DisputeCreateParams,
    )
    from stripe.params.issuing._dispute_list_params import DisputeListParams
    from stripe.params.issuing._dispute_modify_params import (
        DisputeModifyParams,
    )
    from stripe.params.issuing._dispute_provisional_credit_params import (
        DisputeProvisionalCreditParams,
    )
    from stripe.params.issuing._dispute_retrieve_params import (
        DisputeRetrieveParams,
    )
    from stripe.params.issuing._dispute_simulate_network_lifecycle_dispute_response_params import (
        DisputeSimulateNetworkLifecycleDisputeResponseParams,
    )
    from stripe.params.issuing._dispute_simulate_network_lifecycle_pre_arbitration_response_params import (
        DisputeSimulateNetworkLifecyclePreArbitrationResponseParams,
    )
    from stripe.params.issuing._dispute_simulate_network_lifecycle_pre_arbitration_submission_params import (
        DisputeSimulateNetworkLifecyclePreArbitrationSubmissionParams,
    )
    from stripe.params.issuing._dispute_submit_params import (
        DisputeSubmitParams,
    )


class Dispute(
    CreateableAPIResource["Dispute"],
    ListableAPIResource["Dispute"],
    UpdateableAPIResource["Dispute"],
):
    """
    As a [card issuer](https://docs.stripe.com/issuing), you can dispute transactions that the cardholder does not recognize, suspects to be fraudulent, or has other issues with.

    Related guide: [Issuing disputes](https://docs.stripe.com/issuing/purchases/disputes)
    """

    OBJECT_NAME: ClassVar[Literal["issuing.dispute"]] = "issuing.dispute"

    class CryptoTransaction(StripeObject):
        class CryptoTransactionConfirmed(StripeObject):
            class Fee(StripeObject):
                amount: str
                """
                The fee amount.
                """
                currency: str
                """
                The fee currency.
                """
                type: str
                """
                The fee type.
                """

            amount: str
            """
            The crypto amount for the confirmed transaction.
            """
            amount_mcc_upcharged: Optional[str]
            """
            The upcharged MCC amount, if one was applied.
            """
            chain: str
            """
            The blockchain network for the confirmed transaction.
            """
            confirmed_at: int
            """
            When the transaction was confirmed onchain.
            """
            currency: str
            """
            The currency of the crypto transaction amount.
            """
            fees: List[Fee]
            """
            Fees associated with the transaction.
            """
            from_address: str
            """
            The source wallet address for the transaction.
            """
            memo: Optional[str]
            """
            Memo metadata attached to the transaction, if present.
            """
            to_address: str
            """
            The destination wallet address for the transaction.
            """
            transaction_hash: str
            """
            The blockchain transaction hash.
            """
            _inner_class_types = {"fees": Fee}

        class CryptoTransactionFailed(StripeObject):
            class Fee(StripeObject):
                amount: str
                """
                The fee amount.
                """
                currency: str
                """
                The fee currency.
                """
                type: str
                """
                The fee type.
                """

            amount: str
            """
            The crypto amount for the failed transaction.
            """
            amount_mcc_upcharged: Optional[str]
            """
            The upcharged MCC amount, if one was applied.
            """
            chain: str
            """
            The blockchain network for the failed transaction.
            """
            currency: str
            """
            The currency of the crypto transaction amount.
            """
            failed_at: int
            """
            When the transaction failed.
            """
            failure_reason: str
            """
            The reason the transaction failed.
            """
            fees: List[Fee]
            """
            Fees associated with the transaction.
            """
            from_address: str
            """
            The source wallet address for the attempted transaction.
            """
            memo: Optional[str]
            """
            Memo metadata attached to the transaction, if present.
            """
            to_address: Optional[str]
            """
            The destination wallet address for the attempted transaction when one exists.
            """
            transaction_hash: Optional[str]
            """
            The blockchain transaction hash when one exists.
            """
            _inner_class_types = {"fees": Fee}

        crypto_transaction_confirmed: Optional[CryptoTransactionConfirmed]
        """
        The confirmed crypto transaction details when `type` is `crypto_transaction_confirmed`; otherwise null.
        """
        crypto_transaction_failed: Optional[CryptoTransactionFailed]
        """
        The failed crypto transaction details when `type` is `crypto_transaction_failed`; otherwise null.
        """
        type: str
        """
        The crypto transaction variant for this array entry.
        """
        _inner_class_types = {
            "crypto_transaction_confirmed": CryptoTransactionConfirmed,
            "crypto_transaction_failed": CryptoTransactionFailed,
        }

    class Evidence(StripeObject):
        class Canceled(StripeObject):
            additional_documentation: Optional[ExpandableField["File"]]
            """
            (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute.
            """
            canceled_at: Optional[int]
            """
            Date when order was canceled.
            """
            cancellation_policy_provided: Optional[bool]
            """
            Whether the cardholder was provided with a cancellation policy.
            """
            cancellation_reason: Optional[str]
            """
            Reason for canceling the order.
            """
            expected_at: Optional[int]
            """
            Date when the cardholder expected to receive the product.
            """
            explanation: Optional[str]
            """
            Explanation of why the cardholder is disputing this transaction.
            """
            product_description: Optional[str]
            """
            Description of the merchandise or service that was purchased.
            """
            product_type: Optional[Literal["merchandise", "service"]]
            """
            Whether the product was a merchandise or service.
            """
            return_status: Optional[Literal["merchant_rejected", "successful"]]
            """
            Result of cardholder's attempt to return the product.
            """
            returned_at: Optional[int]
            """
            Date when the product was returned or attempted to be returned.
            """

        class Duplicate(StripeObject):
            additional_documentation: Optional[ExpandableField["File"]]
            """
            (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute.
            """
            card_statement: Optional[ExpandableField["File"]]
            """
            (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Copy of the card statement showing that the product had already been paid for.
            """
            cash_receipt: Optional[ExpandableField["File"]]
            """
            (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Copy of the receipt showing that the product had been paid for in cash.
            """
            check_image: Optional[ExpandableField["File"]]
            """
            (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Image of the front and back of the check that was used to pay for the product.
            """
            explanation: Optional[str]
            """
            Explanation of why the cardholder is disputing this transaction.
            """
            original_transaction: Optional[str]
            """
            Transaction (e.g., ipi_...) that the disputed transaction is a duplicate of. Of the two or more transactions that are copies of each other, this is original undisputed one.
            """

        class Fraudulent(StripeObject):
            additional_documentation: Optional[ExpandableField["File"]]
            """
            (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute.
            """
            explanation: Optional[str]
            """
            Explanation of why the cardholder is disputing this transaction.
            """

        class MerchandiseNotAsDescribed(StripeObject):
            additional_documentation: Optional[ExpandableField["File"]]
            """
            (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute.
            """
            explanation: Optional[str]
            """
            Explanation of why the cardholder is disputing this transaction.
            """
            received_at: Optional[int]
            """
            Date when the product was received.
            """
            return_description: Optional[str]
            """
            Description of the cardholder's attempt to return the product.
            """
            return_status: Optional[Literal["merchant_rejected", "successful"]]
            """
            Result of cardholder's attempt to return the product.
            """
            returned_at: Optional[int]
            """
            Date when the product was returned or attempted to be returned.
            """

        class NoValidAuthorization(StripeObject):
            additional_documentation: Optional[ExpandableField["File"]]
            """
            (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute.
            """
            explanation: Optional[str]
            """
            Explanation of why the cardholder is disputing this transaction.
            """

        class NotReceived(StripeObject):
            additional_documentation: Optional[ExpandableField["File"]]
            """
            (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute.
            """
            expected_at: Optional[int]
            """
            Date when the cardholder expected to receive the product.
            """
            explanation: Optional[str]
            """
            Explanation of why the cardholder is disputing this transaction.
            """
            product_description: Optional[str]
            """
            Description of the merchandise or service that was purchased.
            """
            product_type: Optional[Literal["merchandise", "service"]]
            """
            Whether the product was a merchandise or service.
            """

        class Other(StripeObject):
            additional_documentation: Optional[ExpandableField["File"]]
            """
            (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute.
            """
            explanation: Optional[str]
            """
            Explanation of why the cardholder is disputing this transaction.
            """
            product_description: Optional[str]
            """
            Description of the merchandise or service that was purchased.
            """
            product_type: Optional[Literal["merchandise", "service"]]
            """
            Whether the product was a merchandise or service.
            """

        class ServiceNotAsDescribed(StripeObject):
            additional_documentation: Optional[ExpandableField["File"]]
            """
            (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute.
            """
            canceled_at: Optional[int]
            """
            Date when order was canceled.
            """
            cancellation_reason: Optional[str]
            """
            Reason for canceling the order.
            """
            explanation: Optional[str]
            """
            Explanation of why the cardholder is disputing this transaction.
            """
            received_at: Optional[int]
            """
            Date when the product was received.
            """

        canceled: Optional[Canceled]
        duplicate: Optional[Duplicate]
        fraudulent: Optional[Fraudulent]
        merchandise_not_as_described: Optional[MerchandiseNotAsDescribed]
        no_valid_authorization: Optional[NoValidAuthorization]
        not_received: Optional[NotReceived]
        other: Optional[Other]
        reason: Literal[
            "canceled",
            "duplicate",
            "fraudulent",
            "merchandise_not_as_described",
            "no_valid_authorization",
            "not_received",
            "other",
            "service_not_as_described",
        ]
        """
        The reason for filing the dispute. Its value will match the field containing the evidence.
        """
        service_not_as_described: Optional[ServiceNotAsDescribed]
        _inner_class_types = {
            "canceled": Canceled,
            "duplicate": Duplicate,
            "fraudulent": Fraudulent,
            "merchandise_not_as_described": MerchandiseNotAsDescribed,
            "no_valid_authorization": NoValidAuthorization,
            "not_received": NotReceived,
            "other": Other,
            "service_not_as_described": ServiceNotAsDescribed,
        }

    class NetworkLifecycle(StripeObject):
        class DisputeResponse(StripeObject):
            error: Optional[str]
            """
            Error message if processing the acquiring merchant's initial dispute response failed.
            """
            merchant_evidence_files: Optional[List[str]]
            """
            Array of [File](https://docs.stripe.com/api/files) ids containing evidence the acquiring merchant provided in support of their initial dispute response.
            """

        class PreArbitrationResponse(StripeObject):
            error: Optional[str]
            """
            Error message if processing the acquiring merchant's pre-arbitration response failed.
            """
            merchant_evidence_files: Optional[List[str]]
            """
            Array of [File](https://docs.stripe.com/api/files) ids containing evidence the acquiring merchant provided with their pre-arbitration response.
            """

        class PreArbitrationSubmission(StripeObject):
            error: Optional[str]
            """
            Error message if processing the acquiring merchant's pre-arbitration submission failed.
            """
            merchant_evidence_files: Optional[List[str]]
            """
            Array of [File](https://docs.stripe.com/api/files) ids containing evidence the acquiring merchant provided with their pre-arbitration submission.
            """

        dispute_response: Optional[DisputeResponse]
        """
        Information related to the acquiring merchant's initial response to this dispute.
        """
        pre_arbitration_response: Optional[PreArbitrationResponse]
        """
        Information related to the acquiring merchant's pre-arbitration response for this dispute.
        """
        pre_arbitration_submission: Optional[PreArbitrationSubmission]
        """
        Information related to the acquiring merchant's pre-arbitration submission for this dispute.
        """
        _inner_class_types = {
            "dispute_response": DisputeResponse,
            "pre_arbitration_response": PreArbitrationResponse,
            "pre_arbitration_submission": PreArbitrationSubmission,
        }

    class ProvisionalCredit(StripeObject):
        grant_deadline: Optional[int]
        """
        The time by which the platform must grant a provisional credit to the consumer.
        """
        granted_at: Optional[int]
        """
        The time at which the platform reported granting the provisional credit.
        """
        revocable_after: Optional[int]
        """
        The earliest time after which the platform can revoke the provisional credit.
        """
        revoked_at: Optional[int]
        """
        The time at which the platform reported revoking the provisional credit.
        """
        status: Literal[
            "delinquent",
            "granted",
            "not_required",
            "permanent",
            "required",
            "revocable",
            "revocation_notice_period",
            "revoked",
        ]
        """
        The status of the provisional credit obligation.
        """

    class Redaction(StripeObject):
        status: Literal["processing", "redacted", "validated"]
        """
        Indicates whether this object and its related objects have been redacted or not.
        """

    class Treasury(StripeObject):
        debit_reversal: Optional[str]
        """
        The Treasury [DebitReversal](https://docs.stripe.com/api/treasury/debit_reversals) representing this Issuing dispute
        """
        received_debit: str
        """
        The Treasury [ReceivedDebit](https://docs.stripe.com/api/treasury/received_debits) that is being disputed.
        """

    amount: int
    """
    Disputed amount in the card's currency and in the [smallest currency unit](https://docs.stripe.com/currencies#zero-decimal). Usually the amount of the `transaction`, but can differ (usually because of currency fluctuation).
    """
    balance_transactions: Optional[List["BalanceTransaction"]]
    """
    List of balance transactions associated with the dispute.
    """
    created: int
    """
    Time at which the object was created. Measured in seconds since the Unix epoch.
    """
    crypto_transactions: Optional[List[CryptoTransaction]]
    """
    Array of onchain crypto transactions linked to this resource.
    """
    currency: str
    """
    The currency the `transaction` was made in.
    """
    evidence: Evidence
    id: str
    """
    Unique identifier for the object.
    """
    livemode: bool
    """
    If the object exists in live mode, the value is `true`. If the object exists in test mode, the value is `false`.
    """
    loss_reason: Optional[
        Literal[
            "cardholder_authentication_issuer_liability",
            "eci5_token_transaction_with_tavv",
            "excess_disputes_in_timeframe",
            "has_not_met_the_minimum_dispute_amount_requirements",
            "invalid_duplicate_dispute",
            "invalid_incorrect_amount_dispute",
            "invalid_no_authorization",
            "invalid_use_of_disputes",
            "merchandise_delivered_or_shipped",
            "merchandise_or_service_as_described",
            "not_cancelled",
            "other",
            "refund_issued",
            "submitted_beyond_allowable_time_limit",
            "transaction_3ds_required",
            "transaction_approved_after_prior_fraud_dispute",
            "transaction_authorized",
            "transaction_electronically_read",
            "transaction_qualifies_for_visa_easy_payment_service",
            "transaction_unattended",
        ]
    ]
    """
    The enum that describes the dispute loss outcome. If the dispute is not lost, this field will be absent. New enum values may be added in the future, so be sure to handle unknown values.
    """
    metadata: UntypedStripeObject[str]
    """
    Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
    """
    network_lifecycle: Optional[NetworkLifecycle]
    """
    Incoming information from the card network for this dispute. Includes the acquiring merchant's initial response, pre-arbitration submission, and pre-arbitration response to the dispute.
    """
    object: Literal["issuing.dispute"]
    """
    String representing the object's type. Objects of the same type share the same value.
    """
    provisional_credit: Optional[ProvisionalCredit]
    """
    Provisional credit details for this dispute.
    """
    redaction: Optional[Redaction]
    """
    Redaction status of this dispute. If the dispute is not redacted, this field will be null.
    """
    status: Literal["expired", "lost", "submitted", "unsubmitted", "won"]
    """
    Current status of the dispute.
    """
    transaction: ExpandableField["Transaction"]
    """
    The transaction being disputed.
    """
    treasury: Optional[Treasury]
    """
    [Treasury](https://docs.stripe.com/api/treasury) details related to this dispute if it was created on a [FinancialAccount](https://docs.stripe.com/api/treasury/financial_accounts)
    """

    @classmethod
    def create(cls, **params: Unpack["DisputeCreateParams"]) -> "Dispute":
        """
        Creates an Issuing Dispute object. Individual pieces of evidence within the evidence object are optional at this point. Stripe only validates that required evidence is present during submission. Refer to [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence) for more details about evidence requirements.
        """
        return cast(
            "Dispute",
            cls._static_request(
                "post",
                cls.class_url(),
                params=params,
            ),
        )

    @classmethod
    async def create_async(
        cls, **params: Unpack["DisputeCreateParams"]
    ) -> "Dispute":
        """
        Creates an Issuing Dispute object. Individual pieces of evidence within the evidence object are optional at this point. Stripe only validates that required evidence is present during submission. Refer to [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence) for more details about evidence requirements.
        """
        return cast(
            "Dispute",
            await cls._static_request_async(
                "post",
                cls.class_url(),
                params=params,
            ),
        )

    @classmethod
    def list(
        cls, **params: Unpack["DisputeListParams"]
    ) -> ListObject["Dispute"]:
        """
        Returns a list of Issuing Dispute objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.
        """
        result = cls._static_request(
            "get",
            cls.class_url(),
            params=params,
        )
        if not isinstance(result, ListObject):
            raise TypeError(
                "Expected list object from API, got %s"
                % (type(result).__name__)
            )

        return result

    @classmethod
    async def list_async(
        cls, **params: Unpack["DisputeListParams"]
    ) -> ListObject["Dispute"]:
        """
        Returns a list of Issuing Dispute objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.
        """
        result = await cls._static_request_async(
            "get",
            cls.class_url(),
            params=params,
        )
        if not isinstance(result, ListObject):
            raise TypeError(
                "Expected list object from API, got %s"
                % (type(result).__name__)
            )

        return result

    @classmethod
    def modify(
        cls, id: str, **params: Unpack["DisputeModifyParams"]
    ) -> "Dispute":
        """
        Updates the specified Issuing Dispute object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. Properties on the evidence object can be unset by passing in an empty string.
        """
        url = "%s/%s" % (cls.class_url(), sanitize_id(id))
        return cast(
            "Dispute",
            cls._static_request(
                "post",
                url,
                params=params,
            ),
        )

    @classmethod
    async def modify_async(
        cls, id: str, **params: Unpack["DisputeModifyParams"]
    ) -> "Dispute":
        """
        Updates the specified Issuing Dispute object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. Properties on the evidence object can be unset by passing in an empty string.
        """
        url = "%s/%s" % (cls.class_url(), sanitize_id(id))
        return cast(
            "Dispute",
            await cls._static_request_async(
                "post",
                url,
                params=params,
            ),
        )

    @classmethod
    def retrieve(
        cls, id: str, **params: Unpack["DisputeRetrieveParams"]
    ) -> "Dispute":
        """
        Retrieves an Issuing Dispute object.
        """
        instance = cls(id, **params)
        instance.refresh()
        return instance

    @classmethod
    async def retrieve_async(
        cls, id: str, **params: Unpack["DisputeRetrieveParams"]
    ) -> "Dispute":
        """
        Retrieves an Issuing Dispute object.
        """
        instance = cls(id, **params)
        await instance.refresh_async()
        return instance

    @classmethod
    def _cls_submit(
        cls, dispute: str, **params: Unpack["DisputeSubmitParams"]
    ) -> "Dispute":
        """
        Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence).
        """
        return cast(
            "Dispute",
            cls._static_request(
                "post",
                "/v1/issuing/disputes/{dispute}/submit".format(
                    dispute=sanitize_id(dispute)
                ),
                params=params,
            ),
        )

    @overload
    @staticmethod
    def submit(
        dispute: str, **params: Unpack["DisputeSubmitParams"]
    ) -> "Dispute":
        """
        Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence).
        """
        ...

    @overload
    def submit(self, **params: Unpack["DisputeSubmitParams"]) -> "Dispute":
        """
        Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence).
        """
        ...

    @class_method_variant("_cls_submit")
    def submit(  # pyright: ignore[reportGeneralTypeIssues]
        self, **params: Unpack["DisputeSubmitParams"]
    ) -> "Dispute":
        """
        Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence).
        """
        return cast(
            "Dispute",
            self._request(
                "post",
                "/v1/issuing/disputes/{dispute}/submit".format(
                    dispute=sanitize_id(self._data.get("id"))
                ),
                params=params,
            ),
        )

    @classmethod
    async def _cls_submit_async(
        cls, dispute: str, **params: Unpack["DisputeSubmitParams"]
    ) -> "Dispute":
        """
        Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence).
        """
        return cast(
            "Dispute",
            await cls._static_request_async(
                "post",
                "/v1/issuing/disputes/{dispute}/submit".format(
                    dispute=sanitize_id(dispute)
                ),
                params=params,
            ),
        )

    @overload
    @staticmethod
    async def submit_async(
        dispute: str, **params: Unpack["DisputeSubmitParams"]
    ) -> "Dispute":
        """
        Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence).
        """
        ...

    @overload
    async def submit_async(
        self, **params: Unpack["DisputeSubmitParams"]
    ) -> "Dispute":
        """
        Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence).
        """
        ...

    @class_method_variant("_cls_submit_async")
    async def submit_async(  # pyright: ignore[reportGeneralTypeIssues]
        self, **params: Unpack["DisputeSubmitParams"]
    ) -> "Dispute":
        """
        Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://docs.stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence).
        """
        return cast(
            "Dispute",
            await self._request_async(
                "post",
                "/v1/issuing/disputes/{dispute}/submit".format(
                    dispute=sanitize_id(self._data.get("id"))
                ),
                params=params,
            ),
        )

    class TestHelpers(APIResourceTestHelpers["Dispute"]):
        _resource_cls: Type["Dispute"]

        @classmethod
        def _cls_close(
            cls, dispute: str, **params: Unpack["DisputeCloseParams"]
        ) -> "Dispute":
            """
            Test helper: closes a test-mode Issuing dispute as won or lost.
            """
            return cast(
                "Dispute",
                cls._static_request(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/close".format(
                        dispute=sanitize_id(dispute)
                    ),
                    params=params,
                ),
            )

        @overload
        @staticmethod
        def close(
            dispute: str, **params: Unpack["DisputeCloseParams"]
        ) -> "Dispute":
            """
            Test helper: closes a test-mode Issuing dispute as won or lost.
            """
            ...

        @overload
        def close(self, **params: Unpack["DisputeCloseParams"]) -> "Dispute":
            """
            Test helper: closes a test-mode Issuing dispute as won or lost.
            """
            ...

        @class_method_variant("_cls_close")
        def close(  # pyright: ignore[reportGeneralTypeIssues]
            self, **params: Unpack["DisputeCloseParams"]
        ) -> "Dispute":
            """
            Test helper: closes a test-mode Issuing dispute as won or lost.
            """
            return cast(
                "Dispute",
                self.resource._request(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/close".format(
                        dispute=sanitize_id(self.resource._data.get("id"))
                    ),
                    params=params,
                ),
            )

        @classmethod
        async def _cls_close_async(
            cls, dispute: str, **params: Unpack["DisputeCloseParams"]
        ) -> "Dispute":
            """
            Test helper: closes a test-mode Issuing dispute as won or lost.
            """
            return cast(
                "Dispute",
                await cls._static_request_async(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/close".format(
                        dispute=sanitize_id(dispute)
                    ),
                    params=params,
                ),
            )

        @overload
        @staticmethod
        async def close_async(
            dispute: str, **params: Unpack["DisputeCloseParams"]
        ) -> "Dispute":
            """
            Test helper: closes a test-mode Issuing dispute as won or lost.
            """
            ...

        @overload
        async def close_async(
            self, **params: Unpack["DisputeCloseParams"]
        ) -> "Dispute":
            """
            Test helper: closes a test-mode Issuing dispute as won or lost.
            """
            ...

        @class_method_variant("_cls_close_async")
        async def close_async(  # pyright: ignore[reportGeneralTypeIssues]
            self, **params: Unpack["DisputeCloseParams"]
        ) -> "Dispute":
            """
            Test helper: closes a test-mode Issuing dispute as won or lost.
            """
            return cast(
                "Dispute",
                await self.resource._request_async(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/close".format(
                        dispute=sanitize_id(self.resource._data.get("id"))
                    ),
                    params=params,
                ),
            )

        @classmethod
        def _cls_provisional_credit(
            cls,
            dispute: str,
            **params: Unpack["DisputeProvisionalCreditParams"],
        ) -> "Dispute":
            """
            Test helper: overrides the grant_deadline and revocable_after timestamps on a test-mode Issuing dispute's provisional credit, allowing tests to simulate timer-driven status transitions without waiting for real regulatory deadlines to pass.
            """
            return cast(
                "Dispute",
                cls._static_request(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/provisional_credit".format(
                        dispute=sanitize_id(dispute)
                    ),
                    params=params,
                ),
            )

        @overload
        @staticmethod
        def provisional_credit(
            dispute: str, **params: Unpack["DisputeProvisionalCreditParams"]
        ) -> "Dispute":
            """
            Test helper: overrides the grant_deadline and revocable_after timestamps on a test-mode Issuing dispute's provisional credit, allowing tests to simulate timer-driven status transitions without waiting for real regulatory deadlines to pass.
            """
            ...

        @overload
        def provisional_credit(
            self, **params: Unpack["DisputeProvisionalCreditParams"]
        ) -> "Dispute":
            """
            Test helper: overrides the grant_deadline and revocable_after timestamps on a test-mode Issuing dispute's provisional credit, allowing tests to simulate timer-driven status transitions without waiting for real regulatory deadlines to pass.
            """
            ...

        @class_method_variant("_cls_provisional_credit")
        def provisional_credit(  # pyright: ignore[reportGeneralTypeIssues]
            self, **params: Unpack["DisputeProvisionalCreditParams"]
        ) -> "Dispute":
            """
            Test helper: overrides the grant_deadline and revocable_after timestamps on a test-mode Issuing dispute's provisional credit, allowing tests to simulate timer-driven status transitions without waiting for real regulatory deadlines to pass.
            """
            return cast(
                "Dispute",
                self.resource._request(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/provisional_credit".format(
                        dispute=sanitize_id(self.resource._data.get("id"))
                    ),
                    params=params,
                ),
            )

        @classmethod
        async def _cls_provisional_credit_async(
            cls,
            dispute: str,
            **params: Unpack["DisputeProvisionalCreditParams"],
        ) -> "Dispute":
            """
            Test helper: overrides the grant_deadline and revocable_after timestamps on a test-mode Issuing dispute's provisional credit, allowing tests to simulate timer-driven status transitions without waiting for real regulatory deadlines to pass.
            """
            return cast(
                "Dispute",
                await cls._static_request_async(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/provisional_credit".format(
                        dispute=sanitize_id(dispute)
                    ),
                    params=params,
                ),
            )

        @overload
        @staticmethod
        async def provisional_credit_async(
            dispute: str, **params: Unpack["DisputeProvisionalCreditParams"]
        ) -> "Dispute":
            """
            Test helper: overrides the grant_deadline and revocable_after timestamps on a test-mode Issuing dispute's provisional credit, allowing tests to simulate timer-driven status transitions without waiting for real regulatory deadlines to pass.
            """
            ...

        @overload
        async def provisional_credit_async(
            self, **params: Unpack["DisputeProvisionalCreditParams"]
        ) -> "Dispute":
            """
            Test helper: overrides the grant_deadline and revocable_after timestamps on a test-mode Issuing dispute's provisional credit, allowing tests to simulate timer-driven status transitions without waiting for real regulatory deadlines to pass.
            """
            ...

        @class_method_variant("_cls_provisional_credit_async")
        async def provisional_credit_async(  # pyright: ignore[reportGeneralTypeIssues]
            self, **params: Unpack["DisputeProvisionalCreditParams"]
        ) -> "Dispute":
            """
            Test helper: overrides the grant_deadline and revocable_after timestamps on a test-mode Issuing dispute's provisional credit, allowing tests to simulate timer-driven status transitions without waiting for real regulatory deadlines to pass.
            """
            return cast(
                "Dispute",
                await self.resource._request_async(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/provisional_credit".format(
                        dispute=sanitize_id(self.resource._data.get("id"))
                    ),
                    params=params,
                ),
            )

        @classmethod
        def _cls_simulate_network_lifecycle_dispute_response(
            cls,
            dispute: str,
            **params: Unpack[
                "DisputeSimulateNetworkLifecycleDisputeResponseParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.dispute_response on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes.
            """
            return cast(
                "Dispute",
                cls._static_request(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/simulate_network_lifecycle_dispute_response".format(
                        dispute=sanitize_id(dispute)
                    ),
                    params=params,
                ),
            )

        @overload
        @staticmethod
        def simulate_network_lifecycle_dispute_response(
            dispute: str,
            **params: Unpack[
                "DisputeSimulateNetworkLifecycleDisputeResponseParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.dispute_response on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes.
            """
            ...

        @overload
        def simulate_network_lifecycle_dispute_response(
            self,
            **params: Unpack[
                "DisputeSimulateNetworkLifecycleDisputeResponseParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.dispute_response on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes.
            """
            ...

        @class_method_variant(
            "_cls_simulate_network_lifecycle_dispute_response",
        )
        def simulate_network_lifecycle_dispute_response(  # pyright: ignore[reportGeneralTypeIssues]
            self,
            **params: Unpack[
                "DisputeSimulateNetworkLifecycleDisputeResponseParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.dispute_response on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes.
            """
            return cast(
                "Dispute",
                self.resource._request(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/simulate_network_lifecycle_dispute_response".format(
                        dispute=sanitize_id(self.resource._data.get("id"))
                    ),
                    params=params,
                ),
            )

        @classmethod
        async def _cls_simulate_network_lifecycle_dispute_response_async(
            cls,
            dispute: str,
            **params: Unpack[
                "DisputeSimulateNetworkLifecycleDisputeResponseParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.dispute_response on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes.
            """
            return cast(
                "Dispute",
                await cls._static_request_async(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/simulate_network_lifecycle_dispute_response".format(
                        dispute=sanitize_id(dispute)
                    ),
                    params=params,
                ),
            )

        @overload
        @staticmethod
        async def simulate_network_lifecycle_dispute_response_async(
            dispute: str,
            **params: Unpack[
                "DisputeSimulateNetworkLifecycleDisputeResponseParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.dispute_response on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes.
            """
            ...

        @overload
        async def simulate_network_lifecycle_dispute_response_async(
            self,
            **params: Unpack[
                "DisputeSimulateNetworkLifecycleDisputeResponseParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.dispute_response on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes.
            """
            ...

        @class_method_variant(
            "_cls_simulate_network_lifecycle_dispute_response_async",
        )
        async def simulate_network_lifecycle_dispute_response_async(  # pyright: ignore[reportGeneralTypeIssues]
            self,
            **params: Unpack[
                "DisputeSimulateNetworkLifecycleDisputeResponseParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.dispute_response on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes.
            """
            return cast(
                "Dispute",
                await self.resource._request_async(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/simulate_network_lifecycle_dispute_response".format(
                        dispute=sanitize_id(self.resource._data.get("id"))
                    ),
                    params=params,
                ),
            )

        @classmethod
        def _cls_simulate_network_lifecycle_pre_arbitration_response(
            cls,
            dispute: str,
            **params: Unpack[
                "DisputeSimulateNetworkLifecyclePreArbitrationResponseParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.pre_arbitration_response on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes in the collaboration flow.
            """
            return cast(
                "Dispute",
                cls._static_request(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/simulate_network_lifecycle_pre_arbitration_response".format(
                        dispute=sanitize_id(dispute)
                    ),
                    params=params,
                ),
            )

        @overload
        @staticmethod
        def simulate_network_lifecycle_pre_arbitration_response(
            dispute: str,
            **params: Unpack[
                "DisputeSimulateNetworkLifecyclePreArbitrationResponseParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.pre_arbitration_response on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes in the collaboration flow.
            """
            ...

        @overload
        def simulate_network_lifecycle_pre_arbitration_response(
            self,
            **params: Unpack[
                "DisputeSimulateNetworkLifecyclePreArbitrationResponseParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.pre_arbitration_response on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes in the collaboration flow.
            """
            ...

        @class_method_variant(
            "_cls_simulate_network_lifecycle_pre_arbitration_response",
        )
        def simulate_network_lifecycle_pre_arbitration_response(  # pyright: ignore[reportGeneralTypeIssues]
            self,
            **params: Unpack[
                "DisputeSimulateNetworkLifecyclePreArbitrationResponseParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.pre_arbitration_response on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes in the collaboration flow.
            """
            return cast(
                "Dispute",
                self.resource._request(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/simulate_network_lifecycle_pre_arbitration_response".format(
                        dispute=sanitize_id(self.resource._data.get("id"))
                    ),
                    params=params,
                ),
            )

        @classmethod
        async def _cls_simulate_network_lifecycle_pre_arbitration_response_async(
            cls,
            dispute: str,
            **params: Unpack[
                "DisputeSimulateNetworkLifecyclePreArbitrationResponseParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.pre_arbitration_response on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes in the collaboration flow.
            """
            return cast(
                "Dispute",
                await cls._static_request_async(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/simulate_network_lifecycle_pre_arbitration_response".format(
                        dispute=sanitize_id(dispute)
                    ),
                    params=params,
                ),
            )

        @overload
        @staticmethod
        async def simulate_network_lifecycle_pre_arbitration_response_async(
            dispute: str,
            **params: Unpack[
                "DisputeSimulateNetworkLifecyclePreArbitrationResponseParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.pre_arbitration_response on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes in the collaboration flow.
            """
            ...

        @overload
        async def simulate_network_lifecycle_pre_arbitration_response_async(
            self,
            **params: Unpack[
                "DisputeSimulateNetworkLifecyclePreArbitrationResponseParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.pre_arbitration_response on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes in the collaboration flow.
            """
            ...

        @class_method_variant(
            "_cls_simulate_network_lifecycle_pre_arbitration_response_async",
        )
        async def simulate_network_lifecycle_pre_arbitration_response_async(  # pyright: ignore[reportGeneralTypeIssues]
            self,
            **params: Unpack[
                "DisputeSimulateNetworkLifecyclePreArbitrationResponseParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.pre_arbitration_response on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes in the collaboration flow.
            """
            return cast(
                "Dispute",
                await self.resource._request_async(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/simulate_network_lifecycle_pre_arbitration_response".format(
                        dispute=sanitize_id(self.resource._data.get("id"))
                    ),
                    params=params,
                ),
            )

        @classmethod
        def _cls_simulate_network_lifecycle_pre_arbitration_submission(
            cls,
            dispute: str,
            **params: Unpack[
                "DisputeSimulateNetworkLifecyclePreArbitrationSubmissionParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.pre_arbitration_submission on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes.
            """
            return cast(
                "Dispute",
                cls._static_request(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/simulate_network_lifecycle_pre_arbitration_submission".format(
                        dispute=sanitize_id(dispute)
                    ),
                    params=params,
                ),
            )

        @overload
        @staticmethod
        def simulate_network_lifecycle_pre_arbitration_submission(
            dispute: str,
            **params: Unpack[
                "DisputeSimulateNetworkLifecyclePreArbitrationSubmissionParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.pre_arbitration_submission on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes.
            """
            ...

        @overload
        def simulate_network_lifecycle_pre_arbitration_submission(
            self,
            **params: Unpack[
                "DisputeSimulateNetworkLifecyclePreArbitrationSubmissionParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.pre_arbitration_submission on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes.
            """
            ...

        @class_method_variant(
            "_cls_simulate_network_lifecycle_pre_arbitration_submission",
        )
        def simulate_network_lifecycle_pre_arbitration_submission(  # pyright: ignore[reportGeneralTypeIssues]
            self,
            **params: Unpack[
                "DisputeSimulateNetworkLifecyclePreArbitrationSubmissionParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.pre_arbitration_submission on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes.
            """
            return cast(
                "Dispute",
                self.resource._request(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/simulate_network_lifecycle_pre_arbitration_submission".format(
                        dispute=sanitize_id(self.resource._data.get("id"))
                    ),
                    params=params,
                ),
            )

        @classmethod
        async def _cls_simulate_network_lifecycle_pre_arbitration_submission_async(
            cls,
            dispute: str,
            **params: Unpack[
                "DisputeSimulateNetworkLifecyclePreArbitrationSubmissionParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.pre_arbitration_submission on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes.
            """
            return cast(
                "Dispute",
                await cls._static_request_async(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/simulate_network_lifecycle_pre_arbitration_submission".format(
                        dispute=sanitize_id(dispute)
                    ),
                    params=params,
                ),
            )

        @overload
        @staticmethod
        async def simulate_network_lifecycle_pre_arbitration_submission_async(
            dispute: str,
            **params: Unpack[
                "DisputeSimulateNetworkLifecyclePreArbitrationSubmissionParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.pre_arbitration_submission on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes.
            """
            ...

        @overload
        async def simulate_network_lifecycle_pre_arbitration_submission_async(
            self,
            **params: Unpack[
                "DisputeSimulateNetworkLifecyclePreArbitrationSubmissionParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.pre_arbitration_submission on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes.
            """
            ...

        @class_method_variant(
            "_cls_simulate_network_lifecycle_pre_arbitration_submission_async",
        )
        async def simulate_network_lifecycle_pre_arbitration_submission_async(  # pyright: ignore[reportGeneralTypeIssues]
            self,
            **params: Unpack[
                "DisputeSimulateNetworkLifecyclePreArbitrationSubmissionParams"
            ],
        ) -> "Dispute":
            """
            Test helper: populates network_lifecycle.pre_arbitration_submission on a test-mode Visa Issuing Dispute using placeholder file tokens. Only supported for Visa disputes.
            """
            return cast(
                "Dispute",
                await self.resource._request_async(
                    "post",
                    "/v1/test_helpers/issuing/disputes/{dispute}/simulate_network_lifecycle_pre_arbitration_submission".format(
                        dispute=sanitize_id(self.resource._data.get("id"))
                    ),
                    params=params,
                ),
            )

    @property
    def test_helpers(self):
        return self.TestHelpers(self)

    _inner_class_types = {
        "crypto_transactions": CryptoTransaction,
        "evidence": Evidence,
        "network_lifecycle": NetworkLifecycle,
        "provisional_credit": ProvisionalCredit,
        "redaction": Redaction,
        "treasury": Treasury,
    }


Dispute.TestHelpers._resource_cls = Dispute
