# coding: utf-8

"""
    Moodle Webservice API

    Auto-generated OpenAPI spec for Moodle's Webservice API.

    The version of the OpenAPI document: 4.5 (Build: 20241007)
    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, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class MessageAirnotifierGetUserDevicesResponseDevicesInner(BaseModel):
    """
    MessageAirnotifierGetUserDevicesResponseDevicesInner
    """ # noqa: E501
    appid: Optional[StrictStr] = Field(description="The app id, something like com.moodle.moodlemobile")
    enable: Optional[StrictInt] = Field(description="Whether the device is enabled or not")
    id: Optional[StrictInt] = Field(description="Device id (in the message_airnotifier table)")
    model: Optional[StrictStr] = Field(description="The device model 'Nexus4' or 'iPad1,1' etc.")
    name: Optional[StrictStr] = Field(description="The device name, 'occam' or 'iPhone' etc.")
    platform: Optional[StrictStr] = Field(description="The device platform 'iOS' or 'Android' etc.")
    pushid: Optional[StrictStr] = Field(description="The device PUSH token/key/identifier/registration id")
    timecreated: Optional[StrictInt] = Field(description="Time created")
    timemodified: Optional[StrictInt] = Field(description="Time modified")
    uuid: Optional[StrictStr] = Field(description="The device UUID")
    version: Optional[StrictStr] = Field(description="The device version '6.1.2' or '4.2.2' etc.")
    __properties: ClassVar[List[str]] = ["appid", "enable", "id", "model", "name", "platform", "pushid", "timecreated", "timemodified", "uuid", "version"]

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "appid": obj.get("appid"),
            "enable": obj.get("enable"),
            "id": obj.get("id"),
            "model": obj.get("model"),
            "name": obj.get("name"),
            "platform": obj.get("platform"),
            "pushid": obj.get("pushid"),
            "timecreated": obj.get("timecreated"),
            "timemodified": obj.get("timemodified"),
            "uuid": obj.get("uuid"),
            "version": obj.get("version")
        })
        return _obj


