from omnis_calls import sendResponse, sendError, sendEvent
from asyncio import sleep

def test(param, response):
    return sendResponse(
        {'unicode': 'Fingerspitzengef\xFChl is a German term.\nIt\u2019s pronounced as follows: [\u02C8f\u026A\u014B\u0250\u02CC\u0283p\u026Ats\u0259n\u0261\u0259\u02CCfy\u02D0l]'},
        response
    )

def test_params(param, response):
    program = param.get('program', 'unknown program')
    version = param.get('version', 'unknown version')

    return sendResponse(
        {'messageToShow': f'You are running {program} version {version}'},
        response
    )

def test_error(param, response):
    return sendError(
        "an error occurred in our module's method!",
        response,
        418
    )

async def test_event(param, response):
    for i in range(100):
        await sendEvent(
            {'loading_percent': i},
            response
        )
        await sleep(0.06)

