from datetime import timedelta
from typing import Dict, Any

from temporalio import workflow

with workflow.unsafe.imports_passed_through():
    from .types import TeamCreatedInput


@workflow.defn(name="team_created_workflow")
class TeamCreatedWorkflow:
    """
    Workflow: process team creation by creating a KYC request in Odoo.
    """

    @workflow.run
    async def run(self, data: TeamCreatedInput) -> Dict[str, Any]:
        return await workflow.execute_activity(
            "create_kyc_in_odoo",
            data,
            schedule_to_close_timeout=timedelta(seconds=60),
            start_to_close_timeout=timedelta(seconds=30),
            retry_policy=workflow.RetryPolicy(
                maximum_attempts=5,
                initial_interval=timedelta(seconds=2),
                backoff_coefficient=2.0,
                maximum_interval=timedelta(seconds=30),
            ),
        )
