azure_rust/pull_requests/
pull.rs1use super::{PullRequestResponse, PullStatus, PullUpdateOptions};
2use crate::{AzureClient, Future};
3
4pub struct PullRequest {
5 ops: AzureClient,
6 project: String,
7 repo: String,
8 id: u64,
9}
10
11impl PullRequest {
12 #[doc(hidden)]
13 pub fn new<P, R>(ops: AzureClient, project: P, repo: R, id: u64) -> Self
14 where
15 P: Into<String>,
16 R: Into<String>,
17 {
18 Self {
19 ops: ops,
20 project: project.into(),
21 repo: repo.into(),
22 id: id,
23 }
24 }
25
26 fn path(&self, more: &str) -> String {
28 format!(
29 "/{}/{}/_apis/git/repositories/{}/pullrequests/{}{}",
30 self.ops.org, self.project, self.repo, self.id, more
31 )
32 }
33 pub fn get(&self) -> Future<PullRequestResponse> {
35 self.ops.get(&self.path(""))
36 }
37
38 pub fn update(&self, pr: &PullUpdateOptions) -> Future<PullRequestResponse> {
40 let body = json!(pr);
41 self.ops
42 .patch::<PullRequestResponse>(&self.path("?"), body)
43 }
44
45 pub fn active(&self) -> Future<PullRequestResponse> {
47 self.update(&PullUpdateOptions::builder().status(PullStatus::Active).build())
48 }
49
50 pub fn abandon(&self) -> Future<PullRequestResponse> {
52 self.update(&PullUpdateOptions::builder().status(PullStatus::Abandoned).build())
53 }
54
55}