# coding: utf-8

"""
    SRO Master API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 0.1.38
    Contact: info@nexium.me
    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
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class TariffEntry(BaseModel):
    """
    TariffEntry
    """ # noqa: E501
    insured_sum: Optional[Union[Annotated[float, Field(strict=True, ge=0.0)], Annotated[int, Field(strict=True, ge=0)]]] = None
    tariff: Optional[Union[Annotated[float, Field(strict=True, ge=0.0)], Annotated[int, Field(strict=True, ge=0)]]] = None
    tariff_default: Optional[Union[Annotated[float, Field(strict=True, ge=0.0)], Annotated[int, Field(strict=True, ge=0)]]] = None
    insurance_premium: Optional[Union[Annotated[float, Field(strict=True, ge=0.0)], Annotated[int, Field(strict=True, ge=0)]]] = None
    __properties: ClassVar[List[str]] = ["insured_sum", "tariff", "tariff_default", "insurance_premium"]

    model_config = ConfigDict(
        validate_by_name=True,
        validate_by_alias=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"""
        return json.dumps(to_jsonable_python(self.to_dict()))

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of TariffEntry 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 insured_sum (nullable) is None
        # and model_fields_set contains the field
        if self.insured_sum is None and "insured_sum" in self.model_fields_set:
            _dict['insured_sum'] = None

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "insured_sum": obj.get("insured_sum"),
            "tariff": obj.get("tariff"),
            "tariff_default": obj.get("tariff_default"),
            "insurance_premium": obj.get("insurance_premium")
        })
        return _obj


