# 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, StrictStr, conlist, validator
from cryptoapis.models.get_transaction_request_details_ri_recipients_inner import GetTransactionRequestDetailsRIRecipientsInner

class GetTransactionRequestDetailsRI(BaseModel):
    """
    GetTransactionRequestDetailsRI
    """
    additional_details: StrictStr = Field(..., alias="additionalDetails", description="Defines an optional note for additional details.")
    blockchain: StrictStr = Field(..., description="Represents the specific blockchain protocol name, e.g. Ethereum, Bitcoin, etc.")
    fee_priority: StrictStr = Field(..., alias="feePriority", description="Defines the priority for the fee, if it is \"slow\", \"standard\" or \"fast\".")
    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\", \"goerli\" are test networks.")
    recipients: conlist(GetTransactionRequestDetailsRIRecipientsInner) = 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.")
    total_transaction_amount: StrictStr = Field(..., alias="totalTransactionAmount", description="Defines the total transaction amount.")
    transaction_id: Optional[StrictStr] = Field(None, 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.")
    transaction_request_status: StrictStr = Field(..., alias="transactionRequestStatus", description="Defines the status of the transaction request, e.g. pending.")
    transaction_type: StrictStr = Field(..., alias="transactionType", description="Defines the transaction type, if it is for coins or tokens.")
    unit: StrictStr = Field(..., description="Defines the unit of the amount.")
    wallet_id: StrictStr = Field(..., alias="walletId", description="Defines the unique ID of the Wallet.")
    __properties = ["additionalDetails", "blockchain", "feePriority", "network", "recipients", "totalTransactionAmount", "transactionId", "transactionRequestStatus", "transactionType", "unit", "walletId"]

    @validator('blockchain')
    def blockchain_validate_enum(cls, value):
        """Validates the enum"""
        if value not in ('bitcoin', 'bitcoin-cash', 'litecoin', 'dogecoin', 'dash', 'ethereum', 'ethereum-classic', 'xrp', 'zcash'):
            raise ValueError("must be one of enum values ('bitcoin', 'bitcoin-cash', 'litecoin', 'dogecoin', 'dash', 'ethereum', 'ethereum-classic', 'xrp', 'zcash')")
        return value

    @validator('fee_priority')
    def fee_priority_validate_enum(cls, value):
        """Validates the enum"""
        if value not in ('slow', 'standard', 'fast'):
            raise ValueError("must be one of enum values ('slow', 'standard', 'fast')")
        return value

    @validator('network')
    def network_validate_enum(cls, value):
        """Validates the enum"""
        if value not in ('mainnet', 'testnet', 'ropsten', 'mordor'):
            raise ValueError("must be one of enum values ('mainnet', 'testnet', 'ropsten', 'mordor')")
        return value

    @validator('transaction_request_status')
    def transaction_request_status_validate_enum(cls, value):
        """Validates the enum"""
        if value not in ('created', 'await-approval', 'pending', 'prepared', 'signed', 'broadcasted', 'success', 'failed', 'rejected', 'mined'):
            raise ValueError("must be one of enum values ('created', 'await-approval', 'pending', 'prepared', 'signed', 'broadcasted', 'success', 'failed', 'rejected', 'mined')")
        return value

    @validator('transaction_type')
    def transaction_type_validate_enum(cls, value):
        """Validates the enum"""
        if value not in ('coin', 'token'):
            raise ValueError("must be one of enum values ('coin', 'token')")
        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) -> GetTransactionRequestDetailsRI:
        """Create an instance of GetTransactionRequestDetailsRI 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
        return _dict

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

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

        _obj = GetTransactionRequestDetailsRI.parse_obj({
            "additional_details": obj.get("additionalDetails"),
            "blockchain": obj.get("blockchain"),
            "fee_priority": obj.get("feePriority"),
            "network": obj.get("network"),
            "recipients": [GetTransactionRequestDetailsRIRecipientsInner.from_dict(_item) for _item in obj.get("recipients")] if obj.get("recipients") is not None else None,
            "total_transaction_amount": obj.get("totalTransactionAmount"),
            "transaction_id": obj.get("transactionId"),
            "transaction_request_status": obj.get("transactionRequestStatus"),
            "transaction_type": obj.get("transactionType"),
            "unit": obj.get("unit"),
            "wallet_id": obj.get("walletId")
        })
        return _obj

