Skip to content

Commit

Permalink
Merge pull request #587 from andygrunwald/pr-455
Browse files Browse the repository at this point in the history
Cloud/Board: Add Location to Board struct
  • Loading branch information
andygrunwald authored Oct 19, 2022
2 parents 4496e87 + 9eaa723 commit 76785ff
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
33 changes: 22 additions & 11 deletions cloud/board.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,24 @@ type BoardsList struct {

// Board represents a Jira agile board
type Board struct {
ID int `json:"id,omitempty" structs:"id,omitempty"`
Self string `json:"self,omitempty" structs:"self,omitempty"`
Name string `json:"name,omitempty" structs:"name,omitemtpy"`
Type string `json:"type,omitempty" structs:"type,omitempty"`
FilterID int `json:"filterId,omitempty" structs:"filterId,omitempty"`
ID int `json:"id,omitempty" structs:"id,omitempty"`
Self string `json:"self,omitempty" structs:"self,omitempty"`
Name string `json:"name,omitempty" structs:"name,omitemtpy"`
Type string `json:"type,omitempty" structs:"type,omitempty"`
Location BoardLocation `json:"location,omitempty" structs:"location,omitempty"`
FilterID int `json:"filterId,omitempty" structs:"filterId,omitempty"`
}

// BoardLocation represents the location of a Jira board
type BoardLocation struct {
ProjectID int `json:"projectId"`
UserID int `json:"userId"`
UserAccountID string `json:"userAccountId"`
DisplayName string `json:"displayName"`
ProjectName string `json:"projectName"`
ProjectKey string `json:"projectKey"`
ProjectTypeKey string `json:"projectTypeKey"`
Name string `json:"name"`
}

// BoardListOptions specifies the optional parameters to the BoardService.GetList
Expand Down Expand Up @@ -152,14 +165,12 @@ func (s *BoardService) GetAllBoards(ctx context.Context, opt *BoardListOptions)
return boards, resp, err
}

// GetBoard will returns the board for the given boardID.
// GetBoard returns the board for the given board ID.
// This board will only be returned if the user has permission to view it.
// Admins without the view permission will see the board as a private one, so will see only a subset of the board's data (board location for instance).
//
// Jira API docs: https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-getBoard
//
// TODO Double check this method if this works as expected, is using the latest API and the response is complete
// This double check effort is done for v2 - Remove this two lines if this is completed.
func (s *BoardService) GetBoard(ctx context.Context, boardID int) (*Board, *Response, error) {
// Jira API docs: https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-get
func (s *BoardService) GetBoard(ctx context.Context, boardID int64) (*Board, *Response, error) {
apiEndpoint := fmt.Sprintf("rest/agile/1.0/board/%v", boardID)
req, err := s.client.NewRequest(ctx, http.MethodGet, apiEndpoint, nil)
if err != nil {
Expand Down
10 changes: 9 additions & 1 deletion testing/mock-data/all_boards.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@
"id": 1,
"self": "https://test.jira.org/rest/agile/1.0/board/1",
"name": "Test Mobile",
"type": "scrum"
"type": "scrum",
"location": {
"projectId": 10000,
"displayName": "aproject (AP)",
"projectName": "aproject",
"projectKey": "AP",
"projectTypeKey": "software",
"name": "aproject (AP)"
}
}
]
}

0 comments on commit 76785ff

Please sign in to comment.