-
-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add list_teams() and list_collaborators() to repos() (#395)
* Added list_teams() and list_collaborators() to repos() * Corrected list_collaborators example * cargo fmt
- Loading branch information
Showing
4 changed files
with
120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use super::*; | ||
|
||
#[derive(serde::Serialize)] | ||
pub struct ListCollaboratorsBuilder<'octo, 'r> { | ||
#[serde(skip)] | ||
handler: &'r RepoHandler<'octo>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
per_page: Option<u8>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
page: Option<u32>, | ||
} | ||
|
||
impl<'octo, 'r> ListCollaboratorsBuilder<'octo, 'r> { | ||
pub fn new(handler: &'r RepoHandler<'octo>) -> Self { | ||
Self { | ||
handler, | ||
per_page: None, | ||
page: None, | ||
} | ||
} | ||
|
||
/// Results per page (max 100). | ||
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. | ||
pub fn page(mut self, page: impl Into<u32>) -> Self { | ||
self.page = Some(page.into()); | ||
self | ||
} | ||
|
||
/// Sends the actual request. | ||
pub async fn send(self) -> crate::Result<crate::Page<crate::models::Collaborator>> { | ||
let route = format!( | ||
"/repos/{owner}/{repo}/collaborators", | ||
owner = self.handler.owner, | ||
repo = self.handler.repo | ||
); | ||
self.handler.crab.get(route, Some(&self)).await | ||
} | ||
} |
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,43 @@ | ||
use super::*; | ||
|
||
#[derive(serde::Serialize)] | ||
pub struct ListTeamsBuilder<'octo, 'r> { | ||
#[serde(skip)] | ||
handler: &'r RepoHandler<'octo>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
per_page: Option<u8>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
page: Option<u32>, | ||
} | ||
|
||
impl<'octo, 'r> ListTeamsBuilder<'octo, 'r> { | ||
pub fn new(handler: &'r RepoHandler<'octo>) -> Self { | ||
Self { | ||
handler, | ||
per_page: None, | ||
page: None, | ||
} | ||
} | ||
|
||
/// Results per page (max 100). | ||
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. | ||
pub fn page(mut self, page: impl Into<u32>) -> Self { | ||
self.page = Some(page.into()); | ||
self | ||
} | ||
|
||
/// Sends the actual request. | ||
pub async fn send(self) -> crate::Result<crate::Page<crate::models::teams::Team>> { | ||
let route = format!( | ||
"/repos/{owner}/{repo}/teams", | ||
owner = self.handler.owner, | ||
repo = self.handler.repo | ||
); | ||
self.handler.crab.get(route, Some(&self)).await | ||
} | ||
} |
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