// Copyright 2013 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package github

import (
	
	
	
	
)

// PullRequestComment represents a comment left on a pull request.
type PullRequestComment struct {
	ID                  *int64     `json:"id,omitempty"`
	NodeID              *string    `json:"node_id,omitempty"`
	InReplyTo           *int64     `json:"in_reply_to_id,omitempty"`
	Body                *string    `json:"body,omitempty"`
	Path                *string    `json:"path,omitempty"`
	DiffHunk            *string    `json:"diff_hunk,omitempty"`
	PullRequestReviewID *int64     `json:"pull_request_review_id,omitempty"`
	Position            *int       `json:"position,omitempty"`
	OriginalPosition    *int       `json:"original_position,omitempty"`
	StartLine           *int       `json:"start_line,omitempty"`
	Line                *int       `json:"line,omitempty"`
	OriginalLine        *int       `json:"original_line,omitempty"`
	OriginalStartLine   *int       `json:"original_start_line,omitempty"`
	Side                *string    `json:"side,omitempty"`
	StartSide           *string    `json:"start_side,omitempty"`
	CommitID            *string    `json:"commit_id,omitempty"`
	OriginalCommitID    *string    `json:"original_commit_id,omitempty"`
	User                *User      `json:"user,omitempty"`
	Reactions           *Reactions `json:"reactions,omitempty"`
	CreatedAt           *Timestamp `json:"created_at,omitempty"`
	UpdatedAt           *Timestamp `json:"updated_at,omitempty"`
	// AuthorAssociation is the comment author's relationship to the pull request's repository.
	// Possible values are "COLLABORATOR", "CONTRIBUTOR", "FIRST_TIMER", "FIRST_TIME_CONTRIBUTOR", "MEMBER", "OWNER", or "NONE".
	AuthorAssociation *string `json:"author_association,omitempty"`
	URL               *string `json:"url,omitempty"`
	HTMLURL           *string `json:"html_url,omitempty"`
	PullRequestURL    *string `json:"pull_request_url,omitempty"`
	// Can be one of: LINE, FILE from https://docs.github.com/rest/pulls/comments#create-a-review-comment-for-a-pull-request
	SubjectType *string `json:"subject_type,omitempty"`
}

func ( PullRequestComment) () string {
	return Stringify()
}

// PullRequestListCommentsOptions specifies the optional parameters to the
// PullRequestsService.ListComments method.
type PullRequestListCommentsOptions struct {
	// Sort specifies how to sort comments. Possible values are: created, updated.
	Sort string `url:"sort,omitempty"`

	// Direction in which to sort comments. Possible values are: asc, desc.
	Direction string `url:"direction,omitempty"`

	// Since filters comments by time.
	Since time.Time `url:"since,omitempty"`

	ListOptions
}

// ListComments lists all comments on the specified pull request. Specifying a
// pull request number of 0 will return all comments on all pull requests for
// the repository.
//
// GitHub API docs: https://docs.github.com/rest/pulls/comments#list-review-comments-in-a-repository
// GitHub API docs: https://docs.github.com/rest/pulls/comments#list-review-comments-on-a-pull-request
//
//meta:operation GET /repos/{owner}/{repo}/pulls/comments
//meta:operation GET /repos/{owner}/{repo}/pulls/{pull_number}/comments
func ( *PullRequestsService) ( context.Context, ,  string,  int,  *PullRequestListCommentsOptions) ([]*PullRequestComment, *Response, error) {
	var  string
	if  == 0 {
		 = fmt.Sprintf("repos/%v/%v/pulls/comments", , )
	} else {
		 = fmt.Sprintf("repos/%v/%v/pulls/%d/comments", , , )
	}
	,  := addOptions(, )
	if  != nil {
		return nil, nil, 
	}

	,  := .client.NewRequest("GET", , nil)
	if  != nil {
		return nil, nil, 
	}

	// TODO: remove custom Accept header when this API fully launches.
	 := []string{mediaTypeReactionsPreview, mediaTypeMultiLineCommentsPreview}
	.Header.Set("Accept", strings.Join(, ", "))

	var  []*PullRequestComment
	,  := .client.Do(, , &)
	if  != nil {
		return nil, , 
	}

	return , , nil
}

// GetComment fetches the specified pull request comment.
//
// GitHub API docs: https://docs.github.com/rest/pulls/comments#get-a-review-comment-for-a-pull-request
//
//meta:operation GET /repos/{owner}/{repo}/pulls/comments/{comment_id}
func ( *PullRequestsService) ( context.Context, ,  string,  int64) (*PullRequestComment, *Response, error) {
	 := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", , , )
	,  := .client.NewRequest("GET", , nil)
	if  != nil {
		return nil, nil, 
	}

	// TODO: remove custom Accept header when this API fully launches.
	 := []string{mediaTypeReactionsPreview, mediaTypeMultiLineCommentsPreview}
	.Header.Set("Accept", strings.Join(, ", "))

	 := new(PullRequestComment)
	,  := .client.Do(, , )
	if  != nil {
		return nil, , 
	}

	return , , nil
}

// CreateComment creates a new comment on the specified pull request.
//
// GitHub API docs: https://docs.github.com/rest/pulls/comments#create-a-review-comment-for-a-pull-request
//
//meta:operation POST /repos/{owner}/{repo}/pulls/{pull_number}/comments
func ( *PullRequestsService) ( context.Context, ,  string,  int,  *PullRequestComment) (*PullRequestComment, *Response, error) {
	 := fmt.Sprintf("repos/%v/%v/pulls/%d/comments", , , )
	,  := .client.NewRequest("POST", , )
	if  != nil {
		return nil, nil, 
	}
	// TODO: remove custom Accept headers when their respective API fully launches.
	 := []string{mediaTypeReactionsPreview, mediaTypeMultiLineCommentsPreview}
	.Header.Set("Accept", strings.Join(, ", "))

	 := new(PullRequestComment)
	,  := .client.Do(, , )
	if  != nil {
		return nil, , 
	}

	return , , nil
}

// CreateCommentInReplyTo creates a new comment as a reply to an existing pull request comment.
//
// GitHub API docs: https://docs.github.com/rest/pulls/comments#create-a-review-comment-for-a-pull-request
//
//meta:operation POST /repos/{owner}/{repo}/pulls/{pull_number}/comments
func ( *PullRequestsService) ( context.Context, ,  string,  int,  string,  int64) (*PullRequestComment, *Response, error) {
	 := &struct {
		      string `json:"body,omitempty"`
		 int64  `json:"in_reply_to,omitempty"`
	}{
		:      ,
		: ,
	}
	 := fmt.Sprintf("repos/%v/%v/pulls/%d/comments", , , )
	,  := .client.NewRequest("POST", , )
	if  != nil {
		return nil, nil, 
	}

	 := new(PullRequestComment)
	,  := .client.Do(, , )
	if  != nil {
		return nil, , 
	}

	return , , nil
}

// EditComment updates a pull request comment.
// A non-nil comment.Body must be provided. Other comment fields should be left nil.
//
// GitHub API docs: https://docs.github.com/rest/pulls/comments#update-a-review-comment-for-a-pull-request
//
//meta:operation PATCH /repos/{owner}/{repo}/pulls/comments/{comment_id}
func ( *PullRequestsService) ( context.Context, ,  string,  int64,  *PullRequestComment) (*PullRequestComment, *Response, error) {
	 := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", , , )
	,  := .client.NewRequest("PATCH", , )
	if  != nil {
		return nil, nil, 
	}

	 := new(PullRequestComment)
	,  := .client.Do(, , )
	if  != nil {
		return nil, , 
	}

	return , , nil
}

// DeleteComment deletes a pull request comment.
//
// GitHub API docs: https://docs.github.com/rest/pulls/comments#delete-a-review-comment-for-a-pull-request
//
//meta:operation DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}
func ( *PullRequestsService) ( context.Context, ,  string,  int64) (*Response, error) {
	 := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", , , )
	,  := .client.NewRequest("DELETE", , nil)
	if  != nil {
		return nil, 
	}
	return .client.Do(, , nil)
}