# coding: utf-8

"""
    OSCR API

    OSCR API

    The version of the OpenAPI document: v1
    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 Any, Dict, Optional
from pydantic import BaseModel, Field, StrictInt, constr

class Metadata(BaseModel):
    """
    Metadata
    """
    id: Optional[StrictInt] = None
    map: constr(strict=True, min_length=1) = Field(...)
    difficulty: constr(strict=True, min_length=1) = Field(...)
    summary: Dict[str, Any] = Field(...)
    date_time: Optional[datetime] = None
    __properties = ["id", "map", "difficulty", "summary", "date_time"]

    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) -> Metadata:
        """Create an instance of Metadata 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={
                            "id",
                          },
                          exclude_none=True)
        # set to None if date_time (nullable) is None
        # and __fields_set__ contains the field
        if self.date_time is None and "date_time" in self.__fields_set__:
            _dict['date_time'] = None

        return _dict

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

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

        _obj = Metadata.parse_obj({
            "id": obj.get("id"),
            "map": obj.get("map"),
            "difficulty": obj.get("difficulty"),
            "summary": obj.get("summary"),
            "date_time": obj.get("date_time")
        })
        return _obj


