mirror of
https://github.com/foomo/go-clockify.git
synced 2025-10-16 12:35:40 +00:00
21 lines
560 B
Go
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)
|
|
}
|