-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update teams_discussions with ByID and BySlug endpoints #1426
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,12 +44,12 @@ type DiscussionListOptions struct { | |
Direction string `url:"direction,omitempty"` | ||
} | ||
|
||
// ListDiscussions lists all discussions on team's page. | ||
// ListDiscussionsByID lists all discussions on team's page given Organization and Team ID. | ||
// Authenticated user must grant read:discussion scope. | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/teams/discussions/#list-discussions | ||
func (s *TeamsService) ListDiscussions(ctx context.Context, teamID int64, options *DiscussionListOptions) ([]*TeamDiscussion, *Response, error) { | ||
u := fmt.Sprintf("teams/%v/discussions", teamID) | ||
func (s *TeamsService) ListDiscussionsByID(ctx context.Context, orgID, teamID int64, options *DiscussionListOptions) ([]*TeamDiscussion, *Response, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's please change |
||
u := fmt.Sprintf("organizations/%v/team/%v/discussions", orgID, teamID) | ||
u, err := addOptions(u, options) | ||
if err != nil { | ||
return nil, nil, err | ||
|
@@ -69,12 +69,37 @@ func (s *TeamsService) ListDiscussions(ctx context.Context, teamID int64, option | |
return teamDiscussions, resp, nil | ||
} | ||
|
||
// GetDiscussion gets a specific discussion on a team's page. | ||
// ListDiscussionsBySlug lists all discussions on team's page given Organization name and Team's slug. | ||
// Authenticated user must grant read:discussion scope. | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/teams/discussions/#list-discussions | ||
func (s *TeamsService) ListDiscussionsBySlug(ctx context.Context, org, slug string, options *DiscussionListOptions) ([]*TeamDiscussion, *Response, error) { | ||
u := fmt.Sprintf("orgs/%v/teams/%v/discussions", org, slug) | ||
u, err := addOptions(u, options) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
req, err := s.client.NewRequest("GET", u, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
var teamDiscussions []*TeamDiscussion | ||
resp, err := s.client.Do(ctx, req, &teamDiscussions) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
|
||
return teamDiscussions, resp, nil | ||
} | ||
|
||
// GetDiscussionByID gets a specific discussion on a team's page given Organization and Team ID. | ||
// Authenticated user must grant read:discussion scope. | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/teams/discussions/#get-a-single-discussion | ||
func (s *TeamsService) GetDiscussion(ctx context.Context, teamID int64, discussionNumber int) (*TeamDiscussion, *Response, error) { | ||
u := fmt.Sprintf("teams/%v/discussions/%v", teamID, discussionNumber) | ||
func (s *TeamsService) GetDiscussionByID(ctx context.Context, orgID, teamID int64, discussionNumber int) (*TeamDiscussion, *Response, error) { | ||
u := fmt.Sprintf("organizations/%v/team/%v/discussions/%v", orgID, teamID, discussionNumber) | ||
req, err := s.client.NewRequest("GET", u, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
|
@@ -89,12 +114,32 @@ func (s *TeamsService) GetDiscussion(ctx context.Context, teamID int64, discussi | |
return teamDiscussion, resp, nil | ||
} | ||
|
||
// CreateDiscussion creates a new discussion post on a team's page. | ||
// GetDiscussionBySlug gets a specific discussion on a team's page given Organization name and Team's slug. | ||
// Authenticated user must grant read:discussion scope. | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/teams/discussions/#get-a-single-discussion | ||
func (s *TeamsService) GetDiscussionBySlug(ctx context.Context, org, slug string, discussionNumber int) (*TeamDiscussion, *Response, error) { | ||
u := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v", org, slug, discussionNumber) | ||
req, err := s.client.NewRequest("GET", u, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
teamDiscussion := &TeamDiscussion{} | ||
resp, err := s.client.Do(ctx, req, teamDiscussion) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
|
||
return teamDiscussion, resp, nil | ||
} | ||
|
||
// CreateDiscussionByID creates a new discussion post on a team's page given Organization and Team ID. | ||
// Authenticated user must grant write:discussion scope. | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/teams/discussions/#create-a-discussion | ||
func (s *TeamsService) CreateDiscussion(ctx context.Context, teamID int64, discussion TeamDiscussion) (*TeamDiscussion, *Response, error) { | ||
u := fmt.Sprintf("teams/%v/discussions", teamID) | ||
func (s *TeamsService) CreateDiscussionByID(ctx context.Context, orgID, teamID int64, discussion TeamDiscussion) (*TeamDiscussion, *Response, error) { | ||
u := fmt.Sprintf("organizations/%v/team/%v/discussions", orgID, teamID) | ||
req, err := s.client.NewRequest("POST", u, discussion) | ||
if err != nil { | ||
return nil, nil, err | ||
|
@@ -109,13 +154,54 @@ func (s *TeamsService) CreateDiscussion(ctx context.Context, teamID int64, discu | |
return teamDiscussion, resp, nil | ||
} | ||
|
||
// EditDiscussion edits the title and body text of a discussion post. | ||
// CreateDiscussionBySlug creates a new discussion post on a team's page given Organization name and Team's slug. | ||
// Authenticated user must grant write:discussion scope. | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/teams/discussions/#create-a-discussion | ||
func (s *TeamsService) CreateDiscussionBySlug(ctx context.Context, org, slug string, discussion TeamDiscussion) (*TeamDiscussion, *Response, error) { | ||
u := fmt.Sprintf("orgs/%v/teams/%v/discussions", org, slug) | ||
req, err := s.client.NewRequest("POST", u, discussion) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
teamDiscussion := &TeamDiscussion{} | ||
resp, err := s.client.Do(ctx, req, teamDiscussion) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
|
||
return teamDiscussion, resp, nil | ||
} | ||
|
||
// EditDiscussionByID edits the title and body text of a discussion post given Organization and Team ID. | ||
// Authenticated user must grant write:discussion scope. | ||
// User is allowed to change Title and Body of a discussion only. | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/teams/discussions/#edit-a-discussion | ||
func (s *TeamsService) EditDiscussionByID(ctx context.Context, orgID, teamID int64, discussionNumber int, discussion TeamDiscussion) (*TeamDiscussion, *Response, error) { | ||
u := fmt.Sprintf("organizations/%v/team/%v/discussions/%v", orgID, teamID, discussionNumber) | ||
req, err := s.client.NewRequest("PATCH", u, discussion) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
teamDiscussion := &TeamDiscussion{} | ||
resp, err := s.client.Do(ctx, req, teamDiscussion) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
|
||
return teamDiscussion, resp, nil | ||
} | ||
|
||
// EditDiscussionBySlug edits the title and body text of a discussion post given Organization name and Team's slug. | ||
// Authenticated user must grant write:discussion scope. | ||
// User is allowed to change Title and Body of a discussion only. | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/teams/discussions/#edit-a-discussion | ||
func (s *TeamsService) EditDiscussion(ctx context.Context, teamID int64, discussionNumber int, discussion TeamDiscussion) (*TeamDiscussion, *Response, error) { | ||
u := fmt.Sprintf("teams/%v/discussions/%v", teamID, discussionNumber) | ||
func (s *TeamsService) EditDiscussionBySlug(ctx context.Context, org, slug string, discussionNumber int, discussion TeamDiscussion) (*TeamDiscussion, *Response, error) { | ||
u := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v", org, slug, discussionNumber) | ||
req, err := s.client.NewRequest("PATCH", u, discussion) | ||
if err != nil { | ||
return nil, nil, err | ||
|
@@ -130,12 +216,26 @@ func (s *TeamsService) EditDiscussion(ctx context.Context, teamID int64, discuss | |
return teamDiscussion, resp, nil | ||
} | ||
|
||
// DeleteDiscussion deletes a discussion from team's page. | ||
// DeleteDiscussionByID deletes a discussion from team's page given Organization and Team ID. | ||
// Authenticated user must grant write:discussion scope. | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/teams/discussions/#delete-a-discussion | ||
func (s *TeamsService) DeleteDiscussionByID(ctx context.Context, orgID, teamID int64, discussionNumber int) (*Response, error) { | ||
u := fmt.Sprintf("organizations/%v/team/%v/discussions/%v", orgID, teamID, discussionNumber) | ||
req, err := s.client.NewRequest("DELETE", u, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return s.client.Do(ctx, req, nil) | ||
} | ||
|
||
// DeleteDiscussionBySlug deletes a discussion from team's page given Organization name and Team's slug. | ||
// Authenticated user must grant write:discussion scope. | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/teams/discussions/#delete-a-discussion | ||
func (s *TeamsService) DeleteDiscussion(ctx context.Context, teamID int64, discussionNumber int) (*Response, error) { | ||
u := fmt.Sprintf("teams/%v/discussions/%v", teamID, discussionNumber) | ||
func (s *TeamsService) DeleteDiscussionBySlug(ctx context.Context, org, slug string, discussionNumber int) (*Response, error) { | ||
u := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v", org, slug, discussionNumber) | ||
req, err := s.client.NewRequest("DELETE", u, nil) | ||
if err != nil { | ||
return nil, err | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the documentation, it looks like
DiscussionListOptions
also needs to embed aListOptions
struct to support pagination. Please add this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct, I've updated it.