-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from grahamc/review-requests
Support Pull Review Requests
- Loading branch information
Showing
4 changed files
with
116 additions
and
0 deletions.
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
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
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
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
//! Review requests interface | ||
|
||
extern crate futures; | ||
extern crate serde_json; | ||
|
||
use hyper::client::connect::Connect; | ||
|
||
use pulls::Pull; | ||
use teams::Team; | ||
use users::User; | ||
use {Future, Github}; | ||
|
||
/// A structure for interfacing with review requests | ||
pub struct ReviewRequests<C> | ||
where | ||
C: Clone + Connect + 'static, | ||
{ | ||
github: Github<C>, | ||
owner: String, | ||
repo: String, | ||
number: u64, | ||
} | ||
|
||
impl<C: Clone + Connect + 'static> ReviewRequests<C> { | ||
#[doc(hidden)] | ||
pub fn new<O, R>(github: Github<C>, owner: O, repo: R, number: u64) -> Self | ||
where | ||
O: Into<String>, | ||
R: Into<String>, | ||
{ | ||
ReviewRequests { | ||
github, | ||
owner: owner.into(), | ||
repo: repo.into(), | ||
number, | ||
} | ||
} | ||
|
||
/// list requested reviews | ||
pub fn get(&self) -> Future<ReviewRequest> { | ||
self.github.get::<ReviewRequest>(&self.path()) | ||
} | ||
|
||
/// Add new requested reviews | ||
pub fn create(&self, review_request: &ReviewRequestOptions) -> Future<Pull> { | ||
self.github.post(&self.path(), json!(review_request)) | ||
} | ||
|
||
/// Delete a review request | ||
pub fn delete(&self, review_request: &ReviewRequestOptions) -> Future<()> { | ||
self.github | ||
.delete_message(&self.path(), json!(review_request)) | ||
} | ||
|
||
fn path(&self) -> String { | ||
format!( | ||
"/repos/{}/{}/pulls/{}/requested_reviewers", | ||
self.owner, self.repo, self.number | ||
) | ||
} | ||
} | ||
|
||
// representations (todo: replace with derive_builder) | ||
|
||
#[derive(Default, Serialize)] | ||
pub struct ReviewRequestOptions { | ||
/// An array of user `logins` that will be requested. | ||
/// Note, each login must be a collaborator. | ||
pub reviewers: Vec<String>, | ||
/// An array of team `slugs` that will be requested. | ||
pub team_reviewers: Vec<String>, | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub struct ReviewRequest { | ||
pub users: Vec<User>, | ||
pub teams: Vec<Team>, | ||
} |