azure_rust/pull_requests/
pulls.rs1use super::{PullListOptions, PullRequestCreateResponse, PullRequestsResponse};
2use crate::{AzureClient, Future};
3
4pub use super::pull::PullRequest;
5pub use super::PROption;
6
7pub struct PullRequests {
8 ops: AzureClient,
9 project: String,
10 repo: String,
11}
12
13impl PullRequests {
14 #[doc(hidden)]
15 pub fn new<P, R>(ops: AzureClient, project: P, repo: R) -> Self
16 where
17 P: Into<String>,
18 R: Into<String>,
19 {
20 Self {
21 ops: ops,
22 project: project.into(),
23 repo: repo.into(),
24 }
25 }
26
27 pub fn create(&self, options: &PROption) -> Future<PullRequestCreateResponse> {
29 self.ops.post(&self.path(""), json!(options))
30 }
31 pub fn pull(&self, id: u64) -> PullRequest {
33 PullRequest::new(
34 self.ops.clone(),
35 self.project.as_str(),
36 self.repo.as_str(),
37 id,
38 )
39 }
40
41 pub fn list(&self, options: PullListOptions) -> Future<PullRequestsResponse> {
43 let mut uri = vec![self.path("")];
44 for (key, value) in options.params.into_iter() {
45 uri.push(format!("{}={}", key, value))
46 }
47 let uri = &uri.join("?");
48 self.ops.get::<PullRequestsResponse>(&format!("{}&", uri))
49 }
50
51 fn path(&self, more: &str) -> String {
52 format!(
53 "/{}/{}/_apis/git/repositories/{}/pullrequests{}",
54 self.ops.org, self.project, self.repo, more
55 )
56 }
57}