# coding: utf-8

"""
    Weheat Backend

    This is the backend for the Weheat project

    The version of the OpenAPI document: v1
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field, StrictStr
from weheat.models.role import Role

class ReadUserDto(BaseModel):
    """
    ReadUserDto
    """
    id: StrictStr = Field(..., description="Identifier of the user")
    first_name: Optional[StrictStr] = Field(None, alias="firstName", description="First name of the user if available")
    last_name: Optional[StrictStr] = Field(None, alias="lastName", description="Last Name of the user if available")
    role: Role = Field(...)
    email: Optional[StrictStr] = Field(None, description="Email address of the user")
    updated_on: datetime = Field(..., alias="updatedOn", description="Timestamp of the last update to the user entry")
    created_on: datetime = Field(..., alias="createdOn", description="Timestamp of the creation of the user entry")
    __properties = ["id", "firstName", "lastName", "role", "email", "updatedOn", "createdOn"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> ReadUserDto:
        """Create an instance of ReadUserDto from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # set to None if first_name (nullable) is None
        # and __fields_set__ contains the field
        if self.first_name is None and "first_name" in self.__fields_set__:
            _dict['firstName'] = None

        # set to None if last_name (nullable) is None
        # and __fields_set__ contains the field
        if self.last_name is None and "last_name" in self.__fields_set__:
            _dict['lastName'] = None

        # set to None if email (nullable) is None
        # and __fields_set__ contains the field
        if self.email is None and "email" in self.__fields_set__:
            _dict['email'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> ReadUserDto:
        """Create an instance of ReadUserDto from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return ReadUserDto.parse_obj(obj)

        _obj = ReadUserDto.parse_obj({
            "id": obj.get("id"),
            "first_name": obj.get("firstName"),
            "last_name": obj.get("lastName"),
            "role": obj.get("role"),
            "email": obj.get("email"),
            "updated_on": obj.get("updatedOn"),
            "created_on": obj.get("createdOn")
        })
        return _obj


