from easybill_client import EasybillWebhookParser


def handle_easybill_webhook(headers: dict[str, str], payload: dict, content_type: str) -> tuple[int, dict]:
    parser = EasybillWebhookParser()
    envelope = parser.parse(headers=headers, payload=payload, content_type=content_type)

    print(f"Received easybill event: {envelope.event} for resource {envelope.resource_id}")

    return 200, parser.build_acknowledgement()
