# coding: utf-8

"""
    Gigs Core API

    API to manage voice & data plans for smartphones, wearables and IoT in 200+ countries.  # noqa: E501

    The version of the OpenAPI document: 0.0.1
    Contact: support@gigs.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


from __future__ import annotations
import pprint
import re  # noqa: F401
import json


from typing import Any, Optional
from pydantic import BaseModel, Field

class UsageRecord(BaseModel):
    """
    UsageRecord
    """
    object: Optional[Any] = Field(..., description="Type of object is always `usageRecord`.")
    start: Optional[Any] = Field(..., description="Timestamp representing the inclusive lower bound of the aggregation period (e.g. the start of a 24 hour period, subscription period or user-defined set of dates)")
    end: Optional[Any] = Field(..., description="Timestamp representing the exclusive upper bound of the aggregation period (e.g. the end of a 24 hour period, subscription period or user-defined set of dates).")
    data: Optional[Any] = Field(..., description="Amount of data used in bytes.")
    voice: Optional[Any] = Field(..., description="Amount of voice usage in seconds.")
    sms: Optional[Any] = Field(..., description="Amount of SMS sent and received.")
    __properties = ["object", "start", "end", "data", "voice", "sms"]

    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) -> UsageRecord:
        """Create an instance of UsageRecord 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 object (nullable) is None
        # and __fields_set__ contains the field
        if self.object is None and "object" in self.__fields_set__:
            _dict['object'] = None

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

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

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

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

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

        return _dict

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

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

        _obj = UsageRecord.parse_obj({
            "object": obj.get("object"),
            "start": obj.get("start"),
            "end": obj.get("end"),
            "data": obj.get("data"),
            "voice": obj.get("voice"),
            "sms": obj.get("sms")
        })
        return _obj

