# coding: utf-8

"""
    Jellyfin API

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

    The version of the OpenAPI document: 10.11.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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class AuthenticationInfo(BaseModel):
    """
    AuthenticationInfo
    """ # noqa: E501
    id: Optional[StrictInt] = Field(default=None, description="Gets or sets the identifier.", alias="Id")
    access_token: Optional[StrictStr] = Field(default=None, description="Gets or sets the access token.", alias="AccessToken")
    device_id: Optional[StrictStr] = Field(default=None, description="Gets or sets the device identifier.", alias="DeviceId")
    app_name: Optional[StrictStr] = Field(default=None, description="Gets or sets the name of the application.", alias="AppName")
    app_version: Optional[StrictStr] = Field(default=None, description="Gets or sets the application version.", alias="AppVersion")
    device_name: Optional[StrictStr] = Field(default=None, description="Gets or sets the name of the device.", alias="DeviceName")
    user_id: Optional[StrictStr] = Field(default=None, description="Gets or sets the user identifier.", alias="UserId")
    is_active: Optional[StrictBool] = Field(default=None, description="Gets or sets a value indicating whether this instance is active.", alias="IsActive")
    date_created: Optional[datetime] = Field(default=None, description="Gets or sets the date created.", alias="DateCreated")
    date_revoked: Optional[datetime] = Field(default=None, description="Gets or sets the date revoked.", alias="DateRevoked")
    date_last_activity: Optional[datetime] = Field(default=None, alias="DateLastActivity")
    user_name: Optional[StrictStr] = Field(default=None, alias="UserName")
    __properties: ClassVar[List[str]] = ["Id", "AccessToken", "DeviceId", "AppName", "AppVersion", "DeviceName", "UserId", "IsActive", "DateCreated", "DateRevoked", "DateLastActivity", "UserName"]

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "Id": obj.get("Id"),
            "AccessToken": obj.get("AccessToken"),
            "DeviceId": obj.get("DeviceId"),
            "AppName": obj.get("AppName"),
            "AppVersion": obj.get("AppVersion"),
            "DeviceName": obj.get("DeviceName"),
            "UserId": obj.get("UserId"),
            "IsActive": obj.get("IsActive"),
            "DateCreated": obj.get("DateCreated"),
            "DateRevoked": obj.get("DateRevoked"),
            "DateLastActivity": obj.get("DateLastActivity"),
            "UserName": obj.get("UserName")
        })
        return _obj


