Skip to content

Commit

Permalink
Added pull request listing
Browse files Browse the repository at this point in the history
  • Loading branch information
daeMOn63 committed Dec 20, 2018
1 parent c454880 commit 0cec735
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
16 changes: 8 additions & 8 deletions dashboard.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package bitclient

type GetPullRequestSuggestionsRequest struct {
type GetMyPullRequestSuggestionsRequest struct {
PagedRequest
ChangeSince uint `url:"changeSince,omitempty"`
Limit uint `url:"limit,omitempty"`
}

type GetPullRequestSuggestionsResponse struct {
type GetMyPullRequestSuggestionsResponse struct {
PagedResponse
Values []PullRequestSuggestion
}

func (bc *BitClient) GetPullRequestSuggestions(params GetPullRequestSuggestionsRequest) (GetPullRequestSuggestionsResponse, error) {
func (bc *BitClient) GetMyPullRequestSuggestions(params GetMyPullRequestSuggestionsRequest) (GetMyPullRequestSuggestionsResponse, error) {

response := GetPullRequestSuggestionsResponse{}
response := GetMyPullRequestSuggestionsResponse{}

_, err := bc.DoGet(
"/dashboard/pull-request-suggestions",
Expand All @@ -24,7 +24,7 @@ func (bc *BitClient) GetPullRequestSuggestions(params GetPullRequestSuggestionsR
return response, err
}

type GetPullRequestsRequest struct {
type GetMyPullRequestsRequest struct {
PagedRequest
State string `url:"state,omitempty"`
Role string `url:"role,omitempty"`
Expand All @@ -33,14 +33,14 @@ type GetPullRequestsRequest struct {
ClosedSince string `url:"closedSince,omitempty"`
}

type GetPullRequestsResponse struct {
type GetMyPullRequestsResponse struct {
PagedResponse PagedResponse
PullRequests []PullRequest
}

func (bc *BitClient) GetPullRequests(params GetPullRequestsRequest) (GetPullRequestsResponse, error) {
func (bc *BitClient) GetMyPullRequests(params GetMyPullRequestsRequest) (GetMyPullRequestsResponse, error) {

response := GetPullRequestsResponse{}
response := GetMyPullRequestsResponse{}

_, err := bc.DoGet(
"/dashboard/pull-requests",
Expand Down
31 changes: 31 additions & 0 deletions project_repository_pull-requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,34 @@ func (bc *BitClient) SetPullRequestSettings(projectKey string, repositorySlug st

return err
}

// GetPullRequestsRequest defines the available parameters when requesting the list of pull requests
// from a repository.
type GetPullRequestsRequest struct {
PagedRequest
Direction string `url:"direction,omitempty"`
At string `url:"at,omitempty"`
State string `url:"state,omitempty"`
Order string `url:"order,omitempty"`
WithAttributes bool `url:"withAttributes,omitempty"`
WithProperties bool `url:"withProperties,omitempty"`
}

// GetPullRequestsResponse holds the API response data
type GetPullRequestsResponse struct {
PagedResponse
Values []PullRequest
}

// GetPullRequests lists the pull requests from given repository
func (bc *BitClient) GetPullRequests(projectKey string, repositorySlug string, params GetPullRequestsRequest) (GetPullRequestsResponse, error) {
response := new(GetPullRequestsResponse)

_, err := bc.DoGet(
fmt.Sprintf("/projects/%s/repos/%s/pull-requests", projectKey, repositorySlug),
nil,
response,
)

return *response, err
}

0 comments on commit 0cec735

Please sign in to comment.