# -*- coding: utf-8 -*-

"""
coingeckopublicapiv3

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from coingeckopublicapiv3.api_helper import APIHelper
from coingeckopublicapiv3.models.company import Company


class CompaniesTreasury(object):

    """Implementation of the 'CompaniesTreasury' model.

    Attributes:
        total_holdings (float): total btc/eth holdings of companies
        total_value_usd (float): total btc/eth holdings value in usd
        market_cap_dominance (float): market cap dominance
        companies (List[Company]): The model property of type List[Company].

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "total_holdings": 'total_holdings',
        "total_value_usd": 'total_value_usd',
        "market_cap_dominance": 'market_cap_dominance',
        "companies": 'companies'
    }

    _optionals = [
        'total_holdings',
        'total_value_usd',
        'market_cap_dominance',
        'companies',
    ]

    def __init__(self,
                 total_holdings=APIHelper.SKIP,
                 total_value_usd=APIHelper.SKIP,
                 market_cap_dominance=APIHelper.SKIP,
                 companies=APIHelper.SKIP):
        """Constructor for the CompaniesTreasury class"""

        # Initialize members of the class
        if total_holdings is not APIHelper.SKIP:
            self.total_holdings = total_holdings 
        if total_value_usd is not APIHelper.SKIP:
            self.total_value_usd = total_value_usd 
        if market_cap_dominance is not APIHelper.SKIP:
            self.market_cap_dominance = market_cap_dominance 
        if companies is not APIHelper.SKIP:
            self.companies = companies 

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Creates an instance of this model from a dictionary

        Args:
            dictionary (dictionary): A dictionary representation of the object
            as obtained from the deserialization of the server's response. The
            keys MUST match property names in the API description.

        Returns:
            object: An instance of this structure class.

        """

        if not isinstance(dictionary, dict) or dictionary is None:
            return None

        # Extract variables from the dictionary
        total_holdings = dictionary.get("total_holdings") if dictionary.get("total_holdings") else APIHelper.SKIP
        total_value_usd = dictionary.get("total_value_usd") if dictionary.get("total_value_usd") else APIHelper.SKIP
        market_cap_dominance = dictionary.get("market_cap_dominance") if dictionary.get("market_cap_dominance") else APIHelper.SKIP
        companies = None
        if dictionary.get('companies') is not None:
            companies = [Company.from_dictionary(x) for x in dictionary.get('companies')]
        else:
            companies = APIHelper.SKIP
        # Return an object of this model
        return cls(total_holdings,
                   total_value_usd,
                   market_cap_dominance,
                   companies)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'total_holdings={(self.total_holdings if hasattr(self, "total_holdings") else None)!r}, '
                f'total_value_usd={(self.total_value_usd if hasattr(self, "total_value_usd") else None)!r}, '
                f'market_cap_dominance={(self.market_cap_dominance if hasattr(self, "market_cap_dominance") else None)!r}, '
                f'companies={(self.companies if hasattr(self, "companies") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'total_holdings={(self.total_holdings if hasattr(self, "total_holdings") else None)!s}, '
                f'total_value_usd={(self.total_value_usd if hasattr(self, "total_value_usd") else None)!s}, '
                f'market_cap_dominance={(self.market_cap_dominance if hasattr(self, "market_cap_dominance") else None)!s}, '
                f'companies={(self.companies if hasattr(self, "companies") else None)!s})')
