# coding: utf-8

"""
    DUPR Backend APIs

    Internal RESTful APIs to access DUPR ratings, users and provide matches.

    The version of the OpenAPI document: v1.0.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 date
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from dupr_backend.models.league_content_request import LeagueContentRequest
from dupr_backend.models.milp_division_request import MILPDivisionRequest
from dupr_backend.models.milp_event_organizer_request import MILPEventOrganizerRequest
from typing import Optional, Set
from typing_extensions import Self

class MiLPEventRequest(BaseModel):
    """
    MiLPEventRequest
    """ # noqa: E501
    event_name: StrictStr = Field(alias="eventName")
    organizers: List[MILPEventOrganizerRequest]
    default_entry_fee: Union[StrictFloat, StrictInt] = Field(alias="defaultEntryFee")
    default_max_teams: StrictInt = Field(alias="defaultMaxTeams")
    default_max_waitlist: StrictInt = Field(alias="defaultMaxWaitlist")
    description: Optional[LeagueContentRequest] = None
    address_id: StrictInt = Field(alias="addressId")
    event_type: StrictStr = Field(alias="eventType")
    time_zone: StrictStr = Field(alias="timeZone")
    duration: List[date]
    divisions: List[MILPDivisionRequest]
    club_id: StrictInt = Field(alias="clubId")
    status: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["eventName", "organizers", "defaultEntryFee", "defaultMaxTeams", "defaultMaxWaitlist", "description", "addressId", "eventType", "timeZone", "duration", "divisions", "clubId", "status"]

    @field_validator('event_type')
    def event_type_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['STANDARD', 'MARQUE', 'SHOWDOWN']):
            raise ValueError("must be one of enum values ('STANDARD', 'MARQUE', 'SHOWDOWN')")
        return value

    @field_validator('status')
    def status_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['ACTIVE', 'INACTIVE', 'UPCOMING', 'IN_PROGRESS', 'COMPLETE', 'CANCELLED', 'NOT_CONFIRMED', 'INVITED', 'CONFIRMED', 'MATCH_BYE', 'PENDING', 'FORFEITED', 'DELETED', 'ONGOING', 'SUSPENDED_TOS_13']):
            raise ValueError("must be one of enum values ('ACTIVE', 'INACTIVE', 'UPCOMING', 'IN_PROGRESS', 'COMPLETE', 'CANCELLED', 'NOT_CONFIRMED', 'INVITED', 'CONFIRMED', 'MATCH_BYE', 'PENDING', 'FORFEITED', 'DELETED', 'ONGOING', 'SUSPENDED_TOS_13')")
        return value

    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 MiLPEventRequest 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 each item in organizers (list)
        _items = []
        if self.organizers:
            for _item_organizers in self.organizers:
                if _item_organizers:
                    _items.append(_item_organizers.to_dict())
            _dict['organizers'] = _items
        # override the default output from pydantic by calling `to_dict()` of description
        if self.description:
            _dict['description'] = self.description.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in divisions (list)
        _items = []
        if self.divisions:
            for _item_divisions in self.divisions:
                if _item_divisions:
                    _items.append(_item_divisions.to_dict())
            _dict['divisions'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "eventName": obj.get("eventName"),
            "organizers": [MILPEventOrganizerRequest.from_dict(_item) for _item in obj["organizers"]] if obj.get("organizers") is not None else None,
            "defaultEntryFee": obj.get("defaultEntryFee"),
            "defaultMaxTeams": obj.get("defaultMaxTeams"),
            "defaultMaxWaitlist": obj.get("defaultMaxWaitlist"),
            "description": LeagueContentRequest.from_dict(obj["description"]) if obj.get("description") is not None else None,
            "addressId": obj.get("addressId"),
            "eventType": obj.get("eventType"),
            "timeZone": obj.get("timeZone"),
            "duration": obj.get("duration"),
            "divisions": [MILPDivisionRequest.from_dict(_item) for _item in obj["divisions"]] if obj.get("divisions") is not None else None,
            "clubId": obj.get("clubId"),
            "status": obj.get("status")
        })
        return _obj


