# Path: golem/core/responses/responses.py
# class MessageElement:
#     """
#     Base class for message elements.
#     """
#     def to_message(self, fbid):
#         return {"recipient": {"id": fbid}, "message": self.to_response()}
# 
#     def to_response(self):
#         pass
# 
#     def get_response_for(self, platform='fb'):
#         return str(self)  # TODO
# 
#     def set_message_tag(self, tag):
#         self.tag = tag
# 
#     def get_message_tag(self):
#         """
#         See https://developers.facebook.com/docs/messenger-platform/send-messages/message-tags
#         :return: FB message tag
#         """
#         if hasattr(self, "tag"):
#             return self.tag
#         return None
# 
#     def __str__(self):
#         return str(self.__dict__)
# 
#     def __repr__(self):
#         return str(self)
# 
# class GenericTemplateElement(MessageElement):
#     """
#     A horizontal card view with title, subtitle, image and buttons.
#     """
# 
#     def __init__(self, title, image_url=None, subtitle=None, item_url=None, buttons=None):
#         self.title = _ellipsize(str(title)) if title else None
#         self.subtitle = _ellipsize(str(subtitle)) if subtitle else None
#         self.image_url = image_url
#         self.item_url = item_url
#         self.buttons = buttons if buttons else []
# 
#     def to_response(self):
#         response = {
#             "title": self.title,
#             "image_url": self.image_url,
#             "subtitle": self.subtitle,
#             "item_url": self.item_url
#         }
#         if self.buttons:
#             response["buttons"] = [button.to_response() for button in self.buttons]
#         return response
# 
#     def __str__(self):
#         text = 'element: ' + self.title
#         if self.subtitle:
#             text += " (" + self.subtitle + ")"
#         for button in self.buttons:
#             text += "\n  " + str(button)
#         return text
# 
#     def add_button(self, button):
#         self.buttons.append(button)
#         return self


from typing import List
from golem.core.responses.responses import MessageElement, GenericTemplateElement



class ListTemplate(MessageElement):

    def __init__(self, is_compact=False, button=None):
        super().__init__()
        self.elements = []  # type: List[GenericTemplateElement]
        self.compact = is_compact
        self.button = button

    def add_element(self, element: GenericTemplateElement):
        self.elements.append(element)
        return self

    def create_element(self, **kwargs):

# Path: golem/core/responses/responses.py
# class MessageElement:
#     """
#     Base class for message elements.
#     """
#     def to_message(self, fbid):
#         return {"recipient": {"id": fbid}, "message": self.to_response()}
# 
#     def to_response(self):
#         pass
# 
#     def get_response_for(self, platform='fb'):
#         return str(self)  # TODO
# 
#     def set_message_tag(self, tag):
#         self.tag = tag
# 
#     def get_message_tag(self):
#         """
#         See https://developers.facebook.com/docs/messenger-platform/send-messages/message-tags
#         :return: FB message tag
#         """
#         if hasattr(self, "tag"):
#             return self.tag
#         return None
# 
#     def __str__(self):
#         return str(self.__dict__)
# 
#     def __repr__(self):
#         return str(self)
# 
# class GenericTemplateElement(MessageElement):
#     """
#     A horizontal card view with title, subtitle, image and buttons.
#     """
# 
#     def __init__(self, title, image_url=None, subtitle=None, item_url=None, buttons=None):
#         self.title = _ellipsize(str(title)) if title else None
#         self.subtitle = _ellipsize(str(subtitle)) if subtitle else None
#         self.image_url = image_url
#         self.item_url = item_url
#         self.buttons = buttons if buttons else []
# 
#     def to_response(self):
#         response = {
#             "title": self.title,
#             "image_url": self.image_url,
#             "subtitle": self.subtitle,
#             "item_url": self.item_url
#         }
#         if self.buttons:
#             response["buttons"] = [button.to_response() for button in self.buttons]
#         return response
# 
#     def __str__(self):
#         text = 'element: ' + self.title
#         if self.subtitle:
#             text += " (" + self.subtitle + ")"
#         for button in self.buttons:
#             text += "\n  " + str(button)
#         return text
# 
#     def add_button(self, button):
#         self.buttons.append(button)
#         return self


# Path: golem/core/responses/templates.py
from typing import List
from golem.core.responses.responses import MessageElement, GenericTemplateElement




class ListTemplate(MessageElement):

    def __init__(self, is_compact=False, button=None):
        super().__init__()
        self.elements = []  # type: List[GenericTemplateElement]
        self.compact = is_compact
        self.button = button

    def add_element(self, element: GenericTemplateElement):
        self.elements.append(element)
        return self

    def create_element(self, **kwargs):

        element = GenericTemplateElement(**kwargs)