# 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
from pydantic import BaseModel, Field, StrictInt, StrictStr, conlist
from cryptoapis.models.get_zilliqa_transaction_details_by_transaction_idri_fee import GetZilliqaTransactionDetailsByTransactionIDRIFee
from cryptoapis.models.list_zilliqa_transactions_by_address_ri_recipients_inner import ListZilliqaTransactionsByAddressRIRecipientsInner
from cryptoapis.models.list_zilliqa_transactions_by_address_ri_senders_inner import ListZilliqaTransactionsByAddressRISendersInner

class ListZilliqaTransactionsByAddressRI(BaseModel):
    """
    ListZilliqaTransactionsByAddressRI
    """
    fee: GetZilliqaTransactionDetailsByTransactionIDRIFee = Field(...)
    gas_limit: StrictInt = Field(..., alias="gasLimit", description="Represents the maximum amount of gas allowed in the block in order to determine how many transactions it can fit.")
    gas_price: StrictInt = Field(..., alias="gasPrice", description="Defines the price of the gas.")
    gas_used: StrictInt = Field(..., alias="gasUsed", description="Defines how much of the gas for the block has been used.")
    mined_in_block_hash: StrictStr = Field(..., 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: StrictInt = Field(..., alias="minedInBlockHeight", description="Represents the number of blocks in the blockchain preceding this specific block. Block numbers have no gaps. A blockchain usually starts with block 0 called the \"Genesis block\".")
    nonce: StrictInt = Field(..., description="Represents a random value that can be adjusted to satisfy the Proof of Work.")
    recipients: conlist(ListZilliqaTransactionsByAddressRIRecipientsInner) = Field(..., description="Defines an object array of the transaction recipients.")
    senders: conlist(ListZilliqaTransactionsByAddressRISendersInner) = Field(..., description="Represents an object of addresses that provide the funds.")
    timestamp: StrictInt = Field(..., description="Defines the exact date/time when this block was mined in Unix Timestamp.")
    transaction_hash: StrictStr = Field(..., alias="transactionHash", description="Represents the hash of the transaction, which is its unique identifier.")
    transaction_index: StrictInt = Field(..., alias="transactionIndex", description="Defines the numeric representation of the transaction index.")
    transaction_status: StrictStr = Field(..., alias="transactionStatus", description="Defines the status of the transaction, whether it is e.g. pending or complete.")
    __properties = ["fee", "gasLimit", "gasPrice", "gasUsed", "minedInBlockHash", "minedInBlockHeight", "nonce", "recipients", "senders", "timestamp", "transactionHash", "transactionIndex", "transactionStatus"]

    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) -> ListZilliqaTransactionsByAddressRI:
        """Create an instance of ListZilliqaTransactionsByAddressRI 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 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
        return _dict

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

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

        _obj = ListZilliqaTransactionsByAddressRI.parse_obj({
            "fee": GetZilliqaTransactionDetailsByTransactionIDRIFee.from_dict(obj.get("fee")) if obj.get("fee") is not None else None,
            "gas_limit": obj.get("gasLimit"),
            "gas_price": obj.get("gasPrice"),
            "gas_used": obj.get("gasUsed"),
            "mined_in_block_hash": obj.get("minedInBlockHash"),
            "mined_in_block_height": obj.get("minedInBlockHeight"),
            "nonce": obj.get("nonce"),
            "recipients": [ListZilliqaTransactionsByAddressRIRecipientsInner.from_dict(_item) for _item in obj.get("recipients")] if obj.get("recipients") is not None else None,
            "senders": [ListZilliqaTransactionsByAddressRISendersInner.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"),
            "transaction_index": obj.get("transactionIndex"),
            "transaction_status": obj.get("transactionStatus")
        })
        return _obj

