# coding: utf-8

"""
    Fastify Template API

    API documentation using Swagger

    The version of the OpenAPI document: 1.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, StrictFloat, StrictInt
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing import Optional, Set
from typing_extensions import Self

class RepdataSurveyFieldDetails(BaseModel):
    """
    RepdataSurveyFieldDetails
    """ # noqa: E501
    cost: Optional[Union[StrictFloat, StrictInt]] = None
    abandons: Optional[Union[StrictFloat, StrictInt]] = None
    entrants: Optional[Union[StrictFloat, StrictInt]] = None
    inflight: Optional[Union[StrictFloat, StrictInt]] = None
    completes: Optional[Union[StrictFloat, StrictInt]] = None
    final_cost: Optional[Union[StrictFloat, StrictInt]] = None
    accepted_cost: Optional[Union[StrictFloat, StrictInt]] = None
    rejected_cost: Optional[Union[StrictFloat, StrictInt]] = None
    incidence_rate: Optional[Union[StrictFloat, StrictInt]] = None
    final_completes: Optional[Union[StrictFloat, StrictInt]] = None
    accepted_completes: Optional[Union[StrictFloat, StrictInt]] = None
    quality_terminates: Optional[Union[StrictFloat, StrictInt]] = None
    rejected_completes: Optional[Union[StrictFloat, StrictInt]] = None
    defender_terminates: Optional[Union[StrictFloat, StrictInt]] = None
    length_of_interview: Optional[Union[StrictFloat, StrictInt]] = None
    standard_terminates: Optional[Union[StrictFloat, StrictInt]] = None
    overquota_terminates: Optional[Union[StrictFloat, StrictInt]] = None
    accepted_unregistered_cost: Optional[Union[StrictFloat, StrictInt]] = None
    accepted_unregistered_completes: Optional[Union[StrictFloat, StrictInt]] = None
    __properties: ClassVar[List[str]] = ["cost", "abandons", "entrants", "inflight", "completes", "final_cost", "accepted_cost", "rejected_cost", "incidence_rate", "final_completes", "accepted_completes", "quality_terminates", "rejected_completes", "defender_terminates", "length_of_interview", "standard_terminates", "overquota_terminates", "accepted_unregistered_cost", "accepted_unregistered_completes"]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "cost": obj.get("cost"),
            "abandons": obj.get("abandons"),
            "entrants": obj.get("entrants"),
            "inflight": obj.get("inflight"),
            "completes": obj.get("completes"),
            "final_cost": obj.get("final_cost"),
            "accepted_cost": obj.get("accepted_cost"),
            "rejected_cost": obj.get("rejected_cost"),
            "incidence_rate": obj.get("incidence_rate"),
            "final_completes": obj.get("final_completes"),
            "accepted_completes": obj.get("accepted_completes"),
            "quality_terminates": obj.get("quality_terminates"),
            "rejected_completes": obj.get("rejected_completes"),
            "defender_terminates": obj.get("defender_terminates"),
            "length_of_interview": obj.get("length_of_interview"),
            "standard_terminates": obj.get("standard_terminates"),
            "overquota_terminates": obj.get("overquota_terminates"),
            "accepted_unregistered_cost": obj.get("accepted_unregistered_cost"),
            "accepted_unregistered_completes": obj.get("accepted_unregistered_completes")
        })
        return _obj


