# 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, 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.sponsor import Sponsor
from typing import Optional, Set
from typing_extensions import Self

class Player(BaseModel):
    """
    Player
    """ # noqa: E501
    id: StrictInt
    full_name: StrictStr = Field(alias="fullName")
    first_name: Optional[StrictStr] = Field(default=None, alias="firstName")
    last_name: Optional[StrictStr] = Field(default=None, alias="lastName")
    username: Optional[StrictStr] = None
    display_username: StrictBool = Field(alias="displayUsername")
    email: StrictStr
    verified_email: StrictBool = Field(alias="verifiedEmail")
    iso_alpha2_code: Optional[StrictStr] = Field(default=None, alias="isoAlpha2Code")
    phone: Optional[StrictStr] = None
    verified_phone: StrictBool = Field(alias="verifiedPhone")
    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
    birthdate: Optional[date] = None
    age: Optional[StrictInt] = None
    hand: Optional[StrictStr] = None
    reliability_score: Optional[StrictInt] = Field(default=None, alias="reliabilityScore")
    image_url: Optional[StrictStr] = Field(default=None, alias="imageUrl")
    singles: Optional[Union[StrictFloat, StrictInt]] = None
    singles_verified: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="singlesVerified")
    singles_provisional: Optional[StrictBool] = Field(default=None, alias="singlesProvisional")
    doubles: Optional[Union[StrictFloat, StrictInt]] = None
    doubles_verified: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="doublesVerified")
    doubles_provisional: Optional[StrictBool] = Field(default=None, alias="doublesProvisional")
    default_rating: Optional[StrictStr] = Field(default=None, alias="defaultRating")
    registration_type: Optional[StrictStr] = Field(default=None, alias="registrationType")
    registered: StrictBool
    referral_code: Optional[StrictStr] = Field(default=None, alias="referralCode")
    sponsor: Optional[Sponsor] = None
    distance: Optional[StrictStr] = None
    distance_in_miles: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="distanceInMiles")
    enable_privacy: StrictBool = Field(alias="enablePrivacy")
    status: Optional[StrictStr] = None
    created: Optional[datetime] = None
    lucra_connected: Optional[StrictBool] = Field(default=None, alias="lucraConnected")
    singles_reliability: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="singlesReliability")
    doubles_reliability: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="doublesReliability")
    provisional_singles_rating: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="provisionalSinglesRating")
    provisional_doubles_rating: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="provisionalDoublesRating")
    location: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["id", "fullName", "firstName", "lastName", "username", "displayUsername", "email", "verifiedEmail", "isoAlpha2Code", "phone", "verifiedPhone", "shortAddress", "formattedAddress", "latitude", "longitude", "gender", "birthdate", "age", "hand", "reliabilityScore", "imageUrl", "singles", "singlesVerified", "singlesProvisional", "doubles", "doublesVerified", "doublesProvisional", "defaultRating", "registrationType", "registered", "referralCode", "sponsor", "distance", "distanceInMiles", "enablePrivacy", "status", "created", "lucraConnected", "singlesReliability", "doublesReliability", "provisionalSinglesRating", "provisionalDoublesRating", "location"]

    @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('default_rating')
    def default_rating_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['SINGLES', 'DOUBLES']):
            raise ValueError("must be one of enum values ('SINGLES', 'DOUBLES')")
        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 Player 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 sponsor
        if self.sponsor:
            _dict['sponsor'] = self.sponsor.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Player 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"),
            "email": obj.get("email"),
            "verifiedEmail": obj.get("verifiedEmail"),
            "isoAlpha2Code": obj.get("isoAlpha2Code"),
            "phone": obj.get("phone"),
            "verifiedPhone": obj.get("verifiedPhone"),
            "shortAddress": obj.get("shortAddress"),
            "formattedAddress": obj.get("formattedAddress"),
            "latitude": obj.get("latitude"),
            "longitude": obj.get("longitude"),
            "gender": obj.get("gender"),
            "birthdate": obj.get("birthdate"),
            "age": obj.get("age"),
            "hand": obj.get("hand"),
            "reliabilityScore": obj.get("reliabilityScore"),
            "imageUrl": obj.get("imageUrl"),
            "singles": obj.get("singles"),
            "singlesVerified": obj.get("singlesVerified"),
            "singlesProvisional": obj.get("singlesProvisional"),
            "doubles": obj.get("doubles"),
            "doublesVerified": obj.get("doublesVerified"),
            "doublesProvisional": obj.get("doublesProvisional"),
            "defaultRating": obj.get("defaultRating"),
            "registrationType": obj.get("registrationType"),
            "registered": obj.get("registered"),
            "referralCode": obj.get("referralCode"),
            "sponsor": Sponsor.from_dict(obj["sponsor"]) if obj.get("sponsor") is not None else None,
            "distance": obj.get("distance"),
            "distanceInMiles": obj.get("distanceInMiles"),
            "enablePrivacy": obj.get("enablePrivacy"),
            "status": obj.get("status"),
            "created": obj.get("created"),
            "lucraConnected": obj.get("lucraConnected"),
            "singlesReliability": obj.get("singlesReliability"),
            "doublesReliability": obj.get("doublesReliability"),
            "provisionalSinglesRating": obj.get("provisionalSinglesRating"),
            "provisionalDoublesRating": obj.get("provisionalDoublesRating"),
            "location": obj.get("location")
        })
        return _obj


