# -*- 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.market_cap_percentage import MarketCapPercentage
from coingeckopublicapiv3.models.total_market_cap import TotalMarketCap
from coingeckopublicapiv3.models.total_volume_2 import TotalVolume2


class Data3(object):

    """Implementation of the 'Data3' model.

    Attributes:
        active_cryptocurrencies (float): number of active cryptocurrencies
        upcoming_icos (float): number of upcoming icos
        ongoing_icos (float): number of ongoing icos
        ended_icos (float): number of ended icos
        markets (float): number of exchanges
        total_market_cap (TotalMarketCap): cryptocurrencies total market cap
        total_volume (TotalVolume2): cryptocurrencies total volume
        market_cap_percentage (MarketCapPercentage): cryptocurrencies market
            cap percentage
        market_cap_change_percentage_24_h_usd (float): cryptocurrencies market
            cap change percentage in 24 hours in usd
        updated_at (float): The model property of type float.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "active_cryptocurrencies": 'active_cryptocurrencies',
        "upcoming_icos": 'upcoming_icos',
        "ongoing_icos": 'ongoing_icos',
        "ended_icos": 'ended_icos',
        "markets": 'markets',
        "total_market_cap": 'total_market_cap',
        "total_volume": 'total_volume',
        "market_cap_percentage": 'market_cap_percentage',
        "market_cap_change_percentage_24_h_usd": 'market_cap_change_percentage_24h_usd',
        "updated_at": 'updated_at'
    }

    _optionals = [
        'active_cryptocurrencies',
        'upcoming_icos',
        'ongoing_icos',
        'ended_icos',
        'markets',
        'total_market_cap',
        'total_volume',
        'market_cap_percentage',
        'market_cap_change_percentage_24_h_usd',
        'updated_at',
    ]

    def __init__(self,
                 active_cryptocurrencies=APIHelper.SKIP,
                 upcoming_icos=APIHelper.SKIP,
                 ongoing_icos=APIHelper.SKIP,
                 ended_icos=APIHelper.SKIP,
                 markets=APIHelper.SKIP,
                 total_market_cap=APIHelper.SKIP,
                 total_volume=APIHelper.SKIP,
                 market_cap_percentage=APIHelper.SKIP,
                 market_cap_change_percentage_24_h_usd=APIHelper.SKIP,
                 updated_at=APIHelper.SKIP):
        """Constructor for the Data3 class"""

        # Initialize members of the class
        if active_cryptocurrencies is not APIHelper.SKIP:
            self.active_cryptocurrencies = active_cryptocurrencies 
        if upcoming_icos is not APIHelper.SKIP:
            self.upcoming_icos = upcoming_icos 
        if ongoing_icos is not APIHelper.SKIP:
            self.ongoing_icos = ongoing_icos 
        if ended_icos is not APIHelper.SKIP:
            self.ended_icos = ended_icos 
        if markets is not APIHelper.SKIP:
            self.markets = markets 
        if total_market_cap is not APIHelper.SKIP:
            self.total_market_cap = total_market_cap 
        if total_volume is not APIHelper.SKIP:
            self.total_volume = total_volume 
        if market_cap_percentage is not APIHelper.SKIP:
            self.market_cap_percentage = market_cap_percentage 
        if market_cap_change_percentage_24_h_usd is not APIHelper.SKIP:
            self.market_cap_change_percentage_24_h_usd = market_cap_change_percentage_24_h_usd 
        if updated_at is not APIHelper.SKIP:
            self.updated_at = updated_at 

    @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
        active_cryptocurrencies = dictionary.get("active_cryptocurrencies") if dictionary.get("active_cryptocurrencies") else APIHelper.SKIP
        upcoming_icos = dictionary.get("upcoming_icos") if dictionary.get("upcoming_icos") else APIHelper.SKIP
        ongoing_icos = dictionary.get("ongoing_icos") if dictionary.get("ongoing_icos") else APIHelper.SKIP
        ended_icos = dictionary.get("ended_icos") if dictionary.get("ended_icos") else APIHelper.SKIP
        markets = dictionary.get("markets") if dictionary.get("markets") else APIHelper.SKIP
        total_market_cap = TotalMarketCap.from_dictionary(dictionary.get('total_market_cap')) if 'total_market_cap' in dictionary.keys() else APIHelper.SKIP
        total_volume = TotalVolume2.from_dictionary(dictionary.get('total_volume')) if 'total_volume' in dictionary.keys() else APIHelper.SKIP
        market_cap_percentage = MarketCapPercentage.from_dictionary(dictionary.get('market_cap_percentage')) if 'market_cap_percentage' in dictionary.keys() else APIHelper.SKIP
        market_cap_change_percentage_24_h_usd = dictionary.get("market_cap_change_percentage_24h_usd") if dictionary.get("market_cap_change_percentage_24h_usd") else APIHelper.SKIP
        updated_at = dictionary.get("updated_at") if dictionary.get("updated_at") else APIHelper.SKIP
        # Return an object of this model
        return cls(active_cryptocurrencies,
                   upcoming_icos,
                   ongoing_icos,
                   ended_icos,
                   markets,
                   total_market_cap,
                   total_volume,
                   market_cap_percentage,
                   market_cap_change_percentage_24_h_usd,
                   updated_at)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'active_cryptocurrencies={(self.active_cryptocurrencies if hasattr(self, "active_cryptocurrencies") else None)!r}, '
                f'upcoming_icos={(self.upcoming_icos if hasattr(self, "upcoming_icos") else None)!r}, '
                f'ongoing_icos={(self.ongoing_icos if hasattr(self, "ongoing_icos") else None)!r}, '
                f'ended_icos={(self.ended_icos if hasattr(self, "ended_icos") else None)!r}, '
                f'markets={(self.markets if hasattr(self, "markets") else None)!r}, '
                f'total_market_cap={(self.total_market_cap if hasattr(self, "total_market_cap") else None)!r}, '
                f'total_volume={(self.total_volume if hasattr(self, "total_volume") else None)!r}, '
                f'market_cap_percentage={(self.market_cap_percentage if hasattr(self, "market_cap_percentage") else None)!r}, '
                f'market_cap_change_percentage_24_h_usd={(self.market_cap_change_percentage_24_h_usd if hasattr(self, "market_cap_change_percentage_24_h_usd") else None)!r}, '
                f'updated_at={(self.updated_at if hasattr(self, "updated_at") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'active_cryptocurrencies={(self.active_cryptocurrencies if hasattr(self, "active_cryptocurrencies") else None)!s}, '
                f'upcoming_icos={(self.upcoming_icos if hasattr(self, "upcoming_icos") else None)!s}, '
                f'ongoing_icos={(self.ongoing_icos if hasattr(self, "ongoing_icos") else None)!s}, '
                f'ended_icos={(self.ended_icos if hasattr(self, "ended_icos") else None)!s}, '
                f'markets={(self.markets if hasattr(self, "markets") else None)!s}, '
                f'total_market_cap={(self.total_market_cap if hasattr(self, "total_market_cap") else None)!s}, '
                f'total_volume={(self.total_volume if hasattr(self, "total_volume") else None)!s}, '
                f'market_cap_percentage={(self.market_cap_percentage if hasattr(self, "market_cap_percentage") else None)!s}, '
                f'market_cap_change_percentage_24_h_usd={(self.market_cap_change_percentage_24_h_usd if hasattr(self, "market_cap_change_percentage_24_h_usd") else None)!s}, '
                f'updated_at={(self.updated_at if hasattr(self, "updated_at") else None)!s})')
