-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostdata.go
41 lines (32 loc) · 969 Bytes
/
postdata.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package redmine
import (
"net/url"
)
// POST /time_entries params
type PostTimeEntryParams struct {
Payload CreateTimeEntryPayload `json:"time_entry"`
}
func (t PostTimeEntryParams) Validate() error { return t.Payload.Validate() }
func (t PostTimeEntryParams) Url(base string) (string, error) {
return url.JoinPath(base, TimeEntriesEndpoint)
}
func NewPostTimeEntryParams() *PostTimeEntryParams {
return &PostTimeEntryParams{}
}
// POST /issues params
type PostDataIssue struct {
Payload CreateIssuePayload `json:"issue"`
}
func NewPostIssueParams() *PostDataIssue {
return &PostDataIssue{}
}
func (i PostDataIssue) Validate() error { return i.Payload.Validate() }
func (i PostDataIssue) Url(base string) (string, error) {
return url.JoinPath(base, IssuesApiEndpoint)
}
// PostData is a generic container for payloads of API endpoints.
type PostData interface {
PostTimeEntryParams | PostDataIssue
Validate() error
Url(base string) (string, error)
}