//! Compliance and Stream Rules endpoint definitions (7 endpoints).

use crate::tools::manifest::ToolCategory;

use crate::spec::params::{EndpointDef, HttpMethod, ParamDef, ParamType};

use super::shared::{
    ADMIN_ONLY, PARAM_COMPLIANCE_STATUS, PARAM_COMPLIANCE_TYPE, PARAM_ID, PARAM_STREAM_RULE_IDS,
    PARAM_STREAM_RULE_TAG, PARAM_STREAM_RULE_VALUE, PARAM_USAGE_DAYS, X_READ_ERR, X_WRITE_ERR,
};

pub(super) static COMPLIANCE_ENDPOINTS: &[EndpointDef] = &[
    // ── Compliance (4) ────────────────────────────────────────────────
    EndpointDef {
        tool_name: "x_v2_compliance_jobs",
        description: "List compliance jobs for GDPR and data deletion tracking",
        method: HttpMethod::Get,
        path: "/2/compliance/jobs",
        category: ToolCategory::Compliance,
        profiles: ADMIN_ONLY,
        scopes: &["compliance.write"],
        params: &[PARAM_COMPLIANCE_TYPE, PARAM_COMPLIANCE_STATUS],
        error_codes: X_READ_ERR,
        api_version: "v2",
        group: "compliance",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_compliance_job_by_id",
        description: "Get a single compliance job by ID",
        method: HttpMethod::Get,
        path: "/2/compliance/jobs/{id}",
        category: ToolCategory::Compliance,
        profiles: ADMIN_ONLY,
        scopes: &["compliance.write"],
        params: &[PARAM_ID],
        error_codes: X_READ_ERR,
        api_version: "v2",
        group: "compliance",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_compliance_job_create",
        description: "Create a new compliance job for batch user or tweet lookups",
        method: HttpMethod::Post,
        path: "/2/compliance/jobs",
        category: ToolCategory::Compliance,
        profiles: ADMIN_ONLY,
        scopes: &["compliance.write"],
        params: &[
            PARAM_COMPLIANCE_TYPE,
            ParamDef {
                name: "name",
                param_type: ParamType::String,
                required: false,
                description: "Optional human-readable name for the compliance job",
                default: None,
            },
            ParamDef {
                name: "resumable",
                param_type: ParamType::Boolean,
                required: false,
                description: "Whether the job should be resumable (default: false)",
                default: Some("false"),
            },
        ],
        error_codes: X_WRITE_ERR,
        api_version: "v2",
        group: "compliance",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_usage_tweets",
        description: "Get tweet usage data for the authenticated app (cap consumption)",
        method: HttpMethod::Get,
        path: "/2/usage/tweets",
        category: ToolCategory::Compliance,
        profiles: ADMIN_ONLY,
        scopes: &["usage.read"],
        params: &[PARAM_USAGE_DAYS],
        error_codes: X_READ_ERR,
        api_version: "v2",
        group: "compliance",
        host: None,
    },
    // ── Stream Rules (3) ──────────────────────────────────────────────
    EndpointDef {
        tool_name: "x_v2_stream_rules_list",
        description: "List active filtered stream rules",
        method: HttpMethod::Get,
        path: "/2/tweets/search/stream/rules",
        category: ToolCategory::Compliance,
        profiles: ADMIN_ONLY,
        scopes: &["tweet.read"],
        params: &[],
        error_codes: X_READ_ERR,
        api_version: "v2",
        group: "compliance",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_stream_rules_add",
        description: "Add rules to the filtered stream (max 25 rules per request)",
        method: HttpMethod::Post,
        path: "/2/tweets/search/stream/rules",
        category: ToolCategory::Compliance,
        profiles: ADMIN_ONLY,
        scopes: &["tweet.read"],
        params: &[PARAM_STREAM_RULE_VALUE, PARAM_STREAM_RULE_TAG],
        error_codes: X_WRITE_ERR,
        api_version: "v2",
        group: "compliance",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_stream_rules_delete",
        description: "Delete rules from the filtered stream by rule IDs",
        method: HttpMethod::Post,
        path: "/2/tweets/search/stream/rules",
        category: ToolCategory::Compliance,
        profiles: ADMIN_ONLY,
        scopes: &["tweet.read"],
        params: &[PARAM_STREAM_RULE_IDS],
        error_codes: X_WRITE_ERR,
        api_version: "v2",
        group: "compliance",
        host: None,
    },
];
