45 lines
838 B
Go
45 lines
838 B
Go
package controller
|
|
|
|
import "fmt"
|
|
|
|
type Task struct {
|
|
Summary string
|
|
Description string
|
|
Creator string
|
|
CreatorLink string
|
|
|
|
Key string
|
|
URL string
|
|
}
|
|
|
|
func (wc *WorkflowController) NewTask(summ, desc, c, cLink string) *Task {
|
|
return &Task{
|
|
Summary: summ,
|
|
Description: desc,
|
|
Creator: c,
|
|
CreatorLink: cLink,
|
|
}
|
|
}
|
|
|
|
func (wc *WorkflowController) CreateTask(t *Task) (*Task, error) {
|
|
|
|
yt := wc.iYouTrack
|
|
|
|
projectID, err := yt.GetProjectIDByName("ETMD")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
t.Description += fmt.Sprintf("\n\n Created by: [%s](%s)", t.Creator, t.CreatorLink)
|
|
|
|
issue, err := yt.CreateIssue(projectID, t.Creator+" | "+t.Summary, t.Description)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
t.Key = issue.Key
|
|
t.URL = fmt.Sprintf("https://marlerino.youtrack.cloud/issue/%s", issue.Key)
|
|
|
|
return t, nil
|
|
}
|