# coding: utf-8

"""
    Platform API

    _OpenAPI specification for the **Platform API** of **Empire**, the allocation and nomination platform of BritNed_  ---  Additional documentation available in the API's [GitHub repository](https://github.com/britned/empire-platform-api) 

    The version of the OpenAPI document: 6.0.2
    Contact: britned.info@britned.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 datetime import datetime
from typing import Optional, Union
from pydantic import BaseModel, Field, StrictBool, StrictInt, confloat, conint
from empire_platform_api_public_client_legacy.models.buy_now_offer_mtu_status import BuyNowOfferMtuStatus
from empire_platform_api_public_client_legacy.models.date_time_period import DateTimePeriod

class BuyNowOfferMtus(BaseModel):
    """
    BuyNowOfferMtus
    """
    mtu: datetime = Field(default=..., description="The first moment (inclusive) of an MTU period  - theoretically can be sent and received with any zone offset (until it marks the desired **absolute MTU start point** on the timeline) - in practice it is advised to transfer it in UTC timezone (with Z offset, \"Zulu time\") - ISO 8601 compliant string in `yyyy-mm-ddThh:mm:ss.SSSZ` format - only with `XX:00:00`, `XX:15:00`, `XX:30:00` and `XX:45:00` time parts are valid values (depending on MTU size) ")
    validity_period: Optional[DateTimePeriod] = Field(default=None, alias="validityPeriod")
    locked: StrictBool = Field(...)
    current_price: Union[confloat(multiple_of=0.01, strict=True), conint(strict=True)] = Field(default=..., alias="currentPrice", description="Currency value in Euros (€), accepted with a precision of maximum 2 decimal places")
    next_price: Optional[Union[confloat(multiple_of=0.01, strict=True), conint(strict=True)]] = Field(default=None, alias="nextPrice", description="Currency value in Euros (€), accepted with a precision of maximum 2 decimal places")
    oc: StrictInt = Field(default=..., description="Capacity value in kilowatts (kW) - the required system precision allows for handling capacity values as integers")
    status: BuyNowOfferMtuStatus = Field(...)
    allocated_ac: StrictInt = Field(default=..., alias="allocatedAc", description="Capacity value in kilowatts (kW) - the required system precision allows for handling capacity values as integers")
    participant_count: Optional[conint(strict=True, ge=0)] = Field(default=None, alias="participantCount", description="Natural numbers {0, 1, 2, 3, ...} used for counting elements")
    total_price: Union[confloat(multiple_of=0.01, strict=True), conint(strict=True)] = Field(default=..., alias="totalPrice", description="Currency value in Euros (€), accepted with a precision of maximum 2 decimal places")
    expired_oc: Optional[StrictInt] = Field(default=None, alias="expiredOc", description="Capacity value in kilowatts (kW) - the required system precision allows for handling capacity values as integers")
    __properties = ["mtu", "validityPeriod", "locked", "currentPrice", "nextPrice", "oc", "status", "allocatedAc", "participantCount", "totalPrice", "expiredOc"]

    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) -> BuyNowOfferMtus:
        """Create an instance of BuyNowOfferMtus 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)
        # override the default output from pydantic by calling `to_dict()` of validity_period
        if self.validity_period:
            _dict['validityPeriod'] = self.validity_period.to_dict()
        return _dict

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

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

        _obj = BuyNowOfferMtus.parse_obj({
            "mtu": obj.get("mtu"),
            "validity_period": DateTimePeriod.from_dict(obj.get("validityPeriod")) if obj.get("validityPeriod") is not None else None,
            "locked": obj.get("locked"),
            "current_price": obj.get("currentPrice"),
            "next_price": obj.get("nextPrice"),
            "oc": obj.get("oc"),
            "status": obj.get("status"),
            "allocated_ac": obj.get("allocatedAc"),
            "participant_count": obj.get("participantCount"),
            "total_price": obj.get("totalPrice"),
            "expired_oc": obj.get("expiredOc")
        })
        return _obj


