# -*- 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.token import Token


class TokenLists(object):

    """Implementation of the 'TokenLists' model.

    Attributes:
        name (str): The model property of type str.
        logo_uri (str): The model property of type str.
        keywords (List[str]): The model property of type List[str].
        timestamp (datetime): The model property of type datetime.
        tokens (List[Token]): The model property of type List[Token].

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "name": 'name',
        "logo_uri": 'logoURI',
        "keywords": 'keywords',
        "timestamp": 'timestamp',
        "tokens": 'tokens'
    }

    _optionals = [
        'name',
        'logo_uri',
        'keywords',
        'timestamp',
        'tokens',
    ]

    def __init__(self,
                 name=APIHelper.SKIP,
                 logo_uri=APIHelper.SKIP,
                 keywords=APIHelper.SKIP,
                 timestamp=APIHelper.SKIP,
                 tokens=APIHelper.SKIP):
        """Constructor for the TokenLists class"""

        # Initialize members of the class
        if name is not APIHelper.SKIP:
            self.name = name 
        if logo_uri is not APIHelper.SKIP:
            self.logo_uri = logo_uri 
        if keywords is not APIHelper.SKIP:
            self.keywords = keywords 
        if timestamp is not APIHelper.SKIP:
            self.timestamp = APIHelper.apply_datetime_converter(timestamp, APIHelper.RFC3339DateTime) if timestamp else None 
        if tokens is not APIHelper.SKIP:
            self.tokens = tokens 

    @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
        logo_uri = dictionary.get("logoURI") if dictionary.get("logoURI") else APIHelper.SKIP
        keywords = dictionary.get("keywords") if dictionary.get("keywords") else APIHelper.SKIP
        timestamp = APIHelper.RFC3339DateTime.from_value(dictionary.get("timestamp")).datetime if dictionary.get("timestamp") else APIHelper.SKIP
        tokens = None
        if dictionary.get('tokens') is not None:
            tokens = [Token.from_dictionary(x) for x in dictionary.get('tokens')]
        else:
            tokens = APIHelper.SKIP
        # Return an object of this model
        return cls(name,
                   logo_uri,
                   keywords,
                   timestamp,
                   tokens)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'name={(self.name if hasattr(self, "name") else None)!r}, '
                f'logo_uri={(self.logo_uri if hasattr(self, "logo_uri") else None)!r}, '
                f'keywords={(self.keywords if hasattr(self, "keywords") else None)!r}, '
                f'timestamp={(self.timestamp if hasattr(self, "timestamp") else None)!r}, '
                f'tokens={(self.tokens if hasattr(self, "tokens") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'name={(self.name if hasattr(self, "name") else None)!s}, '
                f'logo_uri={(self.logo_uri if hasattr(self, "logo_uri") else None)!s}, '
                f'keywords={(self.keywords if hasattr(self, "keywords") else None)!s}, '
                f'timestamp={(self.timestamp if hasattr(self, "timestamp") else None)!s}, '
                f'tokens={(self.tokens if hasattr(self, "tokens") else None)!s})')
