# -*- coding: utf-8 -*-
import asyncio
import datetime
import logging

from homehub_backend.lib.services import BaseService, ServiceData

LOGGER = logging.getLogger('homehub.fake_api_service')


class FakeAPIService(BaseService):
    KIND = 'FakeAPIService'

    def __init__(self, *args, **kwargs):
        super(FakeAPIService, self).__init__(*args, **kwargs)
        self.started_at = None

    async def current_data(self):
        result = ServiceData()
        if self.started_at:
            result.data = {
                'started_at': self.started_at.isoformat()
            }

        return result

    async def start(self):
        LOGGER.debug('FakeAPIService.start()')
        await asyncio.sleep(5)
        self.started_at = datetime.datetime.utcnow()

    async def stop(self):
        LOGGER.debug('FakeAPIService.stop()')
