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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
use super::*;
#[derive(serde::Serialize)]
pub struct ListPullsBuilder<'octo, 'r> {
#[serde(skip)]
handler: &'r RepoHandler<'octo>,
#[serde(skip)]
sha: String,
#[serde(skip_serializing_if = "Option::is_none")]
per_page: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none")]
page: Option<u32>,
}
impl<'octo, 'r> ListPullsBuilder<'octo, 'r> {
/// Creates a new [`ListPullsBuilder`].
///
/// # Examples
///
/// ```no_run
/// # async fn run(octocrab: &octocrab::Octocrab) -> octocrab::Result<()> {
/// let repo = octocrab.repos("owner", "repo");
/// let builder = octocrab::repos::ListPullsBuilder::new(&repo, "sha".to_string());
/// # Ok(())
/// # }
/// ```
pub fn new(handler: &'r RepoHandler<'octo>, sha: String) -> Self {
Self {
handler,
sha,
per_page: None,
page: None,
}
}
/// Results per page (max 100).
///
/// # Examples
///
/// ```no_run
/// # async fn run(octocrab: &octocrab::Octocrab) -> octocrab::Result<()> {
/// let pulls = octocrab
/// .repos("owner", "repo")
/// .list_pulls("sha".to_string())
/// .per_page(50)
/// .send()
/// .await?;
/// # Ok(())
/// # }
/// ```
pub fn per_page(mut self, per_page: impl Into<u8>) -> Self {
self.per_page = Some(per_page.into());
self
}
/// Page number of the results to fetch.
///
/// # Examples
///
/// ```no_run
/// # async fn run(octocrab: &octocrab::Octocrab) -> octocrab::Result<()> {
/// let pulls = octocrab
/// .repos("owner", "repo")
/// .list_pulls("sha".to_string())
/// .page(2u32)
/// .send()
/// .await?;
/// # Ok(())
/// # }
/// ```
pub fn page(mut self, page: impl Into<u32>) -> Self {
self.page = Some(page.into());
self
}
/// Sends the actual request.
///
/// # Examples
///
/// ```no_run
/// # async fn run(octocrab: &octocrab::Octocrab) -> octocrab::Result<()> {
/// let pulls = octocrab
/// .repos("owner", "repo")
/// .list_pulls("sha".to_string())
/// .send()
/// .await?;
/// # Ok(())
/// # }
/// ```
pub async fn send(self) -> crate::Result<crate::Page<crate::models::pulls::PullRequest>> {
let route = format!("/{}/commits/{sha}/pulls", self.handler.repo, sha = self.sha,);
self.handler.crab.get(route, Some(&self)).await
}
}