# coding: utf-8

"""
Mozart platform API

API for interacting with the Mozart platform.

The version of the OpenAPI document: 0.2.0
Contact: support@bang-olufsen.dk
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
"""  # noqa: E501

from __future__ import annotations

import json
import pprint
import re  # noqa: F401
from typing import Optional, Union

try:
    from pydantic.v1 import (
        BaseModel,
        Field,
        StrictBool,
        StrictFloat,
        StrictInt,
        StrictStr,
        validator,
    )
except ImportError:
    from pydantic import (
        BaseModel,
        Field,
        StrictBool,
        StrictFloat,
        StrictInt,
        StrictStr,
        validator,
    )


class StandMovement(BaseModel):
    """
    StandMovement
    """

    angle: Optional[Union[StrictFloat, StrictInt]] = None
    ignore_endstop: Optional[StrictBool] = Field(default=None, alias="ignoreEndstop")
    stand_motion: Optional[StrictStr] = Field(default=None, alias="standMotion")
    __properties = ["angle", "ignoreEndstop", "standMotion"]

    @validator("stand_motion")
    def stand_motion_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in (
            "continuousCCW",
            "stepCCW",
            "stop",
            "stepCW",
            "continuousCW",
        ):
            raise ValueError(
                "must be one of enum values ('continuousCCW', 'stepCCW', 'stop', 'stepCW', 'continuousCW')"
            )
        return value

    class Config:
        """Pydantic configuration"""

        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> StandMovement:
        """Create an instance of StandMovement from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
        # set to None if angle (nullable) is None
        # and __fields_set__ contains the field
        if self.angle is None and "angle" in self.__fields_set__:
            _dict["angle"] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> StandMovement:
        """Create an instance of StandMovement from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return StandMovement.parse_obj(obj)

        _obj = StandMovement.parse_obj(
            {
                "angle": obj.get("angle"),
                "ignore_endstop": obj.get("ignoreEndstop"),
                "stand_motion": obj.get("standMotion"),
            }
        )
        return _obj
