# 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, StrictInt, StrictStr, conlist
from cryptoapis.models.list_wallet_transactions_ri_fee import ListWalletTransactionsRIFee
from cryptoapis.models.list_wallet_transactions_ri_fungible_tokens_inner import ListWalletTransactionsRIFungibleTokensInner
from cryptoapis.models.list_wallet_transactions_ri_internal_transactions_inner import ListWalletTransactionsRIInternalTransactionsInner
from cryptoapis.models.list_wallet_transactions_ri_non_fungible_tokens_inner import ListWalletTransactionsRINonFungibleTokensInner
from cryptoapis.models.list_wallet_transactions_ri_recipients_inner import ListWalletTransactionsRIRecipientsInner
from cryptoapis.models.list_wallet_transactions_ri_senders_inner import ListWalletTransactionsRISendersInner
from cryptoapis.models.list_wallet_transactions_ri_value import ListWalletTransactionsRIValue

class ListWalletTransactionsRI(BaseModel):
    """
    ListWalletTransactionsRI
    """
    direction: StrictStr = Field(..., description="Defines the direction of the transaction, e.g. incoming.")
    fee: ListWalletTransactionsRIFee = Field(...)
    fungible_tokens: Optional[conlist(ListWalletTransactionsRIFungibleTokensInner)] = Field(None, alias="fungibleTokens", description="Represents fungible tokens'es detailed information")
    internal_transactions: Optional[conlist(ListWalletTransactionsRIInternalTransactionsInner)] = Field(None, alias="internalTransactions")
    non_fungible_tokens: Optional[conlist(ListWalletTransactionsRINonFungibleTokensInner)] = Field(None, alias="nonFungibleTokens", description="Represents non-fungible tokens'es detailed information.")
    recipients: conlist(ListWalletTransactionsRIRecipientsInner) = Field(..., description="Represents a list of recipient addresses with the respective amounts. In account-based protocols like Ethereum there is only one address in this list.")
    senders: conlist(ListWalletTransactionsRISendersInner) = Field(..., description="Represents a list of sender addresses with the respective amounts. In account-based protocols like Ethereum there is only one address in this list.")
    status: StrictStr = Field(..., description="Defines the status of the transaction, if it is confirmed or unconfirmed.")
    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_id: StrictStr = Field(..., alias="transactionId", description="Represents the unique TD of the transaction.")
    value: ListWalletTransactionsRIValue = Field(...)
    __properties = ["direction", "fee", "fungibleTokens", "internalTransactions", "nonFungibleTokens", "recipients", "senders", "status", "timestamp", "transactionId", "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) -> ListWalletTransactionsRI:
        """Create an instance of ListWalletTransactionsRI 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 fee
        if self.fee:
            _dict['fee'] = self.fee.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in fungible_tokens (list)
        _items = []
        if self.fungible_tokens:
            for _item in self.fungible_tokens:
                if _item:
                    _items.append(_item.to_dict())
            _dict['fungibleTokens'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in internal_transactions (list)
        _items = []
        if self.internal_transactions:
            for _item in self.internal_transactions:
                if _item:
                    _items.append(_item.to_dict())
            _dict['internalTransactions'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in non_fungible_tokens (list)
        _items = []
        if self.non_fungible_tokens:
            for _item in self.non_fungible_tokens:
                if _item:
                    _items.append(_item.to_dict())
            _dict['nonFungibleTokens'] = _items
        # 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 value
        if self.value:
            _dict['value'] = self.value.to_dict()
        return _dict

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

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

        _obj = ListWalletTransactionsRI.parse_obj({
            "direction": obj.get("direction"),
            "fee": ListWalletTransactionsRIFee.from_dict(obj.get("fee")) if obj.get("fee") is not None else None,
            "fungible_tokens": [ListWalletTransactionsRIFungibleTokensInner.from_dict(_item) for _item in obj.get("fungibleTokens")] if obj.get("fungibleTokens") is not None else None,
            "internal_transactions": [ListWalletTransactionsRIInternalTransactionsInner.from_dict(_item) for _item in obj.get("internalTransactions")] if obj.get("internalTransactions") is not None else None,
            "non_fungible_tokens": [ListWalletTransactionsRINonFungibleTokensInner.from_dict(_item) for _item in obj.get("nonFungibleTokens")] if obj.get("nonFungibleTokens") is not None else None,
            "recipients": [ListWalletTransactionsRIRecipientsInner.from_dict(_item) for _item in obj.get("recipients")] if obj.get("recipients") is not None else None,
            "senders": [ListWalletTransactionsRISendersInner.from_dict(_item) for _item in obj.get("senders")] if obj.get("senders") is not None else None,
            "status": obj.get("status"),
            "timestamp": obj.get("timestamp"),
            "transaction_id": obj.get("transactionId"),
            "value": ListWalletTransactionsRIValue.from_dict(obj.get("value")) if obj.get("value") is not None else None
        })
        return _obj

