# coding: utf-8

"""
    Moodle Webservice API

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

    The version of the OpenAPI document: 5.0.3 (Build: 20251006)
    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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from poodle_async_full.models.core_enrol_get_potential_users_response_inner import CoreEnrolGetPotentialUsersResponseInner
from typing import Optional, Set
from typing_extensions import Self

from poodle_async_full.configuration import settings

class ModAssignGetParticipantResponse(BaseModel):
    """
    ModAssignGetParticipantResponse
    """ # noqa: E501
    allowsubmissionsfromdate: Optional[StrictInt] = Field(description="allowsubmissionsfromdate for the user")
    blindmarking: Optional[StrictBool] = Field(description="is blind marking enabled for this assignment")
    cutoffdate: Optional[StrictInt] = Field(description="cutoffdate for the user")
    duedate: Optional[StrictInt] = Field(description="duedate for the user")
    duedatestr: Optional[StrictStr] = Field(description="duedate for the user")
    fullname: Optional[StrictStr] = Field(description="The fullname of the user")
    grantedextension: Optional[StrictBool] = Field(description="have they been granted an extension")
    groupid: Optional[StrictInt] = Field(default=None, description="for group assignments this is the group id")
    groupname: Optional[StrictStr] = Field(default=None, description="for group assignments this is the group name")
    id: Optional[StrictInt] = Field(description="ID of the user")
    requiregrading: Optional[StrictBool] = Field(description="is their submission waiting for grading")
    submissionstatus: Optional[StrictStr] = Field(default=None, description="The submission status (new, draft, reopened or submitted).                 Empty when not submitted.")
    submitted: Optional[StrictBool] = Field(description="have they submitted their assignment")
    user: Optional[CoreEnrolGetPotentialUsersResponseInner] = None
    __properties: ClassVar[List[str]] = ["allowsubmissionsfromdate", "blindmarking", "cutoffdate", "duedate", "duedatestr", "fullname", "grantedextension", "groupid", "groupname", "id", "requiregrading", "submissionstatus", "submitted", "user"]

    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 ModAssignGetParticipantResponse 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,
        )
        # override the default output from pydantic by calling `to_dict()` of user
        if self.user:
            _dict['user'] = self.user.to_dict()
        # set to None if allowsubmissionsfromdate (nullable) is None
        # and model_fields_set contains the field
        if self.allowsubmissionsfromdate is None and "allowsubmissionsfromdate" in self.model_fields_set:
            _dict['allowsubmissionsfromdate'] = None

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

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

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

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

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

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

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

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

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

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

        return _dict

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

        relaxed = settings.relaxe_all_models or "ModAssignGetParticipantResponse" in settings.relaxed_models

        if not isinstance(obj, dict):
            return cls.model_construct(**obj) if relaxed else cls.model_validate(obj)

        data = {
            "allowsubmissionsfromdate": obj.get("allowsubmissionsfromdate"),
            "blindmarking": obj.get("blindmarking"),
            "cutoffdate": obj.get("cutoffdate"),
            "duedate": obj.get("duedate"),
            "duedatestr": obj.get("duedatestr"),
            "fullname": obj.get("fullname"),
            "grantedextension": obj.get("grantedextension"),
            "groupid": obj.get("groupid"),
            "groupname": obj.get("groupname"),
            "id": obj.get("id"),
            "requiregrading": obj.get("requiregrading"),
            "submissionstatus": obj.get("submissionstatus"),
            "submitted": obj.get("submitted"),
            "user": CoreEnrolGetPotentialUsersResponseInner.from_dict(obj["user"]) if obj.get("user") is not None else None
        }
        _obj = cls.model_construct(**data) if relaxed else cls.model_validate(data)
        return _obj


