# coding: utf-8

"""
    InductivaWebAPI

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 0.1.0
    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 pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from inductiva.client.models.invitation_status import InvitationStatus
from inductiva.client.models.team_role import TeamRole
from typing import Optional, Set
from typing_extensions import Self


class TeamInvitationAdminResponse(BaseModel):
    """
    Schema for team invitation response (admin endpoints - full data).
    """ # noqa: E501
    email: StrictStr = Field(
        description="Email address of the person to invite")
    role: Optional[TeamRole] = None
    message: Optional[StrictStr] = None
    id: StrictStr
    organization_id: StrictStr
    status: InvitationStatus
    invitation_token: StrictStr
    invited_at: datetime
    expires_at: datetime
    accepted_at: Optional[datetime] = None
    rejected_at: Optional[datetime] = None
    invited_by_email: StrictStr
    invited_by_name: Optional[StrictStr] = None
    organization_name: StrictStr
    __properties: ClassVar[List[str]] = [
        "email", "role", "message", "id", "organization_id", "status",
        "invitation_token", "invited_at", "expires_at", "accepted_at",
        "rejected_at", "invited_by_email", "invited_by_name",
        "organization_name"
    ]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )

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

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

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

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # set to None if message (nullable) is None
        # and model_fields_set contains the field
        if self.message is None and "message" in self.model_fields_set:
            _dict['message'] = None

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of TeamInvitationAdminResponse from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "email": obj.get("email"),
            "role": obj.get("role"),
            "message": obj.get("message"),
            "id": obj.get("id"),
            "organization_id": obj.get("organization_id"),
            "status": obj.get("status"),
            "invitation_token": obj.get("invitation_token"),
            "invited_at": obj.get("invited_at"),
            "expires_at": obj.get("expires_at"),
            "accepted_at": obj.get("accepted_at"),
            "rejected_at": obj.get("rejected_at"),
            "invited_by_email": obj.get("invited_by_email"),
            "invited_by_name": obj.get("invited_by_name"),
            "organization_name": obj.get("organization_name")
        })
        return _obj
