# 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
from inspect import getfullargspec
import json
import pprint
import re  # noqa: F401

from typing import Any, List, Optional
from pydantic import BaseModel, Field, StrictStr, ValidationError, validator
from cryptoapis.models.get_block_details_by_block_height_from_callback_ribsb import GetBlockDetailsByBlockHeightFromCallbackRIBSB
from cryptoapis.models.get_block_details_by_block_height_from_callback_ribsbc import GetBlockDetailsByBlockHeightFromCallbackRIBSBC
from cryptoapis.models.get_block_details_by_block_height_from_callback_ribsbsc import GetBlockDetailsByBlockHeightFromCallbackRIBSBSC
from cryptoapis.models.get_block_details_by_block_height_from_callback_ribsd import GetBlockDetailsByBlockHeightFromCallbackRIBSD
from cryptoapis.models.get_block_details_by_block_height_from_callback_ribsd2 import GetBlockDetailsByBlockHeightFromCallbackRIBSD2
from cryptoapis.models.get_block_details_by_block_height_from_callback_ribse import GetBlockDetailsByBlockHeightFromCallbackRIBSE
from cryptoapis.models.get_block_details_by_block_height_from_callback_ribsec import GetBlockDetailsByBlockHeightFromCallbackRIBSEC
from cryptoapis.models.get_block_details_by_block_height_from_callback_ribsl import GetBlockDetailsByBlockHeightFromCallbackRIBSL
from cryptoapis.models.get_block_details_by_block_height_from_callback_ribsp import GetBlockDetailsByBlockHeightFromCallbackRIBSP
from cryptoapis.models.get_block_details_by_block_height_from_callback_ribst import GetBlockDetailsByBlockHeightFromCallbackRIBST
from cryptoapis.models.get_block_details_by_block_height_from_callback_ribsx import GetBlockDetailsByBlockHeightFromCallbackRIBSX
from cryptoapis.models.get_block_details_by_block_height_from_callback_ribsz import GetBlockDetailsByBlockHeightFromCallbackRIBSZ
from typing import Any, List
from pydantic import StrictStr, Field

GETBLOCKDETAILSBYBLOCKHEIGHTFROMCALLBACKRIBS_ONE_OF_SCHEMAS = ["GetBlockDetailsByBlockHeightFromCallbackRIBSB", "GetBlockDetailsByBlockHeightFromCallbackRIBSBC", "GetBlockDetailsByBlockHeightFromCallbackRIBSBSC", "GetBlockDetailsByBlockHeightFromCallbackRIBSD", "GetBlockDetailsByBlockHeightFromCallbackRIBSD2", "GetBlockDetailsByBlockHeightFromCallbackRIBSE", "GetBlockDetailsByBlockHeightFromCallbackRIBSEC", "GetBlockDetailsByBlockHeightFromCallbackRIBSL", "GetBlockDetailsByBlockHeightFromCallbackRIBSP", "GetBlockDetailsByBlockHeightFromCallbackRIBST", "GetBlockDetailsByBlockHeightFromCallbackRIBSX", "GetBlockDetailsByBlockHeightFromCallbackRIBSZ"]

class GetBlockDetailsByBlockHeightFromCallbackRIBS(BaseModel):
    """
    GetBlockDetailsByBlockHeightFromCallbackRIBS
    """
    # data type: GetBlockDetailsByBlockHeightFromCallbackRIBSB
    oneof_schema_1_validator: Optional[GetBlockDetailsByBlockHeightFromCallbackRIBSB] = None
    # data type: GetBlockDetailsByBlockHeightFromCallbackRIBSBC
    oneof_schema_2_validator: Optional[GetBlockDetailsByBlockHeightFromCallbackRIBSBC] = None
    # data type: GetBlockDetailsByBlockHeightFromCallbackRIBSL
    oneof_schema_3_validator: Optional[GetBlockDetailsByBlockHeightFromCallbackRIBSL] = None
    # data type: GetBlockDetailsByBlockHeightFromCallbackRIBSD
    oneof_schema_4_validator: Optional[GetBlockDetailsByBlockHeightFromCallbackRIBSD] = None
    # data type: GetBlockDetailsByBlockHeightFromCallbackRIBSD2
    oneof_schema_5_validator: Optional[GetBlockDetailsByBlockHeightFromCallbackRIBSD2] = None
    # data type: GetBlockDetailsByBlockHeightFromCallbackRIBSE
    oneof_schema_6_validator: Optional[GetBlockDetailsByBlockHeightFromCallbackRIBSE] = None
    # data type: GetBlockDetailsByBlockHeightFromCallbackRIBSBSC
    oneof_schema_7_validator: Optional[GetBlockDetailsByBlockHeightFromCallbackRIBSBSC] = None
    # data type: GetBlockDetailsByBlockHeightFromCallbackRIBSEC
    oneof_schema_8_validator: Optional[GetBlockDetailsByBlockHeightFromCallbackRIBSEC] = None
    # data type: GetBlockDetailsByBlockHeightFromCallbackRIBSX
    oneof_schema_9_validator: Optional[GetBlockDetailsByBlockHeightFromCallbackRIBSX] = None
    # data type: GetBlockDetailsByBlockHeightFromCallbackRIBSZ
    oneof_schema_10_validator: Optional[GetBlockDetailsByBlockHeightFromCallbackRIBSZ] = None
    # data type: GetBlockDetailsByBlockHeightFromCallbackRIBST
    oneof_schema_11_validator: Optional[GetBlockDetailsByBlockHeightFromCallbackRIBST] = None
    # data type: GetBlockDetailsByBlockHeightFromCallbackRIBSP
    oneof_schema_12_validator: Optional[GetBlockDetailsByBlockHeightFromCallbackRIBSP] = None
    actual_instance: Any
    one_of_schemas: List[str] = Field(GETBLOCKDETAILSBYBLOCKHEIGHTFROMCALLBACKRIBS_ONE_OF_SCHEMAS, const=True)

    class Config:
        validate_assignment = True

    def __init__(self, *args, **kwargs):
        if args:
            if len(args) > 1:
                raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
            if kwargs:
                raise ValueError("If a position argument is used, keyword arguments cannot be used.")
            super().__init__(actual_instance=args[0])
        else:
            super().__init__(**kwargs)

    @validator('actual_instance')
    def actual_instance_must_validate_oneof(cls, v):
        instance = GetBlockDetailsByBlockHeightFromCallbackRIBS.construct()
        error_messages = []
        match = 0
        # validate data type: GetBlockDetailsByBlockHeightFromCallbackRIBSB
        if not isinstance(v, GetBlockDetailsByBlockHeightFromCallbackRIBSB):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GetBlockDetailsByBlockHeightFromCallbackRIBSB`")
        else:
            match += 1
        # validate data type: GetBlockDetailsByBlockHeightFromCallbackRIBSBC
        if not isinstance(v, GetBlockDetailsByBlockHeightFromCallbackRIBSBC):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GetBlockDetailsByBlockHeightFromCallbackRIBSBC`")
        else:
            match += 1
        # validate data type: GetBlockDetailsByBlockHeightFromCallbackRIBSL
        if not isinstance(v, GetBlockDetailsByBlockHeightFromCallbackRIBSL):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GetBlockDetailsByBlockHeightFromCallbackRIBSL`")
        else:
            match += 1
        # validate data type: GetBlockDetailsByBlockHeightFromCallbackRIBSD
        if not isinstance(v, GetBlockDetailsByBlockHeightFromCallbackRIBSD):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GetBlockDetailsByBlockHeightFromCallbackRIBSD`")
        else:
            match += 1
        # validate data type: GetBlockDetailsByBlockHeightFromCallbackRIBSD2
        if not isinstance(v, GetBlockDetailsByBlockHeightFromCallbackRIBSD2):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GetBlockDetailsByBlockHeightFromCallbackRIBSD2`")
        else:
            match += 1
        # validate data type: GetBlockDetailsByBlockHeightFromCallbackRIBSE
        if not isinstance(v, GetBlockDetailsByBlockHeightFromCallbackRIBSE):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GetBlockDetailsByBlockHeightFromCallbackRIBSE`")
        else:
            match += 1
        # validate data type: GetBlockDetailsByBlockHeightFromCallbackRIBSBSC
        if not isinstance(v, GetBlockDetailsByBlockHeightFromCallbackRIBSBSC):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GetBlockDetailsByBlockHeightFromCallbackRIBSBSC`")
        else:
            match += 1
        # validate data type: GetBlockDetailsByBlockHeightFromCallbackRIBSEC
        if not isinstance(v, GetBlockDetailsByBlockHeightFromCallbackRIBSEC):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GetBlockDetailsByBlockHeightFromCallbackRIBSEC`")
        else:
            match += 1
        # validate data type: GetBlockDetailsByBlockHeightFromCallbackRIBSX
        if not isinstance(v, GetBlockDetailsByBlockHeightFromCallbackRIBSX):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GetBlockDetailsByBlockHeightFromCallbackRIBSX`")
        else:
            match += 1
        # validate data type: GetBlockDetailsByBlockHeightFromCallbackRIBSZ
        if not isinstance(v, GetBlockDetailsByBlockHeightFromCallbackRIBSZ):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GetBlockDetailsByBlockHeightFromCallbackRIBSZ`")
        else:
            match += 1
        # validate data type: GetBlockDetailsByBlockHeightFromCallbackRIBST
        if not isinstance(v, GetBlockDetailsByBlockHeightFromCallbackRIBST):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GetBlockDetailsByBlockHeightFromCallbackRIBST`")
        else:
            match += 1
        # validate data type: GetBlockDetailsByBlockHeightFromCallbackRIBSP
        if not isinstance(v, GetBlockDetailsByBlockHeightFromCallbackRIBSP):
            error_messages.append(f"Error! Input type `{type(v)}` is not `GetBlockDetailsByBlockHeightFromCallbackRIBSP`")
        else:
            match += 1
        if match > 1:
            # more than 1 match
            raise ValueError("Multiple matches found when setting `actual_instance` in GetBlockDetailsByBlockHeightFromCallbackRIBS with oneOf schemas: GetBlockDetailsByBlockHeightFromCallbackRIBSB, GetBlockDetailsByBlockHeightFromCallbackRIBSBC, GetBlockDetailsByBlockHeightFromCallbackRIBSBSC, GetBlockDetailsByBlockHeightFromCallbackRIBSD, GetBlockDetailsByBlockHeightFromCallbackRIBSD2, GetBlockDetailsByBlockHeightFromCallbackRIBSE, GetBlockDetailsByBlockHeightFromCallbackRIBSEC, GetBlockDetailsByBlockHeightFromCallbackRIBSL, GetBlockDetailsByBlockHeightFromCallbackRIBSP, GetBlockDetailsByBlockHeightFromCallbackRIBST, GetBlockDetailsByBlockHeightFromCallbackRIBSX, GetBlockDetailsByBlockHeightFromCallbackRIBSZ. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when setting `actual_instance` in GetBlockDetailsByBlockHeightFromCallbackRIBS with oneOf schemas: GetBlockDetailsByBlockHeightFromCallbackRIBSB, GetBlockDetailsByBlockHeightFromCallbackRIBSBC, GetBlockDetailsByBlockHeightFromCallbackRIBSBSC, GetBlockDetailsByBlockHeightFromCallbackRIBSD, GetBlockDetailsByBlockHeightFromCallbackRIBSD2, GetBlockDetailsByBlockHeightFromCallbackRIBSE, GetBlockDetailsByBlockHeightFromCallbackRIBSEC, GetBlockDetailsByBlockHeightFromCallbackRIBSL, GetBlockDetailsByBlockHeightFromCallbackRIBSP, GetBlockDetailsByBlockHeightFromCallbackRIBST, GetBlockDetailsByBlockHeightFromCallbackRIBSX, GetBlockDetailsByBlockHeightFromCallbackRIBSZ. Details: " + ", ".join(error_messages))
        else:
            return v

    @classmethod
    def from_dict(cls, obj: dict) -> GetBlockDetailsByBlockHeightFromCallbackRIBS:
        return cls.from_json(json.dumps(obj))

    @classmethod
    def from_json(cls, json_str: str) -> GetBlockDetailsByBlockHeightFromCallbackRIBS:
        """Returns the object represented by the json string"""
        instance = GetBlockDetailsByBlockHeightFromCallbackRIBS.construct()
        error_messages = []
        match = 0

        # deserialize data into GetBlockDetailsByBlockHeightFromCallbackRIBSB
        try:
            instance.actual_instance = GetBlockDetailsByBlockHeightFromCallbackRIBSB.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into GetBlockDetailsByBlockHeightFromCallbackRIBSBC
        try:
            instance.actual_instance = GetBlockDetailsByBlockHeightFromCallbackRIBSBC.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into GetBlockDetailsByBlockHeightFromCallbackRIBSL
        try:
            instance.actual_instance = GetBlockDetailsByBlockHeightFromCallbackRIBSL.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into GetBlockDetailsByBlockHeightFromCallbackRIBSD
        try:
            instance.actual_instance = GetBlockDetailsByBlockHeightFromCallbackRIBSD.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into GetBlockDetailsByBlockHeightFromCallbackRIBSD2
        try:
            instance.actual_instance = GetBlockDetailsByBlockHeightFromCallbackRIBSD2.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into GetBlockDetailsByBlockHeightFromCallbackRIBSE
        try:
            instance.actual_instance = GetBlockDetailsByBlockHeightFromCallbackRIBSE.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into GetBlockDetailsByBlockHeightFromCallbackRIBSBSC
        try:
            instance.actual_instance = GetBlockDetailsByBlockHeightFromCallbackRIBSBSC.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into GetBlockDetailsByBlockHeightFromCallbackRIBSEC
        try:
            instance.actual_instance = GetBlockDetailsByBlockHeightFromCallbackRIBSEC.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into GetBlockDetailsByBlockHeightFromCallbackRIBSX
        try:
            instance.actual_instance = GetBlockDetailsByBlockHeightFromCallbackRIBSX.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into GetBlockDetailsByBlockHeightFromCallbackRIBSZ
        try:
            instance.actual_instance = GetBlockDetailsByBlockHeightFromCallbackRIBSZ.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into GetBlockDetailsByBlockHeightFromCallbackRIBST
        try:
            instance.actual_instance = GetBlockDetailsByBlockHeightFromCallbackRIBST.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))
        # deserialize data into GetBlockDetailsByBlockHeightFromCallbackRIBSP
        try:
            instance.actual_instance = GetBlockDetailsByBlockHeightFromCallbackRIBSP.from_json(json_str)
            match += 1
        except (ValidationError, ValueError) as e:
            error_messages.append(str(e))

        if match > 1:
            # more than 1 match
            raise ValueError("Multiple matches found when deserializing the JSON string into GetBlockDetailsByBlockHeightFromCallbackRIBS with oneOf schemas: GetBlockDetailsByBlockHeightFromCallbackRIBSB, GetBlockDetailsByBlockHeightFromCallbackRIBSBC, GetBlockDetailsByBlockHeightFromCallbackRIBSBSC, GetBlockDetailsByBlockHeightFromCallbackRIBSD, GetBlockDetailsByBlockHeightFromCallbackRIBSD2, GetBlockDetailsByBlockHeightFromCallbackRIBSE, GetBlockDetailsByBlockHeightFromCallbackRIBSEC, GetBlockDetailsByBlockHeightFromCallbackRIBSL, GetBlockDetailsByBlockHeightFromCallbackRIBSP, GetBlockDetailsByBlockHeightFromCallbackRIBST, GetBlockDetailsByBlockHeightFromCallbackRIBSX, GetBlockDetailsByBlockHeightFromCallbackRIBSZ. Details: " + ", ".join(error_messages))
        elif match == 0:
            # no match
            raise ValueError("No match found when deserializing the JSON string into GetBlockDetailsByBlockHeightFromCallbackRIBS with oneOf schemas: GetBlockDetailsByBlockHeightFromCallbackRIBSB, GetBlockDetailsByBlockHeightFromCallbackRIBSBC, GetBlockDetailsByBlockHeightFromCallbackRIBSBSC, GetBlockDetailsByBlockHeightFromCallbackRIBSD, GetBlockDetailsByBlockHeightFromCallbackRIBSD2, GetBlockDetailsByBlockHeightFromCallbackRIBSE, GetBlockDetailsByBlockHeightFromCallbackRIBSEC, GetBlockDetailsByBlockHeightFromCallbackRIBSL, GetBlockDetailsByBlockHeightFromCallbackRIBSP, GetBlockDetailsByBlockHeightFromCallbackRIBST, GetBlockDetailsByBlockHeightFromCallbackRIBSX, GetBlockDetailsByBlockHeightFromCallbackRIBSZ. Details: " + ", ".join(error_messages))
        else:
            return instance

    def to_json(self) -> str:
        """Returns the JSON representation of the actual instance"""
        if self.actual_instance is None:
            return "null"

        to_json = getattr(self.actual_instance, "to_json", None)
        if callable(to_json):
            return self.actual_instance.to_json()
        else:
            return json.dumps(self.actual_instance)

    def to_dict(self) -> dict:
        """Returns the dict representation of the actual instance"""
        if self.actual_instance is None:
            return None

        to_dict = getattr(self.actual_instance, "to_dict", None)
        if callable(to_dict):
            return self.actual_instance.to_dict()
        else:
            # primitive type
            return self.actual_instance

    def to_str(self) -> str:
        """Returns the string representation of the actual instance"""
        return pprint.pformat(self.dict())

