From 38c5b5b52c50668b1e9f857fe6faccedd984f770 Mon Sep 17 00:00:00 2001 From: Yonas Date: Sun, 15 Jun 2025 15:10:46 -0400 Subject: [PATCH] feat: Take organization as argument. --- src/api/current.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/api/current.rs b/src/api/current.rs index 1bdd7802..81643d4c 100644 --- a/src/api/current.rs +++ b/src/api/current.rs @@ -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) -> ListReposForAuthenticatedUserBuilder<'octo> { + ListReposForAuthenticatedUserBuilder::new(self.crab, org) } /// List gists for the current authenticated user. @@ -273,10 +273,13 @@ pub struct ListReposForAuthenticatedUserBuilder<'octo> { #[serde(skip_serializing_if = "Option::is_none")] before: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + org: Option, } impl<'octo> ListReposForAuthenticatedUserBuilder<'octo> { - fn new(crab: &'octo Octocrab) -> Self { + fn new(crab: &'octo Octocrab, org: Option) -> Self { Self { crab, visibility: None, @@ -288,6 +291,7 @@ impl<'octo> ListReposForAuthenticatedUserBuilder<'octo> { page: None, since: None, before: None, + org: org, } } @@ -370,7 +374,11 @@ impl<'octo> ListReposForAuthenticatedUserBuilder<'octo> { /// Sends the actual request. pub async fn send(self) -> crate::Result> { - 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 + } } }