-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjira.go
46 lines (34 loc) · 1.14 KB
/
jira.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
42
43
44
45
46
package main
import (
"github.com/andygrunwald/go-jira"
"os"
)
type Client jira.Client
func getJiraClient(login, token string) (*Client, error) {
tp := jira.BasicAuthTransport{
Username: login,
Password: token,
}
client, error := jira.NewClient(tp.Client(), os.Getenv("JIRA_URL"))
return (*Client)(client), error
}
func (c *Client) addWorkLog(issueId, description string, timeSpent int64, startTime jira.Time) (*jira.WorklogRecord, error) {
timeSpentSeconds := int(timeSpent)
worklogRecord := jira.WorklogRecord{
Comment: description,
Started: &startTime,
TimeSpentSeconds: timeSpentSeconds,
}
worklog, _, err := c.Issue.AddWorklogRecord(issueId, &worklogRecord)
return worklog, err
}
func (c *Client) updateWorkLog(issueId, description, worklogId string, timeSpent int64, startTime jira.Time) (*jira.WorklogRecord, error) {
timeSpentSeconds := int(timeSpent)
worklogRecord := jira.WorklogRecord{
Comment: description,
Started: &startTime,
TimeSpentSeconds: timeSpentSeconds,
}
worklog, _, err := c.Issue.UpdateWorklogRecord(issueId, worklogId, &worklogRecord)
return worklog, err
}