ticket-pimp/bot/controller/task.go

45 lines
841 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.additionalYT
projectID, err := yt.GetProjectIDByName("E")
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://mobmarlerino.youtrack.cloud/issue/%s", issue.Key)
return t, nil
}