Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/api/current.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ impl<'octo> CurrentAuthHandler<'octo> {
/// ```
///
/// [See the GitHub API documentation](https://docs.github.com/en/rest/reference/repos#list-repositories-for-the-authenticated-user)
pub fn list_repos_for_authenticated_user(&self) -> ListReposForAuthenticatedUserBuilder<'octo> {
ListReposForAuthenticatedUserBuilder::new(self.crab)
pub fn list_repos_for_authenticated_user(&self, org: Option<String>) -> ListReposForAuthenticatedUserBuilder<'octo> {
ListReposForAuthenticatedUserBuilder::new(self.crab, org)
}

/// List gists for the current authenticated user.
Expand Down Expand Up @@ -273,10 +273,13 @@ pub struct ListReposForAuthenticatedUserBuilder<'octo> {

#[serde(skip_serializing_if = "Option::is_none")]
before: Option<DateTime<Utc>>,

#[serde(skip_serializing_if = "Option::is_none")]
org: Option<String>,
}

impl<'octo> ListReposForAuthenticatedUserBuilder<'octo> {
fn new(crab: &'octo Octocrab) -> Self {
fn new(crab: &'octo Octocrab, org: Option<String>) -> Self {
Self {
crab,
visibility: None,
Expand All @@ -288,6 +291,7 @@ impl<'octo> ListReposForAuthenticatedUserBuilder<'octo> {
page: None,
since: None,
before: None,
org: org,
}
}

Expand Down Expand Up @@ -370,7 +374,11 @@ impl<'octo> ListReposForAuthenticatedUserBuilder<'octo> {

/// Sends the actual request.
pub async fn send(self) -> crate::Result<Page<Repository>> {
self.crab.get("/user/repos", (&self).into()).await
if self.org.is_some() {
self.crab.get(format!("/users/{}/repos", self.org.clone().unwrap()), (&self).into()).await
} else {
self.crab.get("/user/repos", (&self).into()).await
}
}
}

Expand Down
Loading