# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ..core.serialization import FieldMetadata
from .authcode import Authcode
from .avs_response import AvsResponse
from .avs_response_text import AvsResponseText
from .cvv_response import CvvResponse
from .cvv_response_text import CvvResponseText
from .emv_auth_response_data import EmvAuthResponseData
from .order_id import OrderId
from .result_code_text import ResultCodeText
from .result_codev_2 import ResultCodev2


class QueryResponseData(UniversalBaseModel):
    """
    The transaction's response data.

    Examples
    --------
    from payabli import QueryResponseData

    QueryResponseData(
        authcode="123456",
        avsresponse="N",
        avsresponse_text="No address or ZIP match only",
        cvvresponse="M",
        cvvresponse_text="CVV2/CVC2 match",
        orderid="10-bfcd5a17861d4a8690ca53c00000X",
        response="Success",
        response_code="100",
        response_code_text="Transaction was approved.",
        responsetext="SUCCESS",
        result_code="A0000",
        result_code_text="Approved",
        transactionid="8082800000",
    )
    """

    authcode: typing.Optional[Authcode] = None
    avsresponse: typing.Optional[AvsResponse] = None
    avsresponse_text: typing.Optional[AvsResponseText] = None
    cvvresponse: typing.Optional[CvvResponse] = None
    cvvresponse_text: typing.Optional[CvvResponseText] = None
    emv_auth_response_data: typing.Optional[EmvAuthResponseData] = None
    orderid: typing.Optional[OrderId] = None
    response: typing.Optional[str] = pydantic.Field(default=None)
    """
    Response text for operation: 'Success' or 'Declined'.
    """

    response_code: typing.Optional[str] = pydantic.Field(default=None)
    """
    Internal result code processing the transaction. Value 1 indicates successful operation, values 2 and 3 indicate errors.
    """

    response_code_text: typing.Optional[str] = pydantic.Field(default=None)
    """
    Text describing the result. If resultCode = 1, will return 'Approved' or a general success message. If resultCode = 2 or 3, will contain the cause of the decline.
    """

    responsetext: typing.Optional[str] = pydantic.Field(default=None)
    """
    Text describing the result. If resultCode = 1, will return 'Approved' or a general success message. If resultCode = 2 or 3, will contain the cause of the decline.
    """

    result_code: typing_extensions.Annotated[
        typing.Optional[ResultCodev2], FieldMetadata(alias="resultCode"), pydantic.Field(alias="resultCode")
    ] = None
    result_code_text: typing_extensions.Annotated[
        typing.Optional[ResultCodeText], FieldMetadata(alias="resultCodeText"), pydantic.Field(alias="resultCodeText")
    ] = None
    transactionid: typing.Optional[str] = pydantic.Field(default=None)
    """
    The transaction identifier in Payabli.
    """

    type: typing.Optional[str] = pydantic.Field(default=None)
    """
    Type of transaction or operation.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
