//! Lists endpoint definitions (15 endpoints).

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

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

use super::shared::{
    PARAM_EXPANSIONS, PARAM_ID, PARAM_LIST_FIELDS, PARAM_MAX_RESULTS, PARAM_PAGINATION_TOKEN,
    PARAM_TARGET_USER_ID, PARAM_TWEET_FIELDS, PARAM_USER_FIELDS, PARAM_USER_ID,
    WRITE_UP_AND_API_RO_AND_UTIL_WRITE, WRITE_UP_AND_UTIL_WRITE, X_READ_ERR, X_WRITE_ERR,
};

pub(super) static LIST_ENDPOINTS: &[EndpointDef] = &[
    // ── Lists (15) ─────────────────────────────────────────────────
    EndpointDef {
        tool_name: "x_v2_lists_get",
        description: "Look up a list by its ID",
        method: HttpMethod::Get,
        path: "/2/lists/{id}",
        category: ToolCategory::List,
        profiles: WRITE_UP_AND_API_RO_AND_UTIL_WRITE,
        scopes: &["list.read"],
        params: &[PARAM_ID, PARAM_LIST_FIELDS, PARAM_EXPANSIONS],
        error_codes: X_READ_ERR,
        api_version: "v2",
        group: "lists",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_lists_owned",
        description: "Get lists owned by a user",
        method: HttpMethod::Get,
        path: "/2/users/{user_id}/owned_lists",
        category: ToolCategory::List,
        profiles: WRITE_UP_AND_API_RO_AND_UTIL_WRITE,
        scopes: &["list.read", "users.read"],
        params: &[
            PARAM_USER_ID,
            PARAM_MAX_RESULTS,
            PARAM_PAGINATION_TOKEN,
            PARAM_LIST_FIELDS,
        ],
        error_codes: X_READ_ERR,
        api_version: "v2",
        group: "lists",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_lists_create",
        description: "Create a new list",
        method: HttpMethod::Post,
        path: "/2/lists",
        category: ToolCategory::List,
        profiles: WRITE_UP_AND_UTIL_WRITE,
        scopes: &["list.write"],
        params: &[
            ParamDef {
                name: "name",
                param_type: ParamType::String,
                required: true,
                description: "Name of the list (max 25 characters)",
                default: None,
            },
            ParamDef {
                name: "description",
                param_type: ParamType::String,
                required: false,
                description: "Description of the list (max 100 characters)",
                default: None,
            },
            ParamDef {
                name: "private",
                param_type: ParamType::Boolean,
                required: false,
                description: "Whether the list is private",
                default: Some("false"),
            },
        ],
        error_codes: X_WRITE_ERR,
        api_version: "v2",
        group: "lists",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_lists_update",
        description: "Update a list's name, description, or privacy setting",
        method: HttpMethod::Put,
        path: "/2/lists/{id}",
        category: ToolCategory::List,
        profiles: WRITE_UP_AND_UTIL_WRITE,
        scopes: &["list.write"],
        params: &[
            PARAM_ID,
            ParamDef {
                name: "name",
                param_type: ParamType::String,
                required: false,
                description: "New name for the list",
                default: None,
            },
            ParamDef {
                name: "description",
                param_type: ParamType::String,
                required: false,
                description: "New description for the list",
                default: None,
            },
            ParamDef {
                name: "private",
                param_type: ParamType::Boolean,
                required: false,
                description: "Whether the list is private",
                default: None,
            },
        ],
        error_codes: X_WRITE_ERR,
        api_version: "v2",
        group: "lists",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_lists_delete",
        description: "Delete a list you own",
        method: HttpMethod::Delete,
        path: "/2/lists/{id}",
        category: ToolCategory::List,
        profiles: WRITE_UP_AND_UTIL_WRITE,
        scopes: &["list.write"],
        params: &[PARAM_ID],
        error_codes: X_WRITE_ERR,
        api_version: "v2",
        group: "lists",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_lists_tweets",
        description: "Get tweets from a list's timeline",
        method: HttpMethod::Get,
        path: "/2/lists/{id}/tweets",
        category: ToolCategory::List,
        profiles: WRITE_UP_AND_API_RO_AND_UTIL_WRITE,
        scopes: &["list.read", "tweet.read", "users.read"],
        params: &[
            PARAM_ID,
            PARAM_MAX_RESULTS,
            PARAM_PAGINATION_TOKEN,
            PARAM_TWEET_FIELDS,
            PARAM_USER_FIELDS,
            PARAM_EXPANSIONS,
        ],
        error_codes: X_READ_ERR,
        api_version: "v2",
        group: "lists",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_lists_members",
        description: "Get members of a list",
        method: HttpMethod::Get,
        path: "/2/lists/{id}/members",
        category: ToolCategory::List,
        profiles: WRITE_UP_AND_API_RO_AND_UTIL_WRITE,
        scopes: &["list.read", "users.read"],
        params: &[
            PARAM_ID,
            PARAM_MAX_RESULTS,
            PARAM_PAGINATION_TOKEN,
            PARAM_USER_FIELDS,
        ],
        error_codes: X_READ_ERR,
        api_version: "v2",
        group: "lists",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_lists_members_add",
        description: "Add a user as a member of a list",
        method: HttpMethod::Post,
        path: "/2/lists/{id}/members",
        category: ToolCategory::List,
        profiles: WRITE_UP_AND_UTIL_WRITE,
        scopes: &["list.write", "users.read"],
        params: &[
            PARAM_ID,
            ParamDef {
                name: "user_id",
                param_type: ParamType::String,
                required: true,
                description: "User ID to add to the list",
                default: None,
            },
        ],
        error_codes: X_WRITE_ERR,
        api_version: "v2",
        group: "lists",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_lists_members_remove",
        description: "Remove a user from a list",
        method: HttpMethod::Delete,
        path: "/2/lists/{id}/members/{user_id}",
        category: ToolCategory::List,
        profiles: WRITE_UP_AND_UTIL_WRITE,
        scopes: &["list.write", "users.read"],
        params: &[PARAM_ID, PARAM_TARGET_USER_ID],
        error_codes: X_WRITE_ERR,
        api_version: "v2",
        group: "lists",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_lists_memberships",
        description: "Get lists a user is a member of",
        method: HttpMethod::Get,
        path: "/2/users/{user_id}/list_memberships",
        category: ToolCategory::List,
        profiles: WRITE_UP_AND_API_RO_AND_UTIL_WRITE,
        scopes: &["list.read", "users.read"],
        params: &[
            PARAM_USER_ID,
            PARAM_MAX_RESULTS,
            PARAM_PAGINATION_TOKEN,
            PARAM_LIST_FIELDS,
        ],
        error_codes: X_READ_ERR,
        api_version: "v2",
        group: "lists",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_lists_followers",
        description: "Get followers of a list",
        method: HttpMethod::Get,
        path: "/2/lists/{id}/followers",
        category: ToolCategory::List,
        profiles: WRITE_UP_AND_API_RO_AND_UTIL_WRITE,
        scopes: &["list.read", "users.read"],
        params: &[
            PARAM_ID,
            PARAM_MAX_RESULTS,
            PARAM_PAGINATION_TOKEN,
            PARAM_USER_FIELDS,
        ],
        error_codes: X_READ_ERR,
        api_version: "v2",
        group: "lists",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_lists_follow",
        description: "Follow a list",
        method: HttpMethod::Post,
        path: "/2/users/{user_id}/followed_lists",
        category: ToolCategory::List,
        profiles: WRITE_UP_AND_UTIL_WRITE,
        scopes: &["list.write", "users.read"],
        params: &[
            PARAM_USER_ID,
            ParamDef {
                name: "list_id",
                param_type: ParamType::String,
                required: true,
                description: "ID of the list to follow",
                default: None,
            },
        ],
        error_codes: X_WRITE_ERR,
        api_version: "v2",
        group: "lists",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_lists_unfollow",
        description: "Unfollow a list",
        method: HttpMethod::Delete,
        path: "/2/users/{user_id}/followed_lists/{list_id}",
        category: ToolCategory::List,
        profiles: WRITE_UP_AND_UTIL_WRITE,
        scopes: &["list.write", "users.read"],
        params: &[
            PARAM_USER_ID,
            ParamDef {
                name: "list_id",
                param_type: ParamType::String,
                required: true,
                description: "ID of the list to unfollow",
                default: None,
            },
        ],
        error_codes: X_WRITE_ERR,
        api_version: "v2",
        group: "lists",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_lists_pinned",
        description: "Get a user's pinned lists",
        method: HttpMethod::Get,
        path: "/2/users/{user_id}/pinned_lists",
        category: ToolCategory::List,
        profiles: WRITE_UP_AND_API_RO_AND_UTIL_WRITE,
        scopes: &["list.read", "users.read"],
        params: &[PARAM_USER_ID, PARAM_LIST_FIELDS],
        error_codes: X_READ_ERR,
        api_version: "v2",
        group: "lists",
        host: None,
    },
    EndpointDef {
        tool_name: "x_v2_lists_pin",
        description: "Pin a list",
        method: HttpMethod::Post,
        path: "/2/users/{user_id}/pinned_lists",
        category: ToolCategory::List,
        profiles: WRITE_UP_AND_UTIL_WRITE,
        scopes: &["list.write", "users.read"],
        params: &[
            PARAM_USER_ID,
            ParamDef {
                name: "list_id",
                param_type: ParamType::String,
                required: true,
                description: "ID of the list to pin",
                default: None,
            },
        ],
        error_codes: X_WRITE_ERR,
        api_version: "v2",
        group: "lists",
        host: None,
    },
];
