# coding: utf-8

"""
    FlexPrice API

    FlexPrice API Service

    The version of the OpenAPI document: 1.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 pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from flexprice.models.types_window_size import TypesWindowSize
from typing import Optional, Set
from typing_extensions import Self

class DtoGetUsageByMeterRequest(BaseModel):
    """
    DtoGetUsageByMeterRequest
    """ # noqa: E501
    billing_anchor: Optional[StrictStr] = Field(default=None, description="BillingAnchor enables custom monthly billing periods for meter usage aggregation.  Usage guidelines: - Only effective when WindowSize = \"MONTH\" - For other window sizes (DAY, HOUR, WEEK), this field is ignored - When nil, uses standard calendar months (1st to 1st) - When provided, creates custom monthly periods (e.g., 5th to 5th)  Common use cases: - Subscription billing periods that don't align with calendar months - Customer-specific billing cycles (e.g., signed up on 15th) - Multi-tenant systems with different billing anchor dates  Example: If BillingAnchor = \"2024-03-05T14:30:45Z\" and WindowSize = \"MONTH\":   - March period: 2024-03-05 14:30:45 to 2024-04-05 14:30:45   - April period: 2024-04-05 14:30:45 to 2024-05-05 14:30:45")
    bucket_size: Optional[TypesWindowSize] = None
    customer_id: Optional[StrictStr] = None
    end_time: Optional[StrictStr] = None
    external_customer_id: Optional[StrictStr] = None
    filters: Optional[Dict[str, List[StrictStr]]] = None
    meter_id: StrictStr
    start_time: Optional[StrictStr] = None
    window_size: Optional[TypesWindowSize] = None
    __properties: ClassVar[List[str]] = ["billing_anchor", "bucket_size", "customer_id", "end_time", "external_customer_id", "filters", "meter_id", "start_time", "window_size"]

    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 DtoGetUsageByMeterRequest 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "billing_anchor": obj.get("billing_anchor"),
            "bucket_size": obj.get("bucket_size"),
            "customer_id": obj.get("customer_id"),
            "end_time": obj.get("end_time"),
            "external_customer_id": obj.get("external_customer_id"),
            "filters": obj.get("filters"),
            "meter_id": obj.get("meter_id"),
            "start_time": obj.get("start_time"),
            "window_size": obj.get("window_size")
        })
        return _obj


