# -*- 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_change_percentage_24_h import MarketCapChangePercentage24h


class Data2(object):

    """Implementation of the 'Data2' model.

    Attributes:
        market_cap (float): category market cap
        market_cap_btc (float): category market cap in btc
        total_volume (float): category total volume
        total_volume_btc (float): category total volume in btc
        market_cap_change_percentage_24_h (MarketCapChangePercentage24h):
            category market cap change percentage in 24 hours
        sparkline (str): category sparkline image url

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "market_cap": 'market_cap',
        "market_cap_btc": 'market_cap_btc',
        "total_volume": 'total_volume',
        "total_volume_btc": 'total_volume_btc',
        "market_cap_change_percentage_24_h": 'market_cap_change_percentage_24h',
        "sparkline": 'sparkline'
    }

    _optionals = [
        'market_cap',
        'market_cap_btc',
        'total_volume',
        'total_volume_btc',
        'market_cap_change_percentage_24_h',
        'sparkline',
    ]

    def __init__(self,
                 market_cap=APIHelper.SKIP,
                 market_cap_btc=APIHelper.SKIP,
                 total_volume=APIHelper.SKIP,
                 total_volume_btc=APIHelper.SKIP,
                 market_cap_change_percentage_24_h=APIHelper.SKIP,
                 sparkline=APIHelper.SKIP):
        """Constructor for the Data2 class"""

        # Initialize members of the class
        if market_cap is not APIHelper.SKIP:
            self.market_cap = market_cap 
        if market_cap_btc is not APIHelper.SKIP:
            self.market_cap_btc = market_cap_btc 
        if total_volume is not APIHelper.SKIP:
            self.total_volume = total_volume 
        if total_volume_btc is not APIHelper.SKIP:
            self.total_volume_btc = total_volume_btc 
        if market_cap_change_percentage_24_h is not APIHelper.SKIP:
            self.market_cap_change_percentage_24_h = market_cap_change_percentage_24_h 
        if sparkline is not APIHelper.SKIP:
            self.sparkline = sparkline 

    @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
        market_cap = dictionary.get("market_cap") if dictionary.get("market_cap") else APIHelper.SKIP
        market_cap_btc = dictionary.get("market_cap_btc") if dictionary.get("market_cap_btc") else APIHelper.SKIP
        total_volume = dictionary.get("total_volume") if dictionary.get("total_volume") else APIHelper.SKIP
        total_volume_btc = dictionary.get("total_volume_btc") if dictionary.get("total_volume_btc") else APIHelper.SKIP
        market_cap_change_percentage_24_h = MarketCapChangePercentage24h.from_dictionary(dictionary.get('market_cap_change_percentage_24h')) if 'market_cap_change_percentage_24h' in dictionary.keys() else APIHelper.SKIP
        sparkline = dictionary.get("sparkline") if dictionary.get("sparkline") else APIHelper.SKIP
        # Return an object of this model
        return cls(market_cap,
                   market_cap_btc,
                   total_volume,
                   total_volume_btc,
                   market_cap_change_percentage_24_h,
                   sparkline)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'market_cap={(self.market_cap if hasattr(self, "market_cap") else None)!r}, '
                f'market_cap_btc={(self.market_cap_btc if hasattr(self, "market_cap_btc") else None)!r}, '
                f'total_volume={(self.total_volume if hasattr(self, "total_volume") else None)!r}, '
                f'total_volume_btc={(self.total_volume_btc if hasattr(self, "total_volume_btc") else None)!r}, '
                f'market_cap_change_percentage_24_h={(self.market_cap_change_percentage_24_h if hasattr(self, "market_cap_change_percentage_24_h") else None)!r}, '
                f'sparkline={(self.sparkline if hasattr(self, "sparkline") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'market_cap={(self.market_cap if hasattr(self, "market_cap") else None)!s}, '
                f'market_cap_btc={(self.market_cap_btc if hasattr(self, "market_cap_btc") else None)!s}, '
                f'total_volume={(self.total_volume if hasattr(self, "total_volume") else None)!s}, '
                f'total_volume_btc={(self.total_volume_btc if hasattr(self, "total_volume_btc") else None)!s}, '
                f'market_cap_change_percentage_24_h={(self.market_cap_change_percentage_24_h if hasattr(self, "market_cap_change_percentage_24_h") else None)!s}, '
                f'sparkline={(self.sparkline if hasattr(self, "sparkline") else None)!s})')
