# coding: utf-8

"""
    Marqeta Core API

    Simplified management of your payment programs  # noqa: E501

    The version of the OpenAPI document: 3.0.0
    Contact: dev@swadesh.co
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


from __future__ import annotations
from inspect import getfullargspec
import pprint
import re  # noqa: F401
import json

from datetime import datetime
from typing import Dict, List, Optional, Union
from pydantic import BaseModel, Field, StrictBool, StrictFloat, StrictInt, StrictStr, conlist, constr, validator
from marqeta_client.models.account_funding import AccountFunding
from marqeta_client.models.acquirer import Acquirer
from marqeta_client.models.address_verification_model import AddressVerificationModel
from marqeta_client.models.atc_information_model import ATCInformationModel
from marqeta_client.models.auto_reload_model import AutoReloadModel
from marqeta_client.models.business_metadata import BusinessMetadata
from marqeta_client.models.card_response import CardResponse
from marqeta_client.models.card_security_code_verification import CardSecurityCodeVerification
from marqeta_client.models.cardholder_authentication_data import CardholderAuthenticationData
from marqeta_client.models.cardholder_balance import CardholderBalance
from marqeta_client.models.cardholder_metadata import CardholderMetadata
from marqeta_client.models.chargeback_response import ChargebackResponse
from marqeta_client.models.currency_conversion import CurrencyConversion
from marqeta_client.models.deposit_deposit_response import DepositDepositResponse
from marqeta_client.models.digital_wallet_token import DigitalWalletToken
from marqeta_client.models.dispute_model import DisputeModel
from marqeta_client.models.fee import Fee
from marqeta_client.models.fee_transfer_response import FeeTransferResponse
from marqeta_client.models.fraud_view import FraudView
from marqeta_client.models.gpa_response import GpaResponse
from marqeta_client.models.gpa_returns import GpaReturns
from marqeta_client.models.merchant_response_model import MerchantResponseModel
from marqeta_client.models.msa_order_response import MsaOrderResponse
from marqeta_client.models.msa_returns import MsaReturns
from marqeta_client.models.network_fee_model import NetworkFeeModel
from marqeta_client.models.network_metadata import NetworkMetadata
from marqeta_client.models.offer_order_response import OfferOrderResponse
from marqeta_client.models.original_credit import OriginalCredit
from marqeta_client.models.peer_transfer_response import PeerTransferResponse
from marqeta_client.models.pos import Pos
from marqeta_client.models.preceding_transaction import PrecedingTransaction
from marqeta_client.models.program import Program
from marqeta_client.models.program_transfer_response import ProgramTransferResponse
from marqeta_client.models.pull_from_card_transfer_response import PullFromCardTransferResponse
from marqeta_client.models.real_time_fee_group import RealTimeFeeGroup
from marqeta_client.models.response import Response
from marqeta_client.models.store_response_model import StoreResponseModel
from marqeta_client.models.transaction_card_acceptor import TransactionCardAcceptor
from marqeta_client.models.transaction_metadata import TransactionMetadata
from marqeta_client.models.user_card_holder_response import UserCardHolderResponse

class TransactionModel(BaseModel):
    """
    TransactionModel
    """
    identifier: Optional[StrictStr] = None
    token: constr(strict=True, max_length=36, min_length=1) = ...
    user_token: Optional[constr(strict=True, max_length=36, min_length=0)] = None
    business_token: Optional[constr(strict=True, max_length=36, min_length=0)] = None
    acting_user_token: constr(strict=True, max_length=36, min_length=0) = ...
    card_token: Optional[constr(strict=True, max_length=36, min_length=0)] = None
    card_product_token: Optional[constr(strict=True, max_length=36, min_length=0)] = None
    is_preauthorization: Optional[StrictBool] = False
    type: StrictStr = ...
    state: StrictStr = ...
    duration: Optional[StrictInt] = None
    created_time: Optional[datetime] = None
    user_transaction_time: Optional[datetime] = None
    settlement_date: Optional[datetime] = None
    request_amount: Optional[Union[StrictFloat, StrictInt]] = None
    amount: Union[StrictFloat, StrictInt] = ...
    cash_back_amount: Optional[Union[StrictFloat, StrictInt]] = None
    currency_conversion: Optional[CurrencyConversion] = None
    issuer_interchange_amount: Optional[Union[StrictFloat, StrictInt]] = None
    currency_code: Optional[StrictStr] = None
    approval_code: Optional[StrictStr] = None
    response: Optional[Response] = None
    preceding_related_transaction_token: Optional[StrictStr] = None
    preceding_transaction: Optional[PrecedingTransaction] = None
    amount_to_be_released: Optional[Union[StrictFloat, StrictInt]] = None
    incremental_authorization_transaction_tokens: Optional[conlist(StrictStr)] = None
    merchant: Optional[MerchantResponseModel] = None
    store: Optional[StoreResponseModel] = None
    card_acceptor: Optional[TransactionCardAcceptor] = None
    gpa: Optional[CardholderBalance] = None
    card: Optional[CardResponse] = None
    gpa_order_unload: Optional[GpaReturns] = None
    gpa_order: Optional[GpaResponse] = None
    program_transfer: Optional[ProgramTransferResponse] = None
    fee_transfer: Optional[FeeTransferResponse] = None
    peer_transfer: Optional[PeerTransferResponse] = None
    msa_orders: Optional[conlist(MsaOrderResponse)] = None
    msa_order_unload: Optional[MsaReturns] = None
    offer_orders: Optional[conlist(OfferOrderResponse)] = None
    auto_reload: Optional[AutoReloadModel] = None
    direct_deposit: Optional[DepositDepositResponse] = None
    pull_from_card: Optional[PullFromCardTransferResponse] = None
    polarity: Optional[StrictStr] = None
    real_time_fee_group: Optional[RealTimeFeeGroup] = None
    fee: Optional[Fee] = None
    chargeback: Optional[ChargebackResponse] = None
    dispute: Optional[DisputeModel] = None
    network: Optional[StrictStr] = None
    subnetwork: Optional[StrictStr] = None
    network_metadata: Optional[NetworkMetadata] = None
    acquirer_fee_amount: Optional[Union[StrictFloat, StrictInt]] = None
    fees: Optional[conlist(NetworkFeeModel)] = None
    digital_wallet_token: Optional[DigitalWalletToken] = None
    user: Optional[CardholderMetadata] = None
    business: Optional[BusinessMetadata] = None
    acquirer: Optional[Acquirer] = None
    fraud: Optional[FraudView] = None
    pos: Optional[Pos] = None
    address_verification: Optional[AddressVerificationModel] = None
    card_security_code_verification: Optional[CardSecurityCodeVerification] = None
    transaction_metadata: Optional[TransactionMetadata] = None
    original_credit: Optional[OriginalCredit] = None
    account_funding: Optional[AccountFunding] = None
    card_holder_model: Optional[UserCardHolderResponse] = None
    standin_approved_by: Optional[StrictStr] = None
    standin_by: Optional[StrictStr] = None
    standin_reason: Optional[StrictStr] = None
    network_reference_id: Optional[StrictStr] = None
    acquirer_reference_id: Optional[StrictStr] = None
    cardholder_authentication_data: Optional[CardholderAuthenticationData] = None
    transaction_attributes: Optional[Dict[str, StrictStr]] = None
    clearing_record_sequence_number: Optional[StrictStr] = None
    issuer_received_time: Optional[StrictStr] = None
    issuer_payment_node: Optional[StrictStr] = None
    program: Optional[Program] = None
    batch_number: Optional[StrictStr] = None
    from_account: Optional[StrictStr] = None
    multi_clearing_sequence_number: Optional[StrictStr] = None
    multi_clearing_sequence_count: Optional[StrictStr] = None
    isa_indicator: Optional[StrictStr] = Field(None, alias="isaIndicator")
    enhanced_data_token: Optional[StrictStr] = None
    advice_reason_code: Optional[StrictStr] = None
    advice_reason_details: Optional[StrictStr] = None
    bank_transfer_token: Optional[StrictStr] = None
    interchange_rate_descriptor: Optional[StrictStr] = None
    real_time_fee_type: Optional[StrictStr] = None
    atc_information: Optional[ATCInformationModel] = None
    __properties = ["identifier", "token", "user_token", "business_token", "acting_user_token", "card_token", "card_product_token", "is_preauthorization", "type", "state", "duration", "created_time", "user_transaction_time", "settlement_date", "request_amount", "amount", "cash_back_amount", "currency_conversion", "issuer_interchange_amount", "currency_code", "approval_code", "response", "preceding_related_transaction_token", "preceding_transaction", "amount_to_be_released", "incremental_authorization_transaction_tokens", "merchant", "store", "card_acceptor", "gpa", "card", "gpa_order_unload", "gpa_order", "program_transfer", "fee_transfer", "peer_transfer", "msa_orders", "msa_order_unload", "offer_orders", "auto_reload", "direct_deposit", "pull_from_card", "polarity", "real_time_fee_group", "fee", "chargeback", "dispute", "network", "subnetwork", "network_metadata", "acquirer_fee_amount", "fees", "digital_wallet_token", "user", "business", "acquirer", "fraud", "pos", "address_verification", "card_security_code_verification", "transaction_metadata", "original_credit", "account_funding", "card_holder_model", "standin_approved_by", "standin_by", "standin_reason", "network_reference_id", "acquirer_reference_id", "cardholder_authentication_data", "transaction_attributes", "clearing_record_sequence_number", "issuer_received_time", "issuer_payment_node", "program", "batch_number", "from_account", "multi_clearing_sequence_number", "multi_clearing_sequence_count", "isaIndicator", "enhanced_data_token", "advice_reason_code", "advice_reason_details", "bank_transfer_token", "interchange_rate_descriptor", "real_time_fee_type", "atc_information"]

    @validator('type')
    def type_validate_enum(cls, v):
        if v not in ('gpa.credit', 'gpa.credit.pending', 'gpa.credit.pending.reversal', 'gpa.credit.reversal', 'gpa.credit.networkload', 'gpa.credit.networkload.reversal', 'gpa.debit.networkload', 'gpa.debit', 'gpa.debit.pending', 'gpa.debit.pending.reversal', 'gpa.grant', 'gpa.credit.issueroperator', 'gpa.debit.issueroperator', 'gpa.credit.chargeback', 'gpa.credit.chargeback.reversal', 'gpa.credit.billpayment', 'gpa.credit.authorization.billpayment', 'gpa.credit.authorization.billpayment.reversal', 'msa.credit.pending', 'msa.credit.pending.reversal', 'msa.credit.reversal', 'msa.credit', 'msa.debit.pending', 'msa.debit.pending.reversal', 'msa.debit', 'msa.credit.chargeback', 'msa.credit.chargeback.reversal', 'authorization', 'authorization.advice', 'authorization.reversal', 'authorization.clearing', 'authorization.reversal.issuerexpiration', 'dispute.credit', 'dispute.debit', 'authorization.clearing.chargeback', 'authorization.clearing.chargeback.reversal', 'refund', 'pindebit.atm.withdrawal', 'pindebit.balanceinquiry', 'pindebit.cashback', 'pindebit', 'programreserve.credit', 'programreserve.debit', 'fee.charge.pending', 'fee.charge', 'fee.charge.pending.refund', 'funds.expire', 'reward.earn', 'transfer.peer', 'transfer.fee', 'account.funding.authorization', 'account.funding.authorization.reversal', 'account.funding.authorization.clearing', 'account.funding.auth_plus_capture', 'account.funding.auth_plus_capture.reversal', 'account.credit', 'account.debit', 'balanceinquiry', 'authorization.atm.withdrawal', 'authorization.clearing.atm.withdrawal', 'authorization.cashback', 'authorization.clearing.cashback', 'transfer.program', 'authorization.quasi.cash', 'authorization.clearing.quasi.cash', 'authorization.incremental', 'gpa.credit.authorization', 'gpa.credit.authorization.reversal', 'gpa.debit.authorization', 'gpa.debit.reversal', 'original.credit.authorization', 'original.credit.authorization.reversal', 'original.credit.authorization.clearing', 'original.credit.auth_plus_capture', 'original.credit.auth_plus_capture.reversal', 'refund.authorization', 'refund.authorization.advice', 'refund.authorization.clearing', 'refund.authorization.reversal', 'token.activation-request', 'token.advice', 'pindebit.authorization', 'pindebit.authorization.clearing', 'pindebit.authorization.reversal', 'pindebit.authorization.reversal.issuerexpiration', 'authorization.standin', 'authorization.clearing.chargeback.completed', 'authorization.clearing.chargeback.provisional.credit', 'authorization.clearing.chargeback.provisional.debit', 'authorization.clearing.chargeback.writeoff', 'directdeposit.credit', 'directdeposit.credit.pending', 'directdeposit.credit.reject', 'directdeposit.credit.pending.reversal', 'directdeposit.credit.reversal', 'directdeposit.debit', 'directdeposit.debit.pending', 'directdeposit.debit.reject', 'directdeposit.debit.reversal', 'directdeposit.debit.pending.reversal', 'fee.charge.reversal', 'pindebit.chargeback', 'pindebit.chargeback.completed', 'pindebit.chargeback.provisional.credit', 'pindebit.chargeback.provisional.debit', 'pindebit.chargeback.reversal', 'pindebit.chargeback.writeoff', 'pindebit.credit.adjustment', 'pindebit.quasicash', 'pindebit.quasi.cash', 'pindebit.refund', 'pindebit.refund.reversal', 'pindebit.reversal', 'pindebit.transfer', 'pushtocard.debit', 'pushtocard.reversal', 'credit.adjustment', 'debit.adjustment', 'unknown'):
            raise ValueError("must be one of enum values ('gpa.credit', 'gpa.credit.pending', 'gpa.credit.pending.reversal', 'gpa.credit.reversal', 'gpa.credit.networkload', 'gpa.credit.networkload.reversal', 'gpa.debit.networkload', 'gpa.debit', 'gpa.debit.pending', 'gpa.debit.pending.reversal', 'gpa.grant', 'gpa.credit.issueroperator', 'gpa.debit.issueroperator', 'gpa.credit.chargeback', 'gpa.credit.chargeback.reversal', 'gpa.credit.billpayment', 'gpa.credit.authorization.billpayment', 'gpa.credit.authorization.billpayment.reversal', 'msa.credit.pending', 'msa.credit.pending.reversal', 'msa.credit.reversal', 'msa.credit', 'msa.debit.pending', 'msa.debit.pending.reversal', 'msa.debit', 'msa.credit.chargeback', 'msa.credit.chargeback.reversal', 'authorization', 'authorization.advice', 'authorization.reversal', 'authorization.clearing', 'authorization.reversal.issuerexpiration', 'dispute.credit', 'dispute.debit', 'authorization.clearing.chargeback', 'authorization.clearing.chargeback.reversal', 'refund', 'pindebit.atm.withdrawal', 'pindebit.balanceinquiry', 'pindebit.cashback', 'pindebit', 'programreserve.credit', 'programreserve.debit', 'fee.charge.pending', 'fee.charge', 'fee.charge.pending.refund', 'funds.expire', 'reward.earn', 'transfer.peer', 'transfer.fee', 'account.funding.authorization', 'account.funding.authorization.reversal', 'account.funding.authorization.clearing', 'account.funding.auth_plus_capture', 'account.funding.auth_plus_capture.reversal', 'account.credit', 'account.debit', 'balanceinquiry', 'authorization.atm.withdrawal', 'authorization.clearing.atm.withdrawal', 'authorization.cashback', 'authorization.clearing.cashback', 'transfer.program', 'authorization.quasi.cash', 'authorization.clearing.quasi.cash', 'authorization.incremental', 'gpa.credit.authorization', 'gpa.credit.authorization.reversal', 'gpa.debit.authorization', 'gpa.debit.reversal', 'original.credit.authorization', 'original.credit.authorization.reversal', 'original.credit.authorization.clearing', 'original.credit.auth_plus_capture', 'original.credit.auth_plus_capture.reversal', 'refund.authorization', 'refund.authorization.advice', 'refund.authorization.clearing', 'refund.authorization.reversal', 'token.activation-request', 'token.advice', 'pindebit.authorization', 'pindebit.authorization.clearing', 'pindebit.authorization.reversal', 'pindebit.authorization.reversal.issuerexpiration', 'authorization.standin', 'authorization.clearing.chargeback.completed', 'authorization.clearing.chargeback.provisional.credit', 'authorization.clearing.chargeback.provisional.debit', 'authorization.clearing.chargeback.writeoff', 'directdeposit.credit', 'directdeposit.credit.pending', 'directdeposit.credit.reject', 'directdeposit.credit.pending.reversal', 'directdeposit.credit.reversal', 'directdeposit.debit', 'directdeposit.debit.pending', 'directdeposit.debit.reject', 'directdeposit.debit.reversal', 'directdeposit.debit.pending.reversal', 'fee.charge.reversal', 'pindebit.chargeback', 'pindebit.chargeback.completed', 'pindebit.chargeback.provisional.credit', 'pindebit.chargeback.provisional.debit', 'pindebit.chargeback.reversal', 'pindebit.chargeback.writeoff', 'pindebit.credit.adjustment', 'pindebit.quasicash', 'pindebit.quasi.cash', 'pindebit.refund', 'pindebit.refund.reversal', 'pindebit.reversal', 'pindebit.transfer', 'pushtocard.debit', 'pushtocard.reversal', 'credit.adjustment', 'debit.adjustment', 'unknown')")
        return v

    @validator('state')
    def state_validate_enum(cls, v):
        if v not in ('PENDING', 'CLEARED', 'COMPLETION', 'DECLINED', 'ERROR'):
            raise ValueError("must be one of enum values ('PENDING', 'CLEARED', 'COMPLETION', 'DECLINED', 'ERROR')")
        return v

    @validator('polarity')
    def polarity_validate_enum(cls, v):
        if v is None:
            return v

        if v not in ('CREDIT', 'DEBIT', 'PENDING_CREDIT', 'PENDING_DEBIT'):
            raise ValueError("must be one of enum values ('CREDIT', 'DEBIT', 'PENDING_CREDIT', 'PENDING_DEBIT')")
        return v

    @validator('isa_indicator')
    def isa_indicator_validate_enum(cls, v):
        if v is None:
            return v

        if v not in ('MULTI_CURRENCY', 'SINGLE_CURRENCY', 'REBATE_CANCELLED', 'MULTI_CURRENCY_NON_US_COUNTRIES', 'SINGLE_CURRENCY_PAID_BY_ISSUER', 'NO_CHARGE_ASSESSED'):
            raise ValueError("must be one of enum values ('MULTI_CURRENCY', 'SINGLE_CURRENCY', 'REBATE_CANCELLED', 'MULTI_CURRENCY_NON_US_COUNTRIES', 'SINGLE_CURRENCY_PAID_BY_ISSUER', 'NO_CHARGE_ASSESSED')")
        return v

    class Config:
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> TransactionModel:
        """Create an instance of TransactionModel from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                            "token",
                            "type",
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of currency_conversion
        if self.currency_conversion:
            _dict['currency_conversion'] = self.currency_conversion.to_dict()
        # override the default output from pydantic by calling `to_dict()` of response
        if self.response:
            _dict['response'] = self.response.to_dict()
        # override the default output from pydantic by calling `to_dict()` of preceding_transaction
        if self.preceding_transaction:
            _dict['preceding_transaction'] = self.preceding_transaction.to_dict()
        # override the default output from pydantic by calling `to_dict()` of merchant
        if self.merchant:
            _dict['merchant'] = self.merchant.to_dict()
        # override the default output from pydantic by calling `to_dict()` of store
        if self.store:
            _dict['store'] = self.store.to_dict()
        # override the default output from pydantic by calling `to_dict()` of card_acceptor
        if self.card_acceptor:
            _dict['card_acceptor'] = self.card_acceptor.to_dict()
        # override the default output from pydantic by calling `to_dict()` of gpa
        if self.gpa:
            _dict['gpa'] = self.gpa.to_dict()
        # override the default output from pydantic by calling `to_dict()` of card
        if self.card:
            _dict['card'] = self.card.to_dict()
        # override the default output from pydantic by calling `to_dict()` of gpa_order_unload
        if self.gpa_order_unload:
            _dict['gpa_order_unload'] = self.gpa_order_unload.to_dict()
        # override the default output from pydantic by calling `to_dict()` of gpa_order
        if self.gpa_order:
            _dict['gpa_order'] = self.gpa_order.to_dict()
        # override the default output from pydantic by calling `to_dict()` of program_transfer
        if self.program_transfer:
            _dict['program_transfer'] = self.program_transfer.to_dict()
        # override the default output from pydantic by calling `to_dict()` of fee_transfer
        if self.fee_transfer:
            _dict['fee_transfer'] = self.fee_transfer.to_dict()
        # override the default output from pydantic by calling `to_dict()` of peer_transfer
        if self.peer_transfer:
            _dict['peer_transfer'] = self.peer_transfer.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in msa_orders (list)
        _items = []
        if self.msa_orders:
            for _item in self.msa_orders:
                if _item:
                    _items.append(_item.to_dict())
            _dict['msa_orders'] = _items
        # override the default output from pydantic by calling `to_dict()` of msa_order_unload
        if self.msa_order_unload:
            _dict['msa_order_unload'] = self.msa_order_unload.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in offer_orders (list)
        _items = []
        if self.offer_orders:
            for _item in self.offer_orders:
                if _item:
                    _items.append(_item.to_dict())
            _dict['offer_orders'] = _items
        # override the default output from pydantic by calling `to_dict()` of auto_reload
        if self.auto_reload:
            _dict['auto_reload'] = self.auto_reload.to_dict()
        # override the default output from pydantic by calling `to_dict()` of direct_deposit
        if self.direct_deposit:
            _dict['direct_deposit'] = self.direct_deposit.to_dict()
        # override the default output from pydantic by calling `to_dict()` of pull_from_card
        if self.pull_from_card:
            _dict['pull_from_card'] = self.pull_from_card.to_dict()
        # override the default output from pydantic by calling `to_dict()` of real_time_fee_group
        if self.real_time_fee_group:
            _dict['real_time_fee_group'] = self.real_time_fee_group.to_dict()
        # override the default output from pydantic by calling `to_dict()` of fee
        if self.fee:
            _dict['fee'] = self.fee.to_dict()
        # override the default output from pydantic by calling `to_dict()` of chargeback
        if self.chargeback:
            _dict['chargeback'] = self.chargeback.to_dict()
        # override the default output from pydantic by calling `to_dict()` of dispute
        if self.dispute:
            _dict['dispute'] = self.dispute.to_dict()
        # override the default output from pydantic by calling `to_dict()` of network_metadata
        if self.network_metadata:
            _dict['network_metadata'] = self.network_metadata.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in fees (list)
        _items = []
        if self.fees:
            for _item in self.fees:
                if _item:
                    _items.append(_item.to_dict())
            _dict['fees'] = _items
        # override the default output from pydantic by calling `to_dict()` of digital_wallet_token
        if self.digital_wallet_token:
            _dict['digital_wallet_token'] = self.digital_wallet_token.to_dict()
        # override the default output from pydantic by calling `to_dict()` of user
        if self.user:
            _dict['user'] = self.user.to_dict()
        # override the default output from pydantic by calling `to_dict()` of business
        if self.business:
            _dict['business'] = self.business.to_dict()
        # override the default output from pydantic by calling `to_dict()` of acquirer
        if self.acquirer:
            _dict['acquirer'] = self.acquirer.to_dict()
        # override the default output from pydantic by calling `to_dict()` of fraud
        if self.fraud:
            _dict['fraud'] = self.fraud.to_dict()
        # override the default output from pydantic by calling `to_dict()` of pos
        if self.pos:
            _dict['pos'] = self.pos.to_dict()
        # override the default output from pydantic by calling `to_dict()` of address_verification
        if self.address_verification:
            _dict['address_verification'] = self.address_verification.to_dict()
        # override the default output from pydantic by calling `to_dict()` of card_security_code_verification
        if self.card_security_code_verification:
            _dict['card_security_code_verification'] = self.card_security_code_verification.to_dict()
        # override the default output from pydantic by calling `to_dict()` of transaction_metadata
        if self.transaction_metadata:
            _dict['transaction_metadata'] = self.transaction_metadata.to_dict()
        # override the default output from pydantic by calling `to_dict()` of original_credit
        if self.original_credit:
            _dict['original_credit'] = self.original_credit.to_dict()
        # override the default output from pydantic by calling `to_dict()` of account_funding
        if self.account_funding:
            _dict['account_funding'] = self.account_funding.to_dict()
        # override the default output from pydantic by calling `to_dict()` of card_holder_model
        if self.card_holder_model:
            _dict['card_holder_model'] = self.card_holder_model.to_dict()
        # override the default output from pydantic by calling `to_dict()` of cardholder_authentication_data
        if self.cardholder_authentication_data:
            _dict['cardholder_authentication_data'] = self.cardholder_authentication_data.to_dict()
        # override the default output from pydantic by calling `to_dict()` of program
        if self.program:
            _dict['program'] = self.program.to_dict()
        # override the default output from pydantic by calling `to_dict()` of atc_information
        if self.atc_information:
            _dict['atc_information'] = self.atc_information.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> TransactionModel:
        """Create an instance of TransactionModel from a dict"""
        if obj is None:
            return None

        if type(obj) is not dict:
            return TransactionModel.parse_obj(obj)

        _obj = TransactionModel.parse_obj({
            "identifier": obj.get("identifier"),
            "token": obj.get("token"),
            "user_token": obj.get("user_token"),
            "business_token": obj.get("business_token"),
            "acting_user_token": obj.get("acting_user_token"),
            "card_token": obj.get("card_token"),
            "card_product_token": obj.get("card_product_token"),
            "is_preauthorization": obj.get("is_preauthorization") if obj.get("is_preauthorization") is not None else False,
            "type": obj.get("type"),
            "state": obj.get("state"),
            "duration": obj.get("duration"),
            "created_time": obj.get("created_time"),
            "user_transaction_time": obj.get("user_transaction_time"),
            "settlement_date": obj.get("settlement_date"),
            "request_amount": obj.get("request_amount"),
            "amount": obj.get("amount"),
            "cash_back_amount": obj.get("cash_back_amount"),
            "currency_conversion": CurrencyConversion.from_dict(obj.get("currency_conversion")) if obj.get("currency_conversion") is not None else None,
            "issuer_interchange_amount": obj.get("issuer_interchange_amount"),
            "currency_code": obj.get("currency_code"),
            "approval_code": obj.get("approval_code"),
            "response": Response.from_dict(obj.get("response")) if obj.get("response") is not None else None,
            "preceding_related_transaction_token": obj.get("preceding_related_transaction_token"),
            "preceding_transaction": PrecedingTransaction.from_dict(obj.get("preceding_transaction")) if obj.get("preceding_transaction") is not None else None,
            "amount_to_be_released": obj.get("amount_to_be_released"),
            "incremental_authorization_transaction_tokens": obj.get("incremental_authorization_transaction_tokens"),
            "merchant": MerchantResponseModel.from_dict(obj.get("merchant")) if obj.get("merchant") is not None else None,
            "store": StoreResponseModel.from_dict(obj.get("store")) if obj.get("store") is not None else None,
            "card_acceptor": TransactionCardAcceptor.from_dict(obj.get("card_acceptor")) if obj.get("card_acceptor") is not None else None,
            "gpa": CardholderBalance.from_dict(obj.get("gpa")) if obj.get("gpa") is not None else None,
            "card": CardResponse.from_dict(obj.get("card")) if obj.get("card") is not None else None,
            "gpa_order_unload": GpaReturns.from_dict(obj.get("gpa_order_unload")) if obj.get("gpa_order_unload") is not None else None,
            "gpa_order": GpaResponse.from_dict(obj.get("gpa_order")) if obj.get("gpa_order") is not None else None,
            "program_transfer": ProgramTransferResponse.from_dict(obj.get("program_transfer")) if obj.get("program_transfer") is not None else None,
            "fee_transfer": FeeTransferResponse.from_dict(obj.get("fee_transfer")) if obj.get("fee_transfer") is not None else None,
            "peer_transfer": PeerTransferResponse.from_dict(obj.get("peer_transfer")) if obj.get("peer_transfer") is not None else None,
            "msa_orders": [MsaOrderResponse.from_dict(_item) for _item in obj.get("msa_orders")] if obj.get("msa_orders") is not None else None,
            "msa_order_unload": MsaReturns.from_dict(obj.get("msa_order_unload")) if obj.get("msa_order_unload") is not None else None,
            "offer_orders": [OfferOrderResponse.from_dict(_item) for _item in obj.get("offer_orders")] if obj.get("offer_orders") is not None else None,
            "auto_reload": AutoReloadModel.from_dict(obj.get("auto_reload")) if obj.get("auto_reload") is not None else None,
            "direct_deposit": DepositDepositResponse.from_dict(obj.get("direct_deposit")) if obj.get("direct_deposit") is not None else None,
            "pull_from_card": PullFromCardTransferResponse.from_dict(obj.get("pull_from_card")) if obj.get("pull_from_card") is not None else None,
            "polarity": obj.get("polarity"),
            "real_time_fee_group": RealTimeFeeGroup.from_dict(obj.get("real_time_fee_group")) if obj.get("real_time_fee_group") is not None else None,
            "fee": Fee.from_dict(obj.get("fee")) if obj.get("fee") is not None else None,
            "chargeback": ChargebackResponse.from_dict(obj.get("chargeback")) if obj.get("chargeback") is not None else None,
            "dispute": DisputeModel.from_dict(obj.get("dispute")) if obj.get("dispute") is not None else None,
            "network": obj.get("network"),
            "subnetwork": obj.get("subnetwork"),
            "network_metadata": NetworkMetadata.from_dict(obj.get("network_metadata")) if obj.get("network_metadata") is not None else None,
            "acquirer_fee_amount": obj.get("acquirer_fee_amount"),
            "fees": [NetworkFeeModel.from_dict(_item) for _item in obj.get("fees")] if obj.get("fees") is not None else None,
            "digital_wallet_token": DigitalWalletToken.from_dict(obj.get("digital_wallet_token")) if obj.get("digital_wallet_token") is not None else None,
            "user": CardholderMetadata.from_dict(obj.get("user")) if obj.get("user") is not None else None,
            "business": BusinessMetadata.from_dict(obj.get("business")) if obj.get("business") is not None else None,
            "acquirer": Acquirer.from_dict(obj.get("acquirer")) if obj.get("acquirer") is not None else None,
            "fraud": FraudView.from_dict(obj.get("fraud")) if obj.get("fraud") is not None else None,
            "pos": Pos.from_dict(obj.get("pos")) if obj.get("pos") is not None else None,
            "address_verification": AddressVerificationModel.from_dict(obj.get("address_verification")) if obj.get("address_verification") is not None else None,
            "card_security_code_verification": CardSecurityCodeVerification.from_dict(obj.get("card_security_code_verification")) if obj.get("card_security_code_verification") is not None else None,
            "transaction_metadata": TransactionMetadata.from_dict(obj.get("transaction_metadata")) if obj.get("transaction_metadata") is not None else None,
            "original_credit": OriginalCredit.from_dict(obj.get("original_credit")) if obj.get("original_credit") is not None else None,
            "account_funding": AccountFunding.from_dict(obj.get("account_funding")) if obj.get("account_funding") is not None else None,
            "card_holder_model": UserCardHolderResponse.from_dict(obj.get("card_holder_model")) if obj.get("card_holder_model") is not None else None,
            "standin_approved_by": obj.get("standin_approved_by"),
            "standin_by": obj.get("standin_by"),
            "standin_reason": obj.get("standin_reason"),
            "network_reference_id": obj.get("network_reference_id"),
            "acquirer_reference_id": obj.get("acquirer_reference_id"),
            "cardholder_authentication_data": CardholderAuthenticationData.from_dict(obj.get("cardholder_authentication_data")) if obj.get("cardholder_authentication_data") is not None else None,
            "transaction_attributes": obj.get("transaction_attributes"),
            "clearing_record_sequence_number": obj.get("clearing_record_sequence_number"),
            "issuer_received_time": obj.get("issuer_received_time"),
            "issuer_payment_node": obj.get("issuer_payment_node"),
            "program": Program.from_dict(obj.get("program")) if obj.get("program") is not None else None,
            "batch_number": obj.get("batch_number"),
            "from_account": obj.get("from_account"),
            "multi_clearing_sequence_number": obj.get("multi_clearing_sequence_number"),
            "multi_clearing_sequence_count": obj.get("multi_clearing_sequence_count"),
            "isa_indicator": obj.get("isaIndicator"),
            "enhanced_data_token": obj.get("enhanced_data_token"),
            "advice_reason_code": obj.get("advice_reason_code"),
            "advice_reason_details": obj.get("advice_reason_details"),
            "bank_transfer_token": obj.get("bank_transfer_token"),
            "interchange_rate_descriptor": obj.get("interchange_rate_descriptor"),
            "real_time_fee_type": obj.get("real_time_fee_type"),
            "atc_information": ATCInformationModel.from_dict(obj.get("atc_information")) if obj.get("atc_information") is not None else None
        })
        return _obj

