mirror of
				https://github.com/interviewstreet/go-jira.git
				synced 2025-10-30 23:47:46 +02:00 
			
		
		
		
	Refactored struct types by reusing already existing components
This commit is contained in:
		
							
								
								
									
										97
									
								
								issue.go
									
									
									
									
									
								
							
							
						
						
									
										97
									
								
								issue.go
									
									
									
									
									
								
							| @@ -34,7 +34,7 @@ type Attachment struct { | ||||
| 	Self      string `json:"self,omitempty"` | ||||
| 	ID        string `json:"id,omitempty"` | ||||
| 	Filename  string `json:"filename,omitempty"` | ||||
| 	Author    *Assignee `json:"author,omitempty"` | ||||
| 	Author    *User  `json:"author,omitempty"` | ||||
| 	Created   string `json:"created,omitempty"` | ||||
| 	Size      int    `json:"size,omitempty"` | ||||
| 	MimeType  string `json:"mimeType,omitempty"` | ||||
| @@ -64,12 +64,12 @@ type IssueFields struct { | ||||
| 	Resolutiondate    string        `json:"resolutiondate,omitempty"` | ||||
| 	Created           string        `json:"created,omitempty"` | ||||
| 	Watches           *Watches      `json:"watches,omitempty"` | ||||
| 	Assignee          *Assignee     `json:"assignee,omitempty"` | ||||
| 	Assignee          *User         `json:"assignee,omitempty"` | ||||
| 	Updated           string        `json:"updated,omitempty"` | ||||
| 	Description       string        `json:"description,omitempty"` | ||||
| 	Summary           string        `json:"summary"` | ||||
| 	Creator           *Assignee     `json:"Creator,omitempty"` | ||||
| 	Reporter          *Assignee     `json:"reporter,omitempty"` | ||||
| 	Creator           *User         `json:"Creator,omitempty"` | ||||
| 	Reporter          *User         `json:"reporter,omitempty"` | ||||
| 	Components        []*Component  `json:"components,omitempty"` | ||||
| 	Status            *Status       `json:"status,omitempty"` | ||||
| 	Progress          *Progress     `json:"progress,omitempty"` | ||||
| @@ -92,6 +92,7 @@ type IssueType struct { | ||||
| 	IconURL     string `json:"iconUrl,omitempty"` | ||||
| 	Name        string `json:"name,omitempty"` | ||||
| 	Subtask     bool   `json:"subtask,omitempty"` | ||||
| 	AvatarID    int    `json:"avatarId,omitempty"` | ||||
| } | ||||
|  | ||||
| // Project represents a JIRA Project. | ||||
| @@ -129,13 +130,22 @@ type Watches struct { | ||||
| } | ||||
|  | ||||
| // Assignee represents a user who is this JIRA issue assigned to. | ||||
| type Assignee struct { | ||||
| type User struct { | ||||
| 	Self         string     `json:"self,omitempty"` | ||||
| 	Name         string     `json:"name,omitempty"` | ||||
| 	Key          string     `json:"key,omitempty"` | ||||
| 	EmailAddress string     `json:"emailAddress,omitempty"` | ||||
| 	AvatarURLs   map[string]string `json:"avatarUrls,omitempty"` | ||||
| 	AvatarUrls   AvatarUrls `json:"avatarUrls,omitempty"` | ||||
| 	DisplayName  string     `json:"displayName,omitempty"` | ||||
| 	Active       bool       `json:"active,omitempty"` | ||||
| 	TimeZone     string     `json:"timeZone,omitempty"` | ||||
| } | ||||
|  | ||||
| type AvatarUrls struct { | ||||
| 	Four8X48  string `json:"48x48,omitempty"` | ||||
| 	Two4X24   string `json:"24x24,omitempty"` | ||||
| 	One6X16   string `json:"16x16,omitempty"` | ||||
| 	Three2X32 string `json:"32x32,omitempty"` | ||||
| } | ||||
|  | ||||
| // Component represents a "component" of a JIRA issue. | ||||
| @@ -180,38 +190,13 @@ type Worklog struct { | ||||
| 	StartAt    int             `json:"startAt"` | ||||
| 	MaxResults int             `json:"maxResults"` | ||||
| 	Total      int             `json:"total"` | ||||
| 	Worklogs   []struct { | ||||
| 	Worklogs   []WorklogRecord `json:"worklogs"` | ||||
| } | ||||
|  | ||||
| type WorklogRecord struct { | ||||
| 	Self             string `json:"self"` | ||||
| 		Author struct { | ||||
| 			Self         string `json:"self"` | ||||
| 			Name         string `json:"name"` | ||||
| 			Key          string `json:"key"` | ||||
| 			EmailAddress string `json:"emailAddress"` | ||||
| 			AvatarUrls   struct { | ||||
| 				Four8X48  string `json:"48x48"` | ||||
| 				Two4X24   string `json:"24x24"` | ||||
| 				One6X16   string `json:"16x16"` | ||||
| 				Three2X32 string `json:"32x32"` | ||||
| 			} `json:"avatarUrls"` | ||||
| 			DisplayName string `json:"displayName"` | ||||
| 			Active      bool   `json:"active"` | ||||
| 			TimeZone    string `json:"timeZone"` | ||||
| 		} `json:"author"` | ||||
| 		UpdateAuthor struct { | ||||
| 			Self         string `json:"self"` | ||||
| 			Name         string `json:"name"` | ||||
| 			Key          string `json:"key"` | ||||
| 			EmailAddress string `json:"emailAddress"` | ||||
| 			AvatarUrls   struct { | ||||
| 				Four8X48  string `json:"48x48"` | ||||
| 				Two4X24   string `json:"24x24"` | ||||
| 				One6X16   string `json:"16x16"` | ||||
| 				Three2X32 string `json:"32x32"` | ||||
| 			} `json:"avatarUrls"` | ||||
| 			DisplayName string `json:"displayName"` | ||||
| 			Active      bool   `json:"active"` | ||||
| 			TimeZone    string `json:"timeZone"` | ||||
| 		} `json:"updateAuthor"` | ||||
| 	Author           User   `json:"author"` | ||||
| 	UpdateAuthor     User   `json:"updateAuthor"` | ||||
| 	Comment          string `json:"comment"` | ||||
| 	Created          string `json:"created"` | ||||
| 	Updated          string `json:"updated"` | ||||
| @@ -220,45 +205,13 @@ type Worklog struct { | ||||
| 	TimeSpentSeconds int    `json:"timeSpentSeconds"` | ||||
| 	ID               string `json:"id"` | ||||
| 	IssueID          string `json:"issueId"` | ||||
| 	} `json:"worklogs"` | ||||
| } | ||||
|  | ||||
| type Subtasks struct { | ||||
| 	ID     string      `json:"id"` | ||||
| 	Key    string      `json:"key"` | ||||
| 	Self   string      `json:"self"` | ||||
| 	Fields struct { | ||||
| 		Summary string `json:"summary"` | ||||
| 		Status  struct { | ||||
| 			Self           string `json:"self"` | ||||
| 			Description    string `json:"description"` | ||||
| 			IconURL        string `json:"iconUrl"` | ||||
| 			Name           string `json:"name"` | ||||
| 			ID             string `json:"id"` | ||||
| 			StatusCategory struct { | ||||
| 				Self      string `json:"self"` | ||||
| 				ID        int    `json:"id"` | ||||
| 				Key       string `json:"key"` | ||||
| 				ColorName string `json:"colorName"` | ||||
| 				Name      string `json:"name"` | ||||
| 			} `json:"statusCategory"` | ||||
| 		} `json:"status"` | ||||
| 		Priority struct { | ||||
| 			Self    string `json:"self"` | ||||
| 			IconURL string `json:"iconUrl"` | ||||
| 			Name    string `json:"name"` | ||||
| 			ID      string `json:"id"` | ||||
| 		} `json:"priority"` | ||||
| 		Issuetype struct { | ||||
| 			Self        string `json:"self"` | ||||
| 			ID          string `json:"id"` | ||||
| 			Description string `json:"description"` | ||||
| 			IconURL     string `json:"iconUrl"` | ||||
| 			Name        string `json:"name"` | ||||
| 			Subtask     bool   `json:"subtask"` | ||||
| 			AvatarID    int    `json:"avatarId"` | ||||
| 		} `json:"issuetype"` | ||||
| 	} `json:"fields"` | ||||
| 	Fields IssueFields `json:"fields"` | ||||
| } | ||||
|  | ||||
| // IssueLink represents a link between two issues in JIRA. | ||||
| @@ -285,9 +238,9 @@ type IssueLinkType struct { | ||||
| type Comment struct { | ||||
| 	Self         string            `json:"self,omitempty"` | ||||
| 	Name         string            `json:"name,omitempty"` | ||||
| 	Author       Assignee          `json:"author,omitempty"` | ||||
| 	Author       User              `json:"author,omitempty"` | ||||
| 	Body         string            `json:"body,omitempty"` | ||||
| 	UpdateAuthor Assignee          `json:"updateAuthor,omitempty"` | ||||
| 	UpdateAuthor User              `json:"updateAuthor,omitempty"` | ||||
| 	Updated      string            `json:"updated,omitempty"` | ||||
| 	Created      string            `json:"created,omitempty"` | ||||
| 	Visibility   CommentVisibility `json:"visibility,omitempty"` | ||||
|   | ||||
							
								
								
									
										105
									
								
								project.go
									
									
									
									
									
								
							
							
						
						
									
										105
									
								
								project.go
									
									
									
									
									
								
							| @@ -16,19 +16,16 @@ type ProjectList []struct { | ||||
| 	ID              string          `json:"id"` | ||||
| 	Key             string          `json:"key"` | ||||
| 	Name            string          `json:"name"` | ||||
| 	AvatarUrls struct { | ||||
| 		Four8X48  string `json:"48x48"` | ||||
| 		Two4X24   string `json:"24x24"` | ||||
| 		One6X16   string `json:"16x16"` | ||||
| 		Three2X32 string `json:"32x32"` | ||||
| 	} `json:"avatarUrls"` | ||||
| 	AvatarUrls      AvatarUrls      `json:"avatarUrls"` | ||||
| 	ProjectTypeKey  string          `json:"projectTypeKey"` | ||||
| 	ProjectCategory struct { | ||||
| 	ProjectCategory ProjectCategory `json:"projectCategory,omitempty"` | ||||
| } | ||||
|  | ||||
| type ProjectCategory struct { | ||||
| 	Self        string `json:"self"` | ||||
| 	ID          string `json:"id"` | ||||
| 	Name        string `json:"name"` | ||||
| 	Description string `json:"description"` | ||||
| 	} `json:"projectCategory,omitempty"` | ||||
| } | ||||
|  | ||||
| // Full project description | ||||
| @@ -39,74 +36,9 @@ type FullProject struct { | ||||
| 	ID           string             `json:"id"` | ||||
| 	Key          string             `json:"key"` | ||||
| 	Description  string             `json:"description"` | ||||
| 	Lead        struct { | ||||
| 		Self       string `json:"self"` | ||||
| 		Name       string `json:"name"` | ||||
| 		AvatarUrls struct { | ||||
| 			Four8X48  string `json:"48x48"` | ||||
| 			Two4X24   string `json:"24x24"` | ||||
| 			One6X16   string `json:"16x16"` | ||||
| 			Three2X32 string `json:"32x32"` | ||||
| 		} `json:"avatarUrls"` | ||||
| 		DisplayName string `json:"displayName"` | ||||
| 		Active      bool   `json:"active"` | ||||
| 	} `json:"lead"` | ||||
| 	Components []struct { | ||||
| 		Self        string `json:"self"` | ||||
| 		ID          string `json:"id"` | ||||
| 		Name        string `json:"name"` | ||||
| 		Description string `json:"description"` | ||||
| 		Lead        struct { | ||||
| 			Self       string `json:"self"` | ||||
| 			Name       string `json:"name"` | ||||
| 			AvatarUrls struct { | ||||
| 				Four8X48  string `json:"48x48"` | ||||
| 				Two4X24   string `json:"24x24"` | ||||
| 				One6X16   string `json:"16x16"` | ||||
| 				Three2X32 string `json:"32x32"` | ||||
| 			} `json:"avatarUrls"` | ||||
| 			DisplayName string `json:"displayName"` | ||||
| 			Active      bool   `json:"active"` | ||||
| 		} `json:"lead"` | ||||
| 		AssigneeType string `json:"assigneeType"` | ||||
| 		Assignee     struct { | ||||
| 			Self       string `json:"self"` | ||||
| 			Name       string `json:"name"` | ||||
| 			AvatarUrls struct { | ||||
| 				Four8X48  string `json:"48x48"` | ||||
| 				Two4X24   string `json:"24x24"` | ||||
| 				One6X16   string `json:"16x16"` | ||||
| 				Three2X32 string `json:"32x32"` | ||||
| 			} `json:"avatarUrls"` | ||||
| 			DisplayName string `json:"displayName"` | ||||
| 			Active      bool   `json:"active"` | ||||
| 		} `json:"assignee"` | ||||
| 		RealAssigneeType string `json:"realAssigneeType"` | ||||
| 		RealAssignee     struct { | ||||
| 			Self       string `json:"self"` | ||||
| 			Name       string `json:"name"` | ||||
| 			AvatarUrls struct { | ||||
| 				Four8X48  string `json:"48x48"` | ||||
| 				Two4X24   string `json:"24x24"` | ||||
| 				One6X16   string `json:"16x16"` | ||||
| 				Three2X32 string `json:"32x32"` | ||||
| 			} `json:"avatarUrls"` | ||||
| 			DisplayName string `json:"displayName"` | ||||
| 			Active      bool   `json:"active"` | ||||
| 		} `json:"realAssignee"` | ||||
| 		IsAssigneeTypeValid bool   `json:"isAssigneeTypeValid"` | ||||
| 		Project             string `json:"project"` | ||||
| 		ProjectID           int    `json:"projectId"` | ||||
| 	} `json:"components"` | ||||
| 	IssueTypes []struct { | ||||
| 		Self        string `json:"self"` | ||||
| 		ID          string `json:"id"` | ||||
| 		Description string `json:"description"` | ||||
| 		IconURL     string `json:"iconUrl"` | ||||
| 		Name        string `json:"name"` | ||||
| 		Subtask     bool   `json:"subtask"` | ||||
| 		AvatarID    int    `json:"avatarId"` | ||||
| 	} `json:"issueTypes"` | ||||
| 	Lead         User               `json:"lead"` | ||||
| 	Components   []ProjectComponent `json:"components"` | ||||
| 	IssueTypes   []IssueType        `json:"issueTypes"` | ||||
| 	URL          string             `json:"url"` | ||||
| 	Email        string             `json:"email"` | ||||
| 	AssigneeType string             `json:"assigneeType"` | ||||
| @@ -115,18 +47,23 @@ type FullProject struct { | ||||
| 	Roles        struct { | ||||
| 		Developers string `json:"Developers"` | ||||
| 	} `json:"roles"` | ||||
| 	AvatarUrls struct { | ||||
| 		Four8X48  string `json:"48x48"` | ||||
| 		Two4X24   string `json:"24x24"` | ||||
| 		One6X16   string `json:"16x16"` | ||||
| 		Three2X32 string `json:"32x32"` | ||||
| 	} `json:"avatarUrls"` | ||||
| 	ProjectCategory struct { | ||||
| 	AvatarUrls      AvatarUrls      `json:"avatarUrls"` | ||||
| 	ProjectCategory ProjectCategory `json:"projectCategory"` | ||||
| } | ||||
|  | ||||
| type ProjectComponent struct { | ||||
| 	Self                string `json:"self"` | ||||
| 	ID                  string `json:"id"` | ||||
| 	Name                string `json:"name"` | ||||
| 	Description         string `json:"description"` | ||||
| 	} `json:"projectCategory"` | ||||
| 	Lead                User   `json:"lead"` | ||||
| 	AssigneeType        string `json:"assigneeType"` | ||||
| 	Assignee            User   `json:"assignee"` | ||||
| 	RealAssigneeType    string `json:"realAssigneeType"` | ||||
| 	RealAssignee        User   `json:"realAssignee"` | ||||
| 	IsAssigneeTypeValid bool   `json:"isAssigneeTypeValid"` | ||||
| 	Project             string `json:"project"` | ||||
| 	ProjectID           int    `json:"projectId"` | ||||
| } | ||||
|  | ||||
| // Get all projects form jira | ||||
|   | ||||
		Reference in New Issue
	
	Block a user