campaigner/model/ticket.go
2020-09-24 13:42:05 +02:00

38 lines
1.1 KiB
Go

package model
import (
"fmt"
)
type Ticket struct {
GithubLink int `json:"github_link,omitempty"`
GithubStatus string `json:"github_status,omitempty"`
GithubAssignee string `json:"github_assignee,omitempty"`
JiraLink string `json:"jira_link,omitempty"`
JiraStatus string `json:"jira_status,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Data map[string]interface{} `json:"data,omitempty"`
}
func (t *Ticket) IsPublishedJira() bool {
return t.JiraLink != ""
}
func (t *Ticket) IsPublishedGithub() bool {
return t.IsPublishedJira() && t.GithubLink != 0
}
func (t *Ticket) IsAssigned() bool {
return t.IsPublishedGithub() && t.GithubAssignee != "" && t.GithubStatus == "open"
}
func (t *Ticket) IsClosed() bool {
return t.IsPublishedGithub() && t.GithubAssignee != "" && t.GithubStatus == "closed"
}
func (t *Ticket) PrintStatus() {
if t.Summary != "" {
fmt.Printf("[%s] %s\n", t.JiraLink, t.Summary)
}
}