"""
Base for adapters in linger
"""

from LingerPlugin.LingerPlugin import LingerPlugin
from LingerPlugin.LingerItem import LingerItem

class LingerBaseAdapter(LingerItem):
    """Base adapter for linger"""
    def __init__(self, configuration):
        super(LingerBaseAdapter, self).__init__(configuration)

    def send_message(self, subject, text, **kwargs):
        """
        Generic sending a message via the adapter
        """
        self.logger.info("Sending message with subject:%s message text:%s", subject, text)

    def start(self):
        """
        Starting the work of the adapter
        """
        pass

    def stop(self):
        """
        Stopping the work of the adapter
        """
        pass

class LingerBaseAdapterFactory(LingerPlugin):
    """Base adapter factory for linger"""
    def __init__(self):
        super(LingerBaseAdapterFactory, self).__init__()
        self.item = LingerBaseAdapter


    def get_instance(self, configuration):
        """
        Returning the instance of the item generated by the factory
        """
        return self.item(configuration)

    def get_fields(self):
        fields, optional_fields = super(LingerBaseAdapterFactory, self).get_fields()
        return (fields, optional_fields)
