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
use super::{PullRequestResponse, PullStatus, PullUpdateOptions};
use crate::{AzureClient, Future};
pub struct PullRequest {
ops: AzureClient,
project: String,
repo: String,
id: u64,
}
impl PullRequest {
#[doc(hidden)]
pub fn new<P, R>(ops: AzureClient, project: P, repo: R, id: u64) -> Self
where
P: Into<String>,
R: Into<String>,
{
Self {
ops: ops,
project: project.into(),
repo: repo.into(),
id: id,
}
}
fn path(&self, more: &str) -> String {
format!(
"/{}/{}/_apis/git/repositories/{}/pullrequests/{}{}",
self.ops.org, self.project, self.repo, self.id, more
)
}
pub fn get(&self) -> Future<PullRequestResponse> {
self.ops.get(&self.path(""))
}
pub fn update(&self, pr: &PullUpdateOptions) -> Future<PullRequestResponse> {
let body = json!(pr);
self.ops
.patch::<PullRequestResponse>(&self.path("?"), body)
}
pub fn active(&self) -> Future<PullRequestResponse> {
self.update(&PullUpdateOptions::builder().status(PullStatus::Active).build())
}
pub fn abandon(&self) -> Future<PullRequestResponse> {
self.update(&PullUpdateOptions::builder().status(PullStatus::Abandoned).build())
}
}