This is a breaking change that modifies the return type of fetchActivities() so that instead of returning a map[int]string that maps an ID with the name of the activity with such ID, it returns a map[uint]remoteActivityType. remoteActivityType is a remote activity and it holds more than just the activity name, it also includes two extra fields exposed by the API: * IsDefault (is_default): the enumerator value can be used as default when not given (i.e., default issue type, default activity type...) * Active (active): the enumerator value can be used for new entries. The ID type has changed from int to uint following the efforts of coalescing all remote identifiers to uint. The activities subcommand now outputs all the fields of the enumerator.
34 lines
737 B
Go
34 lines
737 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
)
|
|
|
|
type remoteTimeEntry struct {
|
|
IssueId int `json:"issue_id"`
|
|
SpentOn string `json:"spent_on"`
|
|
Hours float64 `json:"hours"`
|
|
ActivityId uint `json:"activity_id"`
|
|
Comments string `json:"comments"`
|
|
}
|
|
|
|
type remoteTimeEntryPayload struct {
|
|
TimeEntry remoteTimeEntry `json:"time_entry"`
|
|
}
|
|
|
|
func (ctx *redmineClient) pushActivity(entry *remoteTimeEntry) error {
|
|
payload := &remoteTimeEntryPayload{TimeEntry: *entry}
|
|
jsonBody, err := json.Marshal(&payload)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
reader := bytes.NewReader(jsonBody)
|
|
req, err := ctx.buildPostRequest("time_entries", reader)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = ctx.secureCreate(req)
|
|
return err
|
|
}
|