# coding: utf-8

"""
    Tickcatcher API

    The Tickcatcher API provides access to cryptocurrency market data including candlesticks, symbols, and indicators. All requests require authentication using your RapidAPI key. 

    The version of the OpenAPI document: 1.1.3
    Contact: yagiz@iskirik.com
    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 Pivot200ResponseInner(BaseModel):
    """
    Pivot200ResponseInner
    """ # noqa: E501
    p: Optional[Union[StrictFloat, StrictInt]] = None
    r1: Optional[Union[StrictFloat, StrictInt]] = None
    s1: Optional[Union[StrictFloat, StrictInt]] = None
    r2: Optional[Union[StrictFloat, StrictInt]] = None
    s2: Optional[Union[StrictFloat, StrictInt]] = None
    r3: Optional[Union[StrictFloat, StrictInt]] = None
    s3: Optional[Union[StrictFloat, StrictInt]] = None
    __properties: ClassVar[List[str]] = ["p", "r1", "s1", "r2", "s2", "r3", "s3"]

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "p": obj.get("p"),
            "r1": obj.get("r1"),
            "s1": obj.get("s1"),
            "r2": obj.get("r2"),
            "s2": obj.get("s2"),
            "r3": obj.get("r3"),
            "s3": obj.get("s3")
        })
        return _obj


