package pretix

import (
	"fmt"
	"net/http"
	"strings"
)

func (s Server) buildURL(endpoint string, args ...any) string {
	baseURL := strings.TrimSuffix(s.config.BaseURL, "/")
	return fmt.Sprintf(endpoint, append([]any{baseURL}, args...)...)
}

func (s Server) doGetRequest(url string) (*http.Response, error) {
	req, err := http.NewRequest(http.MethodGet, url, nil)
	if err != nil {
		return nil, err
	}

	req.Header.Set("Accept", "application/json")
	req.Header.Set("Authorization", fmt.Sprint("Token ", s.config.APIToken))

	return s.client.Do(req)
}
