# 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 datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from dupr_backend.models.address_response import AddressResponse
from dupr_backend.models.bracket_response import BracketResponse
from dupr_backend.models.currency_details_response import CurrencyDetailsResponse
from dupr_backend.models.league_contact_detail_response import LeagueContactDetailResponse
from dupr_backend.models.league_content_response import LeagueContentResponse
from typing import Optional, Set
from typing_extensions import Self

class LeagueResponse(BaseModel):
    """
    LeagueResponse
    """ # noqa: E501
    league_id: StrictInt = Field(alias="leagueId")
    club_id: StrictInt = Field(alias="clubId")
    user_id: StrictInt = Field(alias="userId")
    league_name: StrictStr = Field(alias="leagueName")
    media_url: Optional[StrictStr] = Field(default=None, alias="mediaUrl")
    liability_waiver_url: Optional[StrictStr] = Field(default=None, alias="liabilityWaiverUrl")
    member_fee: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="memberFee")
    non_member_fee: Union[StrictFloat, StrictInt] = Field(alias="nonMemberFee")
    membership_permission: Optional[StrictStr] = Field(default=None, alias="membershipPermission")
    short_description: Optional[LeagueContentResponse] = Field(default=None, alias="shortDescription")
    long_description: Optional[LeagueContentResponse] = Field(default=None, alias="longDescription")
    additional_information: Optional[LeagueContentResponse] = Field(default=None, alias="additionalInformation")
    refund_policy: Optional[LeagueContentResponse] = Field(default=None, alias="refundPolicy")
    safety_policy: Optional[LeagueContentResponse] = Field(default=None, alias="safetyPolicy")
    address: Optional[AddressResponse] = None
    duration: List[StrictStr]
    registration_date: List[StrictStr] = Field(alias="registrationDate")
    type: Optional[StrictStr] = None
    attributes: Optional[Dict[str, Dict[str, Any]]] = None
    brackets: List[BracketResponse]
    status: Optional[StrictStr] = None
    distance: Optional[StrictStr] = None
    distance_in_miles: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="distanceInMiles")
    league_price: Optional[StrictStr] = Field(default=None, alias="leaguePrice")
    skill_level: Optional[StrictStr] = Field(default=None, alias="skillLevel")
    age_string: Optional[StrictStr] = Field(default=None, alias="ageString")
    player_group: Optional[StrictStr] = Field(default=None, alias="playerGroup")
    duration_string: Optional[StrictStr] = Field(default=None, alias="durationString")
    registration_string: Optional[StrictStr] = Field(default=None, alias="registrationString")
    registration_status: Optional[StrictStr] = Field(default=None, alias="registrationStatus")
    event_format_string: Optional[StrictStr] = Field(default=None, alias="eventFormatString")
    elimination_string: Optional[StrictStr] = Field(default=None, alias="eliminationString")
    short_address: Optional[StrictStr] = Field(default=None, alias="shortAddress")
    club_name: Optional[StrictStr] = Field(default=None, alias="clubName")
    contact_details: Optional[List[LeagueContactDetailResponse]] = Field(default=None, alias="contactDetails")
    registered_members: Optional[StrictInt] = Field(default=None, alias="registeredMembers")
    duration_status: Optional[StrictStr] = Field(default=None, alias="durationStatus")
    display_status: Optional[StrictStr] = Field(default=None, alias="displayStatus")
    is_registered: Optional[StrictBool] = Field(default=None, alias="isRegistered")
    can_show_standings: Optional[StrictBool] = Field(default=None, alias="canShowStandings")
    liability_waiver_id: StrictInt = Field(alias="liabilityWaiverId")
    media_id: StrictInt = Field(alias="mediaId")
    registration_date_time: Optional[List[StrictStr]] = Field(default=None, alias="registrationDateTime")
    duration_date_time: Optional[List[StrictStr]] = Field(default=None, alias="durationDateTime")
    registration_date_time_utc: Optional[List[StrictStr]] = Field(default=None, alias="registrationDateTimeUTC")
    duration_date_time_utc: Optional[List[StrictStr]] = Field(default=None, alias="durationDateTimeUTC")
    currency_details: Optional[CurrencyDetailsResponse] = Field(default=None, alias="currencyDetails")
    registration_url: Optional[StrictStr] = Field(default=None, alias="registrationUrl")
    start_date: datetime = Field(alias="startDate")
    end_date: datetime = Field(alias="endDate")
    registered: Optional[StrictBool] = None
    __properties: ClassVar[List[str]] = ["leagueId", "clubId", "userId", "leagueName", "mediaUrl", "liabilityWaiverUrl", "memberFee", "nonMemberFee", "membershipPermission", "shortDescription", "longDescription", "additionalInformation", "refundPolicy", "safetyPolicy", "address", "duration", "registrationDate", "type", "attributes", "brackets", "status", "distance", "distanceInMiles", "leaguePrice", "skillLevel", "ageString", "playerGroup", "durationString", "registrationString", "registrationStatus", "eventFormatString", "eliminationString", "shortAddress", "clubName", "contactDetails", "registeredMembers", "durationStatus", "displayStatus", "isRegistered", "canShowStandings", "liabilityWaiverId", "mediaId", "registrationDateTime", "durationDateTime", "registrationDateTimeUTC", "durationDateTimeUTC", "currencyDetails", "registrationUrl", "startDate", "endDate", "registered"]

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

        if value not in set(['OPEN_TO_ALL', 'CLUB_MEMBERS']):
            raise ValueError("must be one of enum values ('OPEN_TO_ALL', 'CLUB_MEMBERS')")
        return value

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

        if value not in set(['FLEX']):
            raise ValueError("must be one of enum values ('FLEX')")
        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 LeagueResponse 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 short_description
        if self.short_description:
            _dict['shortDescription'] = self.short_description.to_dict()
        # override the default output from pydantic by calling `to_dict()` of long_description
        if self.long_description:
            _dict['longDescription'] = self.long_description.to_dict()
        # override the default output from pydantic by calling `to_dict()` of additional_information
        if self.additional_information:
            _dict['additionalInformation'] = self.additional_information.to_dict()
        # override the default output from pydantic by calling `to_dict()` of refund_policy
        if self.refund_policy:
            _dict['refundPolicy'] = self.refund_policy.to_dict()
        # override the default output from pydantic by calling `to_dict()` of safety_policy
        if self.safety_policy:
            _dict['safetyPolicy'] = self.safety_policy.to_dict()
        # override the default output from pydantic by calling `to_dict()` of address
        if self.address:
            _dict['address'] = self.address.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in brackets (list)
        _items = []
        if self.brackets:
            for _item_brackets in self.brackets:
                if _item_brackets:
                    _items.append(_item_brackets.to_dict())
            _dict['brackets'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in contact_details (list)
        _items = []
        if self.contact_details:
            for _item_contact_details in self.contact_details:
                if _item_contact_details:
                    _items.append(_item_contact_details.to_dict())
            _dict['contactDetails'] = _items
        # override the default output from pydantic by calling `to_dict()` of currency_details
        if self.currency_details:
            _dict['currencyDetails'] = self.currency_details.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "leagueId": obj.get("leagueId"),
            "clubId": obj.get("clubId"),
            "userId": obj.get("userId"),
            "leagueName": obj.get("leagueName"),
            "mediaUrl": obj.get("mediaUrl"),
            "liabilityWaiverUrl": obj.get("liabilityWaiverUrl"),
            "memberFee": obj.get("memberFee"),
            "nonMemberFee": obj.get("nonMemberFee"),
            "membershipPermission": obj.get("membershipPermission"),
            "shortDescription": LeagueContentResponse.from_dict(obj["shortDescription"]) if obj.get("shortDescription") is not None else None,
            "longDescription": LeagueContentResponse.from_dict(obj["longDescription"]) if obj.get("longDescription") is not None else None,
            "additionalInformation": LeagueContentResponse.from_dict(obj["additionalInformation"]) if obj.get("additionalInformation") is not None else None,
            "refundPolicy": LeagueContentResponse.from_dict(obj["refundPolicy"]) if obj.get("refundPolicy") is not None else None,
            "safetyPolicy": LeagueContentResponse.from_dict(obj["safetyPolicy"]) if obj.get("safetyPolicy") is not None else None,
            "address": AddressResponse.from_dict(obj["address"]) if obj.get("address") is not None else None,
            "duration": obj.get("duration"),
            "registrationDate": obj.get("registrationDate"),
            "type": obj.get("type"),
            "attributes": obj.get("attributes"),
            "brackets": [BracketResponse.from_dict(_item) for _item in obj["brackets"]] if obj.get("brackets") is not None else None,
            "status": obj.get("status"),
            "distance": obj.get("distance"),
            "distanceInMiles": obj.get("distanceInMiles"),
            "leaguePrice": obj.get("leaguePrice"),
            "skillLevel": obj.get("skillLevel"),
            "ageString": obj.get("ageString"),
            "playerGroup": obj.get("playerGroup"),
            "durationString": obj.get("durationString"),
            "registrationString": obj.get("registrationString"),
            "registrationStatus": obj.get("registrationStatus"),
            "eventFormatString": obj.get("eventFormatString"),
            "eliminationString": obj.get("eliminationString"),
            "shortAddress": obj.get("shortAddress"),
            "clubName": obj.get("clubName"),
            "contactDetails": [LeagueContactDetailResponse.from_dict(_item) for _item in obj["contactDetails"]] if obj.get("contactDetails") is not None else None,
            "registeredMembers": obj.get("registeredMembers"),
            "durationStatus": obj.get("durationStatus"),
            "displayStatus": obj.get("displayStatus"),
            "isRegistered": obj.get("isRegistered"),
            "canShowStandings": obj.get("canShowStandings"),
            "liabilityWaiverId": obj.get("liabilityWaiverId"),
            "mediaId": obj.get("mediaId"),
            "registrationDateTime": obj.get("registrationDateTime"),
            "durationDateTime": obj.get("durationDateTime"),
            "registrationDateTimeUTC": obj.get("registrationDateTimeUTC"),
            "durationDateTimeUTC": obj.get("durationDateTimeUTC"),
            "currencyDetails": CurrencyDetailsResponse.from_dict(obj["currencyDetails"]) if obj.get("currencyDetails") is not None else None,
            "registrationUrl": obj.get("registrationUrl"),
            "startDate": obj.get("startDate"),
            "endDate": obj.get("endDate"),
            "registered": obj.get("registered")
        })
        return _obj


