# 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 pydantic import BaseModel, Field, StrictInt, StrictStr, validator
from cryptoapis.models.address_tokens_transaction_unconfirmed_token import AddressTokensTransactionUnconfirmedToken

class AddressTokensTransactionUnconfirmedDataItem(BaseModel):
    """
    Defines an `item` as one result.
    """
    blockchain: StrictStr = Field(..., description="Represents the specific blockchain protocol name, e.g. Ethereum, Bitcoin, etc.")
    network: StrictStr = Field(..., description="Represents the name of the blockchain network used; blockchain networks are usually identical as technology and software, but they differ in data, e.g. - \"mainnet\" is the live network with actual data while networks like \"testnet\", \"ropsten\", \"rinkeby\" are test networks.")
    address: StrictStr = Field(..., description="Defines the specific address to which the token transaction has been sent and is pending confirmation.")
    transaction_id: StrictStr = Field(..., alias="transactionId", description="Defines the unique ID of the specific transaction, i.e. its identification number.")
    token_type: StrictStr = Field(..., alias="tokenType", description="Defines the type of token sent with the transaction, e.g. ERC 20.")
    token: AddressTokensTransactionUnconfirmedToken = Field(...)
    direction: StrictStr = Field(..., description="Defines whether the transaction is \"incoming\" or \"outgoing\".")
    first_seen_in_mempool_timestamp: StrictInt = Field(..., alias="firstSeenInMempoolTimestamp", description="Defines the exact time the transaction has been first accepted into the mempool to await confirmation as timestamp.")
    __properties = ["blockchain", "network", "address", "transactionId", "tokenType", "token", "direction", "firstSeenInMempoolTimestamp"]

    @validator('token_type')
    def token_type_validate_enum(cls, value):
        """Validates the enum"""
        if value not in ('ERC-20', 'ERC-721', 'OMNI'):
            raise ValueError("must be one of enum values ('ERC-20', 'ERC-721', 'OMNI')")
        return value

    @validator('direction')
    def direction_validate_enum(cls, value):
        """Validates the enum"""
        if value not in ('incoming', 'outgoing'):
            raise ValueError("must be one of enum values ('incoming', 'outgoing')")
        return value

    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) -> AddressTokensTransactionUnconfirmedDataItem:
        """Create an instance of AddressTokensTransactionUnconfirmedDataItem 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 token
        if self.token:
            _dict['token'] = self.token.to_dict()
        return _dict

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

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

        _obj = AddressTokensTransactionUnconfirmedDataItem.parse_obj({
            "blockchain": obj.get("blockchain"),
            "network": obj.get("network"),
            "address": obj.get("address"),
            "transaction_id": obj.get("transactionId"),
            "token_type": obj.get("tokenType"),
            "token": AddressTokensTransactionUnconfirmedToken.from_dict(obj.get("token")) if obj.get("token") is not None else None,
            "direction": obj.get("direction"),
            "first_seen_in_mempool_timestamp": obj.get("firstSeenInMempoolTimestamp")
        })
        return _obj

