import json
from datetime import datetime
from typing import Dict


class Layer:
    '''
    This class represents a single layer of the Multilayer Graph.

    :param layer_info: Information as dictionary to restore the layer object.
    '''

    def __init__(self, layer_info: Dict = None, from_db=False):
        if layer_info is not None:
            self.from_serializable_dict(layer_info, from_db)

    def to_serializable_dict(self, for_db=False) -> Dict:
        return {
            "layer_name": self.layer_name,
            "properties": self.properties
        }

    def from_serializable_dict(self, layer_info: Dict, from_db=False):
        self.layer_name = layer_info['layer_name']
        self.properties = layer_info['properties']

    def __repr__(self):
        return json.dumps(self.to_serializable_dict())

    def __str__(self):
        return f"Layer({self.__repr__()})"
