from src.domain.connectors.catalog._base import (
    ConnectorActionDef,
    ConnectorChangelogEntry,
    ConnectorDef,
    ConnectorFieldDef,
)


CONNECTOR = ConnectorDef(
    key="accredible",
    name="Accredible",
    category="education",
    auth_type="api_key",
    version="01.00.00",
    client_side=False,
    icon="accredible",
    image_url=None,
    description="Issue and retrieve hosted digital certificates or badges through Accredible.",
    docs_url="https://docs.api.accredible.com/",
    config_fields=("api_base_url",),
    secret_fields=("api_key",),
    config_field_defs=(
        ConnectorFieldDef(
            key="api_base_url",
            label="API base URL",
            description="Optional Accredible API base URL; defaults to https://api.accredible.com/v1.",
        ),
    ),
    secret_field_defs=(
        ConnectorFieldDef(
            key="api_key",
            label="Accredible API key",
            description="Accredible API key. Keep it server-side.",
            required=True,
            input_type="password",
        ),
    ),
    actions=(
        ConnectorActionDef(
            key="create_credential",
            slug="accredible.create_credential",
            name="Issue digital credential",
            description="Issue a hosted certificate or badge for a completed achievement.",
            input_schema={
                "type": "object",
                "properties": {
                    "recipient": {"type": "object"},
                    "name": {"type": "string"},
                    "group_id": {"type": "integer"},
                    "group_name": {"type": "string"},
                    "description": {"type": "string"},
                    "issued_on": {"type": "string"},
                    "expired_on": {"type": "string"},
                    "course_link": {"type": "string"},
                    "custom_attributes": {"type": "object"},
                    "evidence_items": {"type": "array"},
                },
                "required": ["recipient", "name"],
                "additionalProperties": False,
            },
            required_capabilities=("integrations.execute",),
        ),
        ConnectorActionDef(
            key="get_credential",
            slug="accredible.get_credential",
            name="Get digital credential",
            description="Retrieve an issued Accredible credential and its hosted verification URL.",
            input_schema={
                "type": "object",
                "properties": {"credential_id": {"type": "string"}},
                "required": ["credential_id"],
                "additionalProperties": False,
            },
            required_capabilities=("integrations.execute",),
        ),
    ),
    changelog=(
        ConnectorChangelogEntry(
            version="01.00.00",
            date="2026-09-20",
            notes="Initial digital credential issuance and retrieval actions.",
        ),
    ),
)
