# coding: utf-8

"""
    CryptoAPIs

    Crypto APIs is a complex and innovative infrastructure layer that radically simplifies the development of any Blockchain and Crypto related applications. Organized around REST, Crypto APIs can assist both novice Bitcoin/Ethereum enthusiasts and crypto experts with the development of their blockchain applications. Crypto APIs provides unified endpoints and data, raw data, automatic tokens and coins forwardings, callback functionalities, and much more.  # noqa: E501

    The version of the OpenAPI document: 2021-03-20
    Contact: developers@cryptoapis.io
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


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


from typing import List, Optional
from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr, conlist
from cryptoapis.models.get_wallet_transaction_details_by_transaction_idri_fee import GetWalletTransactionDetailsByTransactionIDRIFee
from cryptoapis.models.get_wallet_transaction_details_by_transaction_idri_recipients_inner import GetWalletTransactionDetailsByTransactionIDRIRecipientsInner
from cryptoapis.models.get_wallet_transaction_details_by_transaction_idri_senders_inner import GetWalletTransactionDetailsByTransactionIDRISendersInner
from cryptoapis.models.get_wallet_transaction_details_by_transaction_idribs import GetWalletTransactionDetailsByTransactionIDRIBS

class GetWalletTransactionDetailsByTransactionIDRI(BaseModel):
    """
    GetWalletTransactionDetailsByTransactionIDRI
    """
    is_confirmed: StrictBool = Field(..., alias="isConfirmed", description="Represents the state of the transaction whether it is confirmed or not confirmed.")
    transaction_id: StrictStr = Field(..., alias="transactionId", description="Represents the unique identifier of a transaction, i.e. it could be `transactionId` in UTXO-based protocols like Bitcoin, and transaction `hash` in Ethereum blockchain.")
    index: StrictInt = Field(..., description="Represents the index position of the transaction in the specific block.")
    mined_in_block_hash: Optional[StrictStr] = Field(None, alias="minedInBlockHash", description="Represents the hash of the block where this transaction was mined/confirmed for first time. The hash is defined as a cryptographic digital fingerprint made by hashing the block header twice through the SHA256 algorithm.")
    mined_in_block_height: Optional[StrictInt] = Field(None, alias="minedInBlockHeight", description="Represents the hight of the block where this transaction was mined/confirmed for first time. The height is defined as the number of blocks in the blockchain preceding this specific block.")
    recipients: conlist(GetWalletTransactionDetailsByTransactionIDRIRecipientsInner) = Field(..., description="Object Array representation of transaction receivers")
    senders: conlist(GetWalletTransactionDetailsByTransactionIDRISendersInner) = Field(..., description="String representation of the transaction from address")
    timestamp: StrictInt = Field(..., description="Defines the exact date/time in Unix Timestamp when this transaction was mined, confirmed or first seen in Mempool, if it is unconfirmed.")
    transaction_hash: StrictStr = Field(..., alias="transactionHash", description="Represents the same as `transactionId` for account-based protocols like Ethereum, while it could be different in UTXO-based protocols like Bitcoin. E.g., in UTXO-based protocols `hash` is different from `transactionId` for SegWit transactions.")
    fee: GetWalletTransactionDetailsByTransactionIDRIFee = Field(...)
    blockchain_specific: GetWalletTransactionDetailsByTransactionIDRIBS = Field(..., alias="blockchainSpecific")
    __properties = ["isConfirmed", "transactionId", "index", "minedInBlockHash", "minedInBlockHeight", "recipients", "senders", "timestamp", "transactionHash", "fee", "blockchainSpecific"]

    class Config:
        """Pydantic configuration"""
        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) -> GetWalletTransactionDetailsByTransactionIDRI:
        """Create an instance of GetWalletTransactionDetailsByTransactionIDRI 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={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of each item in recipients (list)
        _items = []
        if self.recipients:
            for _item in self.recipients:
                if _item:
                    _items.append(_item.to_dict())
            _dict['recipients'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in senders (list)
        _items = []
        if self.senders:
            for _item in self.senders:
                if _item:
                    _items.append(_item.to_dict())
            _dict['senders'] = _items
        # 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 blockchain_specific
        if self.blockchain_specific:
            _dict['blockchainSpecific'] = self.blockchain_specific.to_dict()
        return _dict

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

        if not isinstance(obj, dict):
            return GetWalletTransactionDetailsByTransactionIDRI.parse_obj(obj)

        _obj = GetWalletTransactionDetailsByTransactionIDRI.parse_obj({
            "is_confirmed": obj.get("isConfirmed"),
            "transaction_id": obj.get("transactionId"),
            "index": obj.get("index"),
            "mined_in_block_hash": obj.get("minedInBlockHash"),
            "mined_in_block_height": obj.get("minedInBlockHeight"),
            "recipients": [GetWalletTransactionDetailsByTransactionIDRIRecipientsInner.from_dict(_item) for _item in obj.get("recipients")] if obj.get("recipients") is not None else None,
            "senders": [GetWalletTransactionDetailsByTransactionIDRISendersInner.from_dict(_item) for _item in obj.get("senders")] if obj.get("senders") is not None else None,
            "timestamp": obj.get("timestamp"),
            "transaction_hash": obj.get("transactionHash"),
            "fee": GetWalletTransactionDetailsByTransactionIDRIFee.from_dict(obj.get("fee")) if obj.get("fee") is not None else None,
            "blockchain_specific": GetWalletTransactionDetailsByTransactionIDRIBS.from_dict(obj.get("blockchainSpecific")) if obj.get("blockchainSpecific") is not None else None
        })
        return _obj

