Setup domain method to get ID by Project Name
This commit is contained in:
parent
2cba8c5c26
commit
0d48ccedb9
|
|
@ -1,5 +1,7 @@
|
||||||
package domain
|
package domain
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
type Project struct {
|
type Project struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
ShortName string `json:"shortName"`
|
ShortName string `json:"shortName"`
|
||||||
|
|
@ -10,6 +12,23 @@ type ProjectID struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Find needed project.ID in the project's list
|
||||||
|
func (plist *ProjectsList) FindProjectByName(searchName string) (string, error) {
|
||||||
|
|
||||||
|
projectID := ""
|
||||||
|
|
||||||
|
for _, elem := range plist.Projects {
|
||||||
|
if elem.ShortName == searchName {
|
||||||
|
projectID = elem.ID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if projectID == "" {
|
||||||
|
return "", fmt.Errorf("project %s doesn't exist", searchName)
|
||||||
|
}
|
||||||
|
return projectID, nil
|
||||||
|
}
|
||||||
|
|
||||||
type IssueCreateRequest struct {
|
type IssueCreateRequest struct {
|
||||||
ProjectID ProjectID `json:"project"`
|
ProjectID ProjectID `json:"project"`
|
||||||
Key string `json:"idReadable"`
|
Key string `json:"idReadable"`
|
||||||
|
|
@ -30,3 +49,7 @@ type CustomField struct {
|
||||||
Type string `json:"$type"`
|
Type string `json:"$type"`
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ProjectsList struct {
|
||||||
|
Projects []Project
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue