Redmine REST API client
![goreportcard](https://goreportcard.com/badge/github.com/1buran/redmine)
This is a lightweight Redmine API client.
Introduction
[!CAUTION]
I created it for my own personal use (while I was learning the Go language),
you probably shouldn't use it! At least until it ready for production: ver >= 1.0.
I wanted create something like TUI of Redmine, but when i dive into learning of TUI libs like bubbletea, i spent all my free time slots and this idea was on pause for a while...until once i needed
small lib to get all my time entries from redmine to build over this one some another cool TUI app.
So basically this lib, a Go module, used for scroll over all Redmine time entries.
Another functional will be added (maybe) later...
Installation
go get github.com/1buran/redmine
Usage
Supported Redmine types:
User
Project
TimeEntry
Issue
start := time.Date(2024, time.March, 1, 0, 0, 0, 0, time.UTC)
end := start.AddDate(0, 0, 30)
timeEntriesFilter := redmine.TimeEntriesFilter{
StartDate: start,
EndDate: end,
UserId: "1"
}
apiClient := redmine.CreateApiClient(
"https://example.com", "asdadwwefwefwf", true, timeEntriesFilter)
dataChan, errChan := redmine.Scroll[redmine.TimeEntries](apiClient)
for {
select {
case data, ok := <-dataChan:
if ok {
for _, t := range data.Items {
fmt.Printf("On %s user spent %.2f hours for %s\n", t.SpentOn, t.Hours, t.Comment)
}
continue
}
return
case err, ok := <-errChan:
if ok {
switch {
case errors.Is(err, redmine.ApiEndpointUrlFatalError):
fmt.Fatalf("redmine api url is malformed: %s", err)
case errors.Is(err, redmine.HttpError):
fmt.Println("http error: %s, retry...", err)
default:
fmt.Println("err: %s", err)
}
}
}
}
There are some custom error types, from low level to high level errors which are aggregates of first ones. Typically you should be expect only these high level errors in errChan:
JsonDecodeError
: errors related to unmarshaling redmine server responseIoReadError
: errors related to read input (io.ReadAll(body)
)HttpError
: errors related to network layer (http_client.Do(req)
)ApiEndpointUrlFatalError
: fatal errors that means that most probably
the url of redmine api is malformed or bogus, please check itApiNewRequestFatalError
: actually will not be thrown (see the comments in code)