# -*- 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.data_2 import Data2


class Categories2(object):

    """Implementation of the 'Categories2' model.

    Attributes:
        id (float): The model property of type float.
        name (str): category name
        market_cap_1_h_change (float): category market cap 1 hour change
        slug (str): category web slug
        coins_count (float): category number of coins
        data (Data2): The model property of type Data2.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id": 'id',
        "name": 'name',
        "market_cap_1_h_change": 'market_cap_1h_change',
        "slug": 'slug',
        "coins_count": 'coins_count',
        "data": 'data'
    }

    _optionals = [
        'id',
        'name',
        'market_cap_1_h_change',
        'slug',
        'coins_count',
        'data',
    ]

    def __init__(self,
                 id=APIHelper.SKIP,
                 name=APIHelper.SKIP,
                 market_cap_1_h_change=APIHelper.SKIP,
                 slug=APIHelper.SKIP,
                 coins_count=APIHelper.SKIP,
                 data=APIHelper.SKIP):
        """Constructor for the Categories2 class"""

        # Initialize members of the class
        if id is not APIHelper.SKIP:
            self.id = id 
        if name is not APIHelper.SKIP:
            self.name = name 
        if market_cap_1_h_change is not APIHelper.SKIP:
            self.market_cap_1_h_change = market_cap_1_h_change 
        if slug is not APIHelper.SKIP:
            self.slug = slug 
        if coins_count is not APIHelper.SKIP:
            self.coins_count = coins_count 
        if data is not APIHelper.SKIP:
            self.data = data 

    @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
        id = dictionary.get("id") if dictionary.get("id") else APIHelper.SKIP
        name = dictionary.get("name") if dictionary.get("name") else APIHelper.SKIP
        market_cap_1_h_change = dictionary.get("market_cap_1h_change") if dictionary.get("market_cap_1h_change") else APIHelper.SKIP
        slug = dictionary.get("slug") if dictionary.get("slug") else APIHelper.SKIP
        coins_count = dictionary.get("coins_count") if dictionary.get("coins_count") else APIHelper.SKIP
        data = Data2.from_dictionary(dictionary.get('data')) if 'data' in dictionary.keys() else APIHelper.SKIP
        # Return an object of this model
        return cls(id,
                   name,
                   market_cap_1_h_change,
                   slug,
                   coins_count,
                   data)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'id={(self.id if hasattr(self, "id") else None)!r}, '
                f'name={(self.name if hasattr(self, "name") else None)!r}, '
                f'market_cap_1_h_change={(self.market_cap_1_h_change if hasattr(self, "market_cap_1_h_change") else None)!r}, '
                f'slug={(self.slug if hasattr(self, "slug") else None)!r}, '
                f'coins_count={(self.coins_count if hasattr(self, "coins_count") else None)!r}, '
                f'data={(self.data if hasattr(self, "data") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'id={(self.id if hasattr(self, "id") else None)!s}, '
                f'name={(self.name if hasattr(self, "name") else None)!s}, '
                f'market_cap_1_h_change={(self.market_cap_1_h_change if hasattr(self, "market_cap_1_h_change") else None)!s}, '
                f'slug={(self.slug if hasattr(self, "slug") else None)!s}, '
                f'coins_count={(self.coins_count if hasattr(self, "coins_count") else None)!s}, '
                f'data={(self.data if hasattr(self, "data") else None)!s})')
