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

"""
   wegene.Models.User

   This file was automatically generated by APIMATIC BETA v2.0 on 02/22/2016
"""
from wegene.APIHelper import APIHelper
from wegene.Models.Profile import Profile


class User(object):

    """Implementation of the 'user' model.

    Model for user information

    Attributes:
        id (string): Unique Wegene Id
        profiles (list of Profile): Available genetic profile data in array
        email (string): User email at Wegene

    """

    def __init__(self,
                 **kwargs):
        """Constructor for the User class

        Args:
            **kwargs: Keyword Arguments in order to initialise the
                object. Any of the attributes in this object are able to
                be set through the **kwargs of the constructor. The values
                that can be supplied and their types are as follows::

                    id -- string -- Sets the attribute id
                    profiles -- list of Profile -- Sets the attribute profiles
                    email -- string -- Sets the attribute email

        """
        # Set all of the parameters to their default values
        self.id = None
        self.profiles = None
        self.email = None

        # Create a mapping from API property names to Model property names
        replace_names = {
            "id": "id",
            "profiles": "profiles",
            "email": "email",
        }

        # Parse all of the Key-Value arguments
        if kwargs is not None:
            for key in kwargs:
                # Only add arguments that are actually part of this object
                if key in replace_names:
                    setattr(self, replace_names[key], kwargs[key])

            # Other objects also need to be initialised properly
            if "profiles" in kwargs:
                # Parameter is an array, so we need to iterate through it
                self.profiles = list()
                for item in kwargs["profiles"]:
                    self.profiles.append(Profile(**item))

    def resolve_names(self):
        """Creates a dictionary representation of this object.

        This method converts an object to a dictionary that represents the
        format that the model should be in when passed into an API Request.
        Because of this, the generated dictionary may have different
        property names to that of the model itself.

        Returns:
            dict: The dictionary representing the object.

        """
        # Create a mapping from Model property names to API property names
        replace_names = {
            "id": "id",
            "profiles": "profiles",
            "email": "email",
        }

        retval = dict()

        return APIHelper.resolve_names(self, replace_names, retval)
