Skip to content
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

Allow to create review comments #142

Merged
merged 1 commit into from Aug 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pulls/mod.rs
Expand Up @@ -378,7 +378,7 @@ impl PullOptions {

#[derive(Debug, Deserialize)]
pub struct FileDiff {
// sha may be null when file mode changed without contents changing
/// sha from GitHub may be null when file mode changed without contents changing
pub sha: Option<String>,
pub filename: String,
pub status: String,
Expand Down
29 changes: 25 additions & 4 deletions src/review_comments/mod.rs
@@ -1,11 +1,15 @@
//! Review comments interface

extern crate futures;
extern crate serde_json;

use hyper::client::Connect;

use {Future, Github};
use futures::future;
use users::User;

/// A structure for interfacing with a issue comments
/// A structure for interfacing with a review comments
pub struct ReviewComments<C>
where
C: Clone + Connect,
Expand All @@ -31,17 +35,34 @@ impl<C: Clone + Connect> ReviewComments<C> {
}
}

/// list pull requests
/// list review comments
pub fn list(&self) -> Future<Vec<ReviewComment>> {
self.github.get::<Vec<ReviewComment>>(&format!(
self.github.get::<Vec<ReviewComment>>(&self.path())
}

/// Create new review comment
pub fn create(&self, review_comment: &ReviewCommentOptions) -> Future<ReviewComment> {
self.github.post(&self.path(), json!(review_comment))
}

fn path(&self) -> String {
format!(
"/repos/{}/{}/pulls/{}/comments",
self.owner, self.repo, self.number
))
)
}
}

// representations (todo: replace with derive_builder)

#[derive(Default, Serialize)]
pub struct ReviewCommentOptions {
pub body: String,
pub commit_id: String,
pub path: String,
pub position: usize,
}

#[derive(Debug, Deserialize)]
pub struct ReviewComment {
pub id: u64,
Expand Down