1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! Review comments interface

use super::{Github, Result};
use users::User;

/// A structure for interfacing with a issue comments
pub struct ReviewComments<'a> {
    github: &'a Github,
    owner: String,
    repo: String,
    number: u64,
}

impl<'a> ReviewComments<'a> {
    pub fn new<O, R>(github: &'a Github, owner: O, repo: R, number: u64) -> ReviewComments<'a>
        where O: Into<String>,
              R: Into<String>
    {
        ReviewComments {
            github: github,
            owner: owner.into(),
            repo: repo.into(),
            number: number,
        }
    }

    /// list pull requests
    pub fn list(&self) -> Result<Vec<ReviewComment>> {
        self.github
            .get::<Vec<ReviewComment>>(&format!("/repos/{}/{}/pulls/{}/comments",
                                                self.owner,
                                                self.repo,
                                                self.number))
    }
}

// representations

#[derive(Debug, Deserialize)]
pub struct ReviewComment {
    pub id: u64,
    pub url: String,
    pub diff_hunk: String,
    pub path: String,
    pub position: u64,
    pub original_position: u64,
    pub commit_id: String,
    pub original_commit_id: String,
    pub user: User,
    pub body: String,
    pub created_at: String,
    pub updated_at: String,
    pub html_url: String,
    pub pull_request_url: String,
}