go-clockify/pkg/clockify/client.go
2025-01-13 16:14:42 +01:00

21 lines
560 B
Go

package clockify
import (
"context"
"net/http"
)
func NewClockifyClientWithBaseURL(baseURL string, token string) (*ClientWithResponses, error) {
hc := http.Client{}
var authInjection RequestEditorFn = func(ctx context.Context, req *http.Request) error {
req.Header.Add("X-Api-Key", token)
return nil
}
return NewClientWithResponses(baseURL, WithHTTPClient(&hc), WithRequestEditorFn(authInjection))
}
func NewClockifyClient(token string) (*ClientWithResponses, error) {
return NewClockifyClientWithBaseURL("https://api.clockify.me/api", token)
}