# Path: minette/serializer.py
# def dumps(obj, **kwargs):
#     """
#     Encode object/dict to JSON
# 
#     Parameters
#     ----------
#     obj : object
#         Object to encode
# 
#     Returns
#     -------
#     s : str
#         JSON string
#     """
#     if obj is None:
#         return ""
#     d = dumpd(obj)
#     return json.dumps(d, default=_encode_datetime, **kwargs)


from abc import ABC, abstractmethod
from logging import getLogger
from pytz import timezone as tz
from ..serializer import dumps
            return True
        else:
            return False

    def _flatten(self, request, response, context):
        return {
            # request
            "channel": request.channel,
            "channel_detail": request.channel_detail,
            "channel_user_id": request.channel_user_id,
            "request_timestamp": request.timestamp,
            "request_id": request.id,
            "request_type": request.type,
            "request_text": request.text,
            "request_payloads": dumps(
                [p.to_dict() for p in request.payloads]),
            "request_intent": request.intent,
            "request_is_adhoc": request.is_adhoc,
            # response
            "response_type": response.messages[0].type if response.messages else "",
            "response_text": response.messages[0].text if response.messages else "",
            "response_payloads": dumps([p.to_dict() for p in response.messages[0].payloads]) if response.messages else "",
            "response_milliseconds": response.performance.milliseconds,
            # context
            "context_is_new": context.is_new,
            "context_topic_name": context.topic.name,
            "context_topic_status": context.topic.status,
            "context_topic_is_new": context.topic.is_new,
            "context_topic_keep_on": context.topic.keep_on,
            "context_topic_priority": context.topic.priority,

# Path: minette/serializer.py
# def dumps(obj, **kwargs):
#     """
#     Encode object/dict to JSON
# 
#     Parameters
#     ----------
#     obj : object
#         Object to encode
# 
#     Returns
#     -------
#     s : str
#         JSON string
#     """
#     if obj is None:
#         return ""
#     d = dumpd(obj)
#     return json.dumps(d, default=_encode_datetime, **kwargs)


# Path: minette/datastore/messagelogstore.py
from abc import ABC, abstractmethod
from logging import getLogger
from pytz import timezone as tz
from ..serializer import dumps

            return True
        else:
            return False

    def _flatten(self, request, response, context):
        return {
            # request
            "channel": request.channel,
            "channel_detail": request.channel_detail,
            "channel_user_id": request.channel_user_id,
            "request_timestamp": request.timestamp,
            "request_id": request.id,
            "request_type": request.type,
            "request_text": request.text,
            "request_payloads": dumps(
                [p.to_dict() for p in request.payloads]),
            "request_intent": request.intent,
            "request_is_adhoc": request.is_adhoc,
            # response
            "response_type": response.messages[0].type if response.messages else "",
            "response_text": response.messages[0].text if response.messages else "",
            "response_payloads": dumps([p.to_dict() for p in response.messages[0].payloads]) if response.messages else "",
            "response_milliseconds": response.performance.milliseconds,
            # context
            "context_is_new": context.is_new,
            "context_topic_name": context.topic.name,
            "context_topic_status": context.topic.status,
            "context_topic_is_new": context.topic.is_new,
            "context_topic_keep_on": context.topic.keep_on,
            "context_topic_priority": context.topic.priority,

            "context_error": dumps(context.error),