# coding: utf-8

"""
    AI Decision Protocol

    AI Decision Protocol Specification

    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 typing import List, Optional, Union
from pydantic import BaseModel, Field, StrictInt, StrictStr, confloat, conint, conlist
from aitp.stubs.models.decision_option_variant import DecisionOptionVariant
from aitp.stubs.models.quote import Quote

class DecisionOption(BaseModel):
    """
    DecisionOption
    """
    id: StrictStr = Field(...)
    name: Optional[StrictStr] = None
    short_variant_name: Optional[StrictStr] = None
    image_url: Optional[StrictStr] = None
    description: Optional[StrictStr] = None
    quote: Optional[Quote] = None
    reviews_count: Optional[StrictInt] = None
    five_star_rating: Optional[Union[confloat(le=5, ge=0, strict=True), conint(le=5, ge=0, strict=True)]] = None
    url: Optional[StrictStr] = None
    variants: Optional[conlist(DecisionOptionVariant)] = None
    additional_properties: Dict[str, Any] = {}
    __properties = ["id", "name", "short_variant_name", "image_url", "description", "quote", "reviews_count", "five_star_rating", "url", "variants"]

    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) -> DecisionOption:
        """Create an instance of DecisionOption 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={
                            "additional_properties"
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of quote
        if self.quote:
            _dict['quote'] = self.quote.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in variants (list)
        _items = []
        if self.variants:
            for _item in self.variants:
                if _item:
                    _items.append(_item.to_dict())
            _dict['variants'] = _items
        # puts key-value pairs in additional_properties in the top level
        if self.additional_properties is not None:
            for _key, _value in self.additional_properties.items():
                _dict[_key] = _value

        return _dict

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

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

        _obj = DecisionOption.parse_obj({
            "id": obj.get("id"),
            "name": obj.get("name"),
            "short_variant_name": obj.get("short_variant_name"),
            "image_url": obj.get("image_url"),
            "description": obj.get("description"),
            "quote": Quote.from_dict(obj.get("quote")) if obj.get("quote") is not None else None,
            "reviews_count": obj.get("reviews_count"),
            "five_star_rating": obj.get("five_star_rating"),
            "url": obj.get("url"),
            "variants": [DecisionOptionVariant.from_dict(_item) for _item in obj.get("variants")] if obj.get("variants") is not None else None
        })
        # store additional fields in additional_properties
        for _key in obj.keys():
            if _key not in cls.__properties:
                _obj.additional_properties[_key] = obj.get(_key)

        return _obj


