package infra

import "fmt"

// MetabaseUpdateCard actualiza campos de una card/pregunta en Metabase.
// fields es un map con los campos a actualizar.
// Campos comunes: name, description, display, dataset_query, visualization_settings,
// collection_id, archived, enable_embedding.
func MetabaseUpdateCard(client MetabaseClient, cardID int, fields map[string]any) (map[string]any, error) {
	path := fmt.Sprintf("/api/card/%d", cardID)

	result, err := metabaseRequest("PUT", client.BaseURL, client.Token, path, fields)
	if err != nil {
		return nil, fmt.Errorf("metabase update card %d: %w", cardID, err)
	}

	return result, nil
}
