# coding: utf-8

"""
    Logto API references

    API references for Logto services. To learn more about how to interact with Logto APIs, see [Interact with Management API](https://docs.logto.io/docs/recipes/interact-with-management-api/).

    The version of the OpenAPI document: Cloud
    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 pydantic import BaseModel, ConfigDict, Field
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class ApiOrganizationInvitationsPostRequest(BaseModel):
    """
    ApiOrganizationInvitationsPostRequest
    """ # noqa: E501
    inviter_id: Optional[Any] = Field(default=None, description="The ID of the user who is inviting the user to join the organization.", alias="inviterId")
    invitee: Optional[Any] = Field(default=None, description="The email address of the user to invite to join the organization.")
    organization_id: Optional[Any] = Field(default=None, description="The ID of the organization to invite the user to join.", alias="organizationId")
    expires_at: Optional[Any] = Field(default=None, description="The epoch time in milliseconds when the invitation expires.", alias="expiresAt")
    organization_role_ids: Optional[Any] = Field(default=None, description="The IDs of the organization roles to assign to the user when they accept the invitation.", alias="organizationRoleIds")
    message_payload: Optional[Any] = Field(default=None, description="The message payload for the \"OrganizationInvitation\" template to use when sending the invitation via email. If it is `false`, the invitation will not be sent via email.", alias="messagePayload")
    __properties: ClassVar[List[str]] = ["inviterId", "invitee", "organizationId", "expiresAt", "organizationRoleIds", "messagePayload"]

    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 ApiOrganizationInvitationsPostRequest 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 inviter_id (nullable) is None
        # and model_fields_set contains the field
        if self.inviter_id is None and "inviter_id" in self.model_fields_set:
            _dict['inviterId'] = None

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "inviterId": obj.get("inviterId"),
            "invitee": obj.get("invitee"),
            "organizationId": obj.get("organizationId"),
            "expiresAt": obj.get("expiresAt"),
            "organizationRoleIds": obj.get("organizationRoleIds"),
            "messagePayload": obj.get("messagePayload")
        })
        return _obj


