1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2025-04-25 12:14:56 +02:00

Refactored struct types by reusing already existing components

This commit is contained in:
Andy Grunwald 2016-06-03 23:14:27 +02:00
parent 077933ab00
commit 883aca79c0
3 changed files with 102 additions and 212 deletions

View File

@ -34,7 +34,7 @@ type Attachment struct {
Self string `json:"self,omitempty"` Self string `json:"self,omitempty"`
ID string `json:"id,omitempty"` ID string `json:"id,omitempty"`
Filename string `json:"filename,omitempty"` Filename string `json:"filename,omitempty"`
Author *Assignee `json:"author,omitempty"` Author *User `json:"author,omitempty"`
Created string `json:"created,omitempty"` Created string `json:"created,omitempty"`
Size int `json:"size,omitempty"` Size int `json:"size,omitempty"`
MimeType string `json:"mimeType,omitempty"` MimeType string `json:"mimeType,omitempty"`
@ -64,12 +64,12 @@ type IssueFields struct {
Resolutiondate string `json:"resolutiondate,omitempty"` Resolutiondate string `json:"resolutiondate,omitempty"`
Created string `json:"created,omitempty"` Created string `json:"created,omitempty"`
Watches *Watches `json:"watches,omitempty"` Watches *Watches `json:"watches,omitempty"`
Assignee *Assignee `json:"assignee,omitempty"` Assignee *User `json:"assignee,omitempty"`
Updated string `json:"updated,omitempty"` Updated string `json:"updated,omitempty"`
Description string `json:"description,omitempty"` Description string `json:"description,omitempty"`
Summary string `json:"summary"` Summary string `json:"summary"`
Creator *Assignee `json:"Creator,omitempty"` Creator *User `json:"Creator,omitempty"`
Reporter *Assignee `json:"reporter,omitempty"` Reporter *User `json:"reporter,omitempty"`
Components []*Component `json:"components,omitempty"` Components []*Component `json:"components,omitempty"`
Status *Status `json:"status,omitempty"` Status *Status `json:"status,omitempty"`
Progress *Progress `json:"progress,omitempty"` Progress *Progress `json:"progress,omitempty"`
@ -92,6 +92,7 @@ type IssueType struct {
IconURL string `json:"iconUrl,omitempty"` IconURL string `json:"iconUrl,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Subtask bool `json:"subtask,omitempty"` Subtask bool `json:"subtask,omitempty"`
AvatarID int `json:"avatarId,omitempty"`
} }
// Project represents a JIRA Project. // Project represents a JIRA Project.
@ -129,13 +130,22 @@ type Watches struct {
} }
// Assignee represents a user who is this JIRA issue assigned to. // Assignee represents a user who is this JIRA issue assigned to.
type Assignee struct { type User struct {
Self string `json:"self,omitempty"` Self string `json:"self,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Key string `json:"key,omitempty"`
EmailAddress string `json:"emailAddress,omitempty"` EmailAddress string `json:"emailAddress,omitempty"`
AvatarURLs map[string]string `json:"avatarUrls,omitempty"` AvatarUrls AvatarUrls `json:"avatarUrls,omitempty"`
DisplayName string `json:"displayName,omitempty"` DisplayName string `json:"displayName,omitempty"`
Active bool `json:"active,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. // Component represents a "component" of a JIRA issue.
@ -180,38 +190,13 @@ type Worklog struct {
StartAt int `json:"startAt"` StartAt int `json:"startAt"`
MaxResults int `json:"maxResults"` MaxResults int `json:"maxResults"`
Total int `json:"total"` Total int `json:"total"`
Worklogs []struct { Worklogs []WorklogRecord `json:"worklogs"`
}
type WorklogRecord struct {
Self string `json:"self"` Self string `json:"self"`
Author struct { Author User `json:"author"`
Self string `json:"self"` UpdateAuthor User `json:"updateAuthor"`
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"`
Comment string `json:"comment"` Comment string `json:"comment"`
Created string `json:"created"` Created string `json:"created"`
Updated string `json:"updated"` Updated string `json:"updated"`
@ -220,45 +205,13 @@ type Worklog struct {
TimeSpentSeconds int `json:"timeSpentSeconds"` TimeSpentSeconds int `json:"timeSpentSeconds"`
ID string `json:"id"` ID string `json:"id"`
IssueID string `json:"issueId"` IssueID string `json:"issueId"`
} `json:"worklogs"`
} }
type Subtasks struct { type Subtasks struct {
ID string `json:"id"` ID string `json:"id"`
Key string `json:"key"` Key string `json:"key"`
Self string `json:"self"` Self string `json:"self"`
Fields struct { Fields IssueFields `json:"fields"`
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"`
} }
// IssueLink represents a link between two issues in JIRA. // IssueLink represents a link between two issues in JIRA.
@ -285,9 +238,9 @@ type IssueLinkType struct {
type Comment struct { type Comment struct {
Self string `json:"self,omitempty"` Self string `json:"self,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Author Assignee `json:"author,omitempty"` Author User `json:"author,omitempty"`
Body string `json:"body,omitempty"` Body string `json:"body,omitempty"`
UpdateAuthor Assignee `json:"updateAuthor,omitempty"` UpdateAuthor User `json:"updateAuthor,omitempty"`
Updated string `json:"updated,omitempty"` Updated string `json:"updated,omitempty"`
Created string `json:"created,omitempty"` Created string `json:"created,omitempty"`
Visibility CommentVisibility `json:"visibility,omitempty"` Visibility CommentVisibility `json:"visibility,omitempty"`

View File

@ -16,19 +16,16 @@ type ProjectList []struct {
ID string `json:"id"` ID string `json:"id"`
Key string `json:"key"` Key string `json:"key"`
Name string `json:"name"` Name string `json:"name"`
AvatarUrls struct { AvatarUrls AvatarUrls `json:"avatarUrls"`
Four8X48 string `json:"48x48"`
Two4X24 string `json:"24x24"`
One6X16 string `json:"16x16"`
Three2X32 string `json:"32x32"`
} `json:"avatarUrls"`
ProjectTypeKey string `json:"projectTypeKey"` ProjectTypeKey string `json:"projectTypeKey"`
ProjectCategory struct { ProjectCategory ProjectCategory `json:"projectCategory,omitempty"`
}
type ProjectCategory struct {
Self string `json:"self"` Self string `json:"self"`
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description"` Description string `json:"description"`
} `json:"projectCategory,omitempty"`
} }
// Full project description // Full project description
@ -39,74 +36,9 @@ type FullProject struct {
ID string `json:"id"` ID string `json:"id"`
Key string `json:"key"` Key string `json:"key"`
Description string `json:"description"` Description string `json:"description"`
Lead struct { Lead User `json:"lead"`
Self string `json:"self"` Components []ProjectComponent `json:"components"`
Name string `json:"name"` IssueTypes []IssueType `json:"issueTypes"`
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"`
URL string `json:"url"` URL string `json:"url"`
Email string `json:"email"` Email string `json:"email"`
AssigneeType string `json:"assigneeType"` AssigneeType string `json:"assigneeType"`
@ -115,18 +47,23 @@ type FullProject struct {
Roles struct { Roles struct {
Developers string `json:"Developers"` Developers string `json:"Developers"`
} `json:"roles"` } `json:"roles"`
AvatarUrls struct { AvatarUrls AvatarUrls `json:"avatarUrls"`
Four8X48 string `json:"48x48"` ProjectCategory ProjectCategory `json:"projectCategory"`
Two4X24 string `json:"24x24"` }
One6X16 string `json:"16x16"`
Three2X32 string `json:"32x32"` type ProjectComponent struct {
} `json:"avatarUrls"`
ProjectCategory struct {
Self string `json:"self"` Self string `json:"self"`
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description"` 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 // Get all projects form jira