# 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 pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from dupr_backend.models.player_rating_response import PlayerRatingResponse
from dupr_backend.models.registration_response import RegistrationResponse
from dupr_backend.models.sponsor_logo_response import SponsorLogoResponse
from typing import Optional, Set
from typing_extensions import Self

class PlayerResponse(BaseModel):
    """
    PlayerResponse
    """ # noqa: E501
    id: Optional[StrictInt] = None
    full_name: StrictStr = Field(alias="fullName")
    first_name: StrictStr = Field(alias="firstName")
    last_name: StrictStr = Field(alias="lastName")
    username: Optional[StrictStr] = None
    display_username: Optional[StrictBool] = Field(default=None, alias="displayUsername")
    short_address: Optional[StrictStr] = Field(default=None, alias="shortAddress")
    formatted_address: Optional[StrictStr] = Field(default=None, alias="formattedAddress")
    latitude: Optional[Union[StrictFloat, StrictInt]] = None
    longitude: Optional[Union[StrictFloat, StrictInt]] = None
    gender: Optional[StrictStr] = None
    age: Optional[StrictInt] = None
    hand: Optional[StrictStr] = None
    image_url: Optional[StrictStr] = Field(default=None, alias="imageUrl")
    ratings: Optional[PlayerRatingResponse] = Field(default=None, description="Ratings data")
    invited: Optional[StrictBool] = None
    distance: Optional[StrictStr] = None
    enable_privacy: StrictBool = Field(alias="enablePrivacy")
    distance_in_miles: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="distanceInMiles")
    is_logged_in_user: Optional[StrictBool] = Field(default=None, alias="isLoggedInUser")
    partner_status: Optional[StrictStr] = Field(default=None, alias="partnerStatus")
    team_status: Optional[StrictStr] = Field(default=None, alias="teamStatus")
    is_player1: StrictBool = Field(alias="isPlayer1")
    registration_details: Optional[RegistrationResponse] = Field(default=None, alias="registrationDetails")
    phone: Optional[StrictStr] = None
    email: Optional[StrictStr] = None
    verified_email: Optional[StrictBool] = Field(default=None, alias="verifiedEmail")
    registration_type: Optional[StrictStr] = Field(default=None, alias="registrationType")
    registered: StrictBool
    dupr_id: StrictStr = Field(alias="duprId")
    show_rating_banner: StrictBool = Field(alias="showRatingBanner")
    status: Optional[StrictStr] = None
    sponsor: Optional[SponsorLogoResponse] = None
    substitution_details: Optional[List[PlayerResponse]] = Field(default=None, alias="substitutionDetails")
    is_substitute: Optional[StrictBool] = Field(default=None, alias="isSubstitute")
    lucra_connected: Optional[StrictBool] = Field(default=None, alias="lucraConnected")
    substitute: Optional[StrictBool] = None
    __properties: ClassVar[List[str]] = ["id", "fullName", "firstName", "lastName", "username", "displayUsername", "shortAddress", "formattedAddress", "latitude", "longitude", "gender", "age", "hand", "imageUrl", "ratings", "invited", "distance", "enablePrivacy", "distanceInMiles", "isLoggedInUser", "partnerStatus", "teamStatus", "isPlayer1", "registrationDetails", "phone", "email", "verifiedEmail", "registrationType", "registered", "duprId", "showRatingBanner", "status", "sponsor", "substitutionDetails", "isSubstitute", "lucraConnected", "substitute"]

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

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

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

        if value not in set(['RIGHT', 'LEFT', 'BOTH', 'NONE']):
            raise ValueError("must be one of enum values ('RIGHT', 'LEFT', 'BOTH', 'NONE')")
        return value

    @field_validator('partner_status')
    def partner_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

    @field_validator('team_status')
    def team_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

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

        if value not in set(['INVITATION', 'UNCLAIMED']):
            raise ValueError("must be one of enum values ('INVITATION', 'UNCLAIMED')")
        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 PlayerResponse 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 ratings
        if self.ratings:
            _dict['ratings'] = self.ratings.to_dict()
        # override the default output from pydantic by calling `to_dict()` of registration_details
        if self.registration_details:
            _dict['registrationDetails'] = self.registration_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of sponsor
        if self.sponsor:
            _dict['sponsor'] = self.sponsor.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in substitution_details (list)
        _items = []
        if self.substitution_details:
            for _item_substitution_details in self.substitution_details:
                if _item_substitution_details:
                    _items.append(_item_substitution_details.to_dict())
            _dict['substitutionDetails'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of PlayerResponse 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"),
            "fullName": obj.get("fullName"),
            "firstName": obj.get("firstName"),
            "lastName": obj.get("lastName"),
            "username": obj.get("username"),
            "displayUsername": obj.get("displayUsername"),
            "shortAddress": obj.get("shortAddress"),
            "formattedAddress": obj.get("formattedAddress"),
            "latitude": obj.get("latitude"),
            "longitude": obj.get("longitude"),
            "gender": obj.get("gender"),
            "age": obj.get("age"),
            "hand": obj.get("hand"),
            "imageUrl": obj.get("imageUrl"),
            "ratings": PlayerRatingResponse.from_dict(obj["ratings"]) if obj.get("ratings") is not None else None,
            "invited": obj.get("invited"),
            "distance": obj.get("distance"),
            "enablePrivacy": obj.get("enablePrivacy"),
            "distanceInMiles": obj.get("distanceInMiles"),
            "isLoggedInUser": obj.get("isLoggedInUser"),
            "partnerStatus": obj.get("partnerStatus"),
            "teamStatus": obj.get("teamStatus"),
            "isPlayer1": obj.get("isPlayer1"),
            "registrationDetails": RegistrationResponse.from_dict(obj["registrationDetails"]) if obj.get("registrationDetails") is not None else None,
            "phone": obj.get("phone"),
            "email": obj.get("email"),
            "verifiedEmail": obj.get("verifiedEmail"),
            "registrationType": obj.get("registrationType"),
            "registered": obj.get("registered"),
            "duprId": obj.get("duprId"),
            "showRatingBanner": obj.get("showRatingBanner"),
            "status": obj.get("status"),
            "sponsor": SponsorLogoResponse.from_dict(obj["sponsor"]) if obj.get("sponsor") is not None else None,
            "substitutionDetails": [PlayerResponse.from_dict(_item) for _item in obj["substitutionDetails"]] if obj.get("substitutionDetails") is not None else None,
            "isSubstitute": obj.get("isSubstitute"),
            "lucraConnected": obj.get("lucraConnected"),
            "substitute": obj.get("substitute")
        })
        return _obj

# TODO: Rewrite to not use raise_errors
PlayerResponse.model_rebuild(raise_errors=False)

