# -*- 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.price_change_percentage_24_h import PriceChangePercentage24h


class Data(object):

    """Implementation of the 'Data' model.

    Attributes:
        price (float): coin price in usd
        price_btc (str): coin price in btc
        price_change_percentage_24_h (PriceChangePercentage24h): coin price
            change percentage in 24 hours
        market_cap (str): coin market cap in usd
        market_cap_btc (str): coin market cap in btc
        total_volume (str): coin total volume in usd
        total_volume_btc (str): coin total volume in btc
        sparkline (str): coin sparkline image url
        content (str): The model property of type str.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "price": 'price',
        "price_btc": 'price_btc',
        "price_change_percentage_24_h": 'price_change_percentage_24h',
        "market_cap": 'market_cap',
        "market_cap_btc": 'market_cap_btc',
        "total_volume": 'total_volume',
        "total_volume_btc": 'total_volume_btc',
        "sparkline": 'sparkline',
        "content": 'content'
    }

    _optionals = [
        'price',
        'price_btc',
        'price_change_percentage_24_h',
        'market_cap',
        'market_cap_btc',
        'total_volume',
        'total_volume_btc',
        'sparkline',
        'content',
    ]

    def __init__(self,
                 price=APIHelper.SKIP,
                 price_btc=APIHelper.SKIP,
                 price_change_percentage_24_h=APIHelper.SKIP,
                 market_cap=APIHelper.SKIP,
                 market_cap_btc=APIHelper.SKIP,
                 total_volume=APIHelper.SKIP,
                 total_volume_btc=APIHelper.SKIP,
                 sparkline=APIHelper.SKIP,
                 content=APIHelper.SKIP):
        """Constructor for the Data class"""

        # Initialize members of the class
        if price is not APIHelper.SKIP:
            self.price = price 
        if price_btc is not APIHelper.SKIP:
            self.price_btc = price_btc 
        if price_change_percentage_24_h is not APIHelper.SKIP:
            self.price_change_percentage_24_h = price_change_percentage_24_h 
        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 sparkline is not APIHelper.SKIP:
            self.sparkline = sparkline 
        if content is not APIHelper.SKIP:
            self.content = content 

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

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'price={(self.price if hasattr(self, "price") else None)!r}, '
                f'price_btc={(self.price_btc if hasattr(self, "price_btc") else None)!r}, '
                f'price_change_percentage_24_h={(self.price_change_percentage_24_h if hasattr(self, "price_change_percentage_24_h") else None)!r}, '
                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'sparkline={(self.sparkline if hasattr(self, "sparkline") else None)!r}, '
                f'content={(self.content if hasattr(self, "content") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'price={(self.price if hasattr(self, "price") else None)!s}, '
                f'price_btc={(self.price_btc if hasattr(self, "price_btc") else None)!s}, '
                f'price_change_percentage_24_h={(self.price_change_percentage_24_h if hasattr(self, "price_change_percentage_24_h") else None)!s}, '
                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'sparkline={(self.sparkline if hasattr(self, "sparkline") else None)!s}, '
                f'content={(self.content if hasattr(self, "content") else None)!s})')
