# coding: utf-8

"""
    Mentortools Access Server

    Mentortools service for Access Packages with lazy access resolution

    The version of the OpenAPI document: 0.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 typing import Optional
from pydantic import BaseModel, StrictInt, StrictStr

class EventSubscription(BaseModel):
    """
    EventSubscription
    """
    external_subscription_id: Optional[StrictStr] = None
    current_period_end: Optional[StrictInt] = None
    grace_until: Optional[StrictInt] = None
    __properties = ["external_subscription_id", "current_period_end", "grace_until"]

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

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

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

        return _dict

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

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

        _obj = EventSubscription.parse_obj({
            "external_subscription_id": obj.get("external_subscription_id"),
            "current_period_end": obj.get("current_period_end"),
            "grace_until": obj.get("grace_until")
        })
        return _obj


