# Path: il2fb/ds/airbridge/json.py
# class JSONEncoder(_json.JSONEncoder):
#     def default(self, obj):
# def object_decoder(obj):


import abc
from typing import Any
from aiohttp import web
from il2fb.ds.airbridge import json



class RESTResponse(web.Response, abc.ABC):
    detail = None

    @property
    @abc.abstractmethod
    def status(self) -> int:
        """
        Status must be explicilty defined by subclasses.

        """

    def __init__(
        self,
        payload: dict=None,
        detail: Any=None,
        pretty: bool=False,
        content_type: str='application/json',
        charset: str='utf-8',
        **kwargs
    ):
        payload = payload if payload is not None else {}

        detail = detail if detail is not None else self.detail
        if detail:
            payload['detail'] = str(detail)

        indent = 2 if pretty else None

# Path: il2fb/ds/airbridge/json.py
# class JSONEncoder(_json.JSONEncoder):
#     def default(self, obj):
# def object_decoder(obj):


# Path: il2fb/ds/airbridge/api/http/responses/rest.py
import abc
from typing import Any
from aiohttp import web
from il2fb.ds.airbridge import json




class RESTResponse(web.Response, abc.ABC):
    detail = None

    @property
    @abc.abstractmethod
    def status(self) -> int:
        """
        Status must be explicilty defined by subclasses.

        """

    def __init__(
        self,
        payload: dict=None,
        detail: Any=None,
        pretty: bool=False,
        content_type: str='application/json',
        charset: str='utf-8',
        **kwargs
    ):
        payload = payload if payload is not None else {}

        detail = detail if detail is not None else self.detail
        if detail:
            payload['detail'] = str(detail)

        indent = 2 if pretty else None

        text = json.dumps(payload, indent=indent) + '\n'