Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Just a few minor style tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
svanharmelen committed Apr 5, 2024
1 parent 8c9df79 commit f81ec4e
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions draft_notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ type DraftNote struct {
// DraftNotesService handles communication with the draft notes related methods
// of the GitLab API.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/draft_notes.html#list-all-merge-request-draft-notes
// GitLab API docs:
// https://docs.gitlab.com/ee/api/draft_notes.html#list-all-merge-request-draft-notes
type DraftNotesService struct {
client *Client
}

// ListDraftNotesOptions represents the available ListDraftNotes()
// options.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/draft_notes.html#list-all-merge-request-draft-notes
// GitLab API docs:
// https://docs.gitlab.com/ee/api/draft_notes.html#list-all-merge-request-draft-notes
type ListDraftNotesOptions struct {
ListOptions
OrderBy *string `url:"order_by,omitempty" json:"order_by,omitempty"`
Expand All @@ -53,13 +55,13 @@ type ListDraftNotesOptions struct {

// ListDraftNotes gets a list of all draft notes for a merge request.
//
// Gitlab API docs: https://docs.gitlab.com/ee/api/draft_notes.html#list-all-merge-request-draft-notes
// Gitlab API docs:
// https://docs.gitlab.com/ee/api/draft_notes.html#list-all-merge-request-draft-notes
func (s *DraftNotesService) ListDraftNotes(pid interface{}, mergeRequest int, opt *ListDraftNotesOptions, options ...RequestOptionFunc) ([]*DraftNote, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}

u := fmt.Sprintf("projects/%s/merge_requests/%d/draft_notes", PathEscape(project), mergeRequest)

req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
Expand All @@ -78,7 +80,8 @@ func (s *DraftNotesService) ListDraftNotes(pid interface{}, mergeRequest int, op

// GetDraftNote gets a single draft note for a merge request.
//
// Gitlab API docs: https://docs.gitlab.com/ee/api/draft_notes.html#get-a-single-draft-note
// Gitlab API docs:
// https://docs.gitlab.com/ee/api/draft_notes.html#get-a-single-draft-note
func (s *DraftNotesService) GetDraftNote(pid interface{}, mergeRequest int, note int, options ...RequestOptionFunc) (*DraftNote, *Response, error) {
project, err := parseID(pid)
if err != nil {
Expand All @@ -103,7 +106,8 @@ func (s *DraftNotesService) GetDraftNote(pid interface{}, mergeRequest int, note
// CreateDraftNoteOptions represents the available CreateDraftNote()
// options.
//
// Gitlab API docs: https://docs.gitlab.com/ee/api/draft_notes.html#create-a-draft-note
// Gitlab API docs:
// https://docs.gitlab.com/ee/api/draft_notes.html#create-a-draft-note
type CreateDraftNoteOptions struct {
Note *string `url:"note" json:"note"`
CommitID *string `url:"commit_id,omitempty" json:"commit_id,omitempty"`
Expand All @@ -114,13 +118,13 @@ type CreateDraftNoteOptions struct {

// CreateDraftNote creates a draft note for a merge request.
//
// Gitlab API docs: https://docs.gitlab.com/ee/api/draft_notes.html#create-a-draft-note
// Gitlab API docs:
// https://docs.gitlab.com/ee/api/draft_notes.html#create-a-draft-note
func (s *DraftNotesService) CreateDraftNote(pid interface{}, mergeRequest int, opt *CreateDraftNoteOptions, options ...RequestOptionFunc) (*DraftNote, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}

u := fmt.Sprintf("projects/%s/merge_requests/%d/draft_notes", PathEscape(project), mergeRequest)

req, err := s.client.NewRequest(http.MethodPost, u, opt, options)
Expand All @@ -140,7 +144,8 @@ func (s *DraftNotesService) CreateDraftNote(pid interface{}, mergeRequest int, o
// UpdateDraftNoteOptions represents the available UpdateDraftNote()
// options.
//
// Gitlab API docs: https://docs.gitlab.com/ee/api/draft_notes.html#create-a-draft-note
// Gitlab API docs:
// https://docs.gitlab.com/ee/api/draft_notes.html#create-a-draft-note
type UpdateDraftNoteOptions struct {
Note *string `url:"note,omitempty" json:"note,omitempty"`
Position *PositionOptions `url:"position,omitempty" json:"position,omitempty"`
Expand All @@ -154,7 +159,6 @@ func (s *DraftNotesService) UpdateDraftNote(pid interface{}, mergeRequest int, n
if err != nil {
return nil, nil, err
}

u := fmt.Sprintf("projects/%s/merge_requests/%d/draft_notes/%d", PathEscape(project), mergeRequest, note)

req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
Expand All @@ -173,7 +177,8 @@ func (s *DraftNotesService) UpdateDraftNote(pid interface{}, mergeRequest int, n

// DeleteDraftNote deletes a single draft note for a merge request.
//
// Gitlab API docs: https://docs.gitlab.com/ee/api/draft_notes.html#delete-a-draft-note
// Gitlab API docs:
// https://docs.gitlab.com/ee/api/draft_notes.html#delete-a-draft-note
func (s *DraftNotesService) DeleteDraftNote(pid interface{}, mergeRequest int, note int, options ...RequestOptionFunc) (*Response, error) {
project, err := parseID(pid)
if err != nil {
Expand All @@ -191,7 +196,8 @@ func (s *DraftNotesService) DeleteDraftNote(pid interface{}, mergeRequest int, n

// PublishDraftNote publishes a single draft note for a merge request.
//
// Gitlab API docs: https://docs.gitlab.com/ee/api/draft_notes.html#publish-a-draft-note
// Gitlab API docs:
// https://docs.gitlab.com/ee/api/draft_notes.html#publish-a-draft-note
func (s *DraftNotesService) PublishDraftNote(pid interface{}, mergeRequest int, note int, options ...RequestOptionFunc) (*Response, error) {
project, err := parseID(pid)
if err != nil {
Expand All @@ -209,13 +215,13 @@ func (s *DraftNotesService) PublishDraftNote(pid interface{}, mergeRequest int,

// PublishAllDraftNotes publishes all draft notes for a merge request that belong to the user.
//
// Gitlab API docs: https://docs.gitlab.com/ee/api/draft_notes.html#publish-a-draft-note
// Gitlab API docs:
// https://docs.gitlab.com/ee/api/draft_notes.html#publish-a-draft-note
func (s *DraftNotesService) PublishAllDraftNotes(pid interface{}, mergeRequest int, options ...RequestOptionFunc) (*Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, err
}

u := fmt.Sprintf("projects/%s/merge_requests/%d/draft_notes/bulk_publish", PathEscape(project), mergeRequest)

req, err := s.client.NewRequest(http.MethodPost, u, nil, options)
Expand Down

0 comments on commit f81ec4e

Please sign in to comment.