package infra

import "fmt"

// MetabaseListCards lista preguntas/cards de Metabase.
// filter: "all", "mine", "fav", "archived", "recent", "popular", "database", "table" (vacio = todas).
// modelID: ID de database o tabla cuando filter es "database" o "table" (0 = ignorar).
func MetabaseListCards(client MetabaseClient, filter string, modelID int) ([]map[string]any, error) {
	path := "/api/card"
	sep := "?"
	if filter != "" {
		path += sep + "f=" + filter
		sep = "&"
	}
	if modelID > 0 {
		path += fmt.Sprintf("%smodel_id=%d", sep, modelID)
	}

	result, err := metabaseRequestList("GET", client.BaseURL, client.Token, path, nil)
	if err != nil {
		return nil, fmt.Errorf("metabase list cards: %w", err)
	}

	return result, nil
}
