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

"""
coingeckopublicapiv3

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


class Rates(object):

    """Implementation of the 'Rates' model.

    Attributes:
        name (str): name of the currency
        unit (str): unit of the currency
        value (float): value of the currency
        mtype (str): type of the currency

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "name": 'name',
        "unit": 'unit',
        "value": 'value',
        "mtype": 'type'
    }

    _optionals = [
        'name',
        'unit',
        'value',
        'mtype',
    ]

    def __init__(self,
                 name=APIHelper.SKIP,
                 unit=APIHelper.SKIP,
                 value=APIHelper.SKIP,
                 mtype=APIHelper.SKIP):
        """Constructor for the Rates class"""

        # Initialize members of the class
        if name is not APIHelper.SKIP:
            self.name = name 
        if unit is not APIHelper.SKIP:
            self.unit = unit 
        if value is not APIHelper.SKIP:
            self.value = value 
        if mtype is not APIHelper.SKIP:
            self.mtype = mtype 

    @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
        name = dictionary.get("name") if dictionary.get("name") else APIHelper.SKIP
        unit = dictionary.get("unit") if dictionary.get("unit") else APIHelper.SKIP
        value = dictionary.get("value") if dictionary.get("value") else APIHelper.SKIP
        mtype = dictionary.get("type") if dictionary.get("type") else APIHelper.SKIP
        # Return an object of this model
        return cls(name,
                   unit,
                   value,
                   mtype)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'name={(self.name if hasattr(self, "name") else None)!r}, '
                f'unit={(self.unit if hasattr(self, "unit") else None)!r}, '
                f'value={(self.value if hasattr(self, "value") else None)!r}, '
                f'mtype={(self.mtype if hasattr(self, "mtype") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'name={(self.name if hasattr(self, "name") else None)!s}, '
                f'unit={(self.unit if hasattr(self, "unit") else None)!s}, '
                f'value={(self.value if hasattr(self, "value") else None)!s}, '
                f'mtype={(self.mtype if hasattr(self, "mtype") else None)!s})')
