summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVaibhav Yenamandra <3663231+envp@users.noreply.github.com>2023-04-17 02:40:53 -0400
committerGitHub <noreply@github.com>2023-04-17 08:40:53 +0200
commita76b43d63c8e50b414f06c3e1bba1ee20d963df7 (patch)
tree08f59b8f13b95050fa1d29e465555cf343813c69
parent9e237e766d99ba80f4a2e1e9c9a8039c7400af82 (diff)
current: Handle `GET /gists/starred` (#340)
List gists starred by authenticated user Adds `CurrentAuthHandler::list_gists_starred_by_authenticated_user`. This allows callers to fetch gists that were starred by the authenticated user.
-rw-r--r--src/api/current.rs58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/api/current.rs b/src/api/current.rs
index 45ecc6a..4ce72af 100644
--- a/src/api/current.rs
+++ b/src/api/current.rs
@@ -118,6 +118,11 @@ impl<'octo> CurrentAuthHandler<'octo> {
// self.crab.get("/gists", None::<&()>).await
ListGistsForAuthenticatedUserBuilder::new(self.crab)
}
+
+ /// List gists that were starred by the authenticated user.
+ pub fn list_gists_starred_by_authenticated_user(&self) -> ListStarredGistsBuilder<'octo> {
+ ListStarredGistsBuilder::new(self.crab)
+ }
}
/// A builder pattern struct for listing starred repositories.
@@ -391,3 +396,56 @@ impl<'octo> ListGistsForAuthenticatedUserBuilder<'octo> {
self.crab.get("/gists", Some(&self)).await
}
}
+
+#[derive(serde::Serialize)]
+pub struct ListStarredGistsBuilder<'octo> {
+ /// Client under use for building the request.
+ #[serde(skip)]
+ crab: &'octo Octocrab,
+
+ /// Only show gists that were starred after the given ISO 8601 UTC timestamp.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ since: Option<DateTime<Utc>>,
+
+ /// Number of results to return per page. Maximum supported value is `100`.
+ /// Larger values are clamped to `100`. Defaults to `30`
+ #[serde(skip_serializing_if = "Option::is_none")]
+ per_page: Option<u8>,
+
+ /// Page number of the results to fetch. Defaults to `1`.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ page: Option<u32>,
+}
+
+impl<'octo> ListStarredGistsBuilder<'octo> {
+ pub fn new(crab: &'octo Octocrab) -> Self {
+ Self {
+ crab,
+ since: None,
+ per_page: None,
+ page: None,
+ }
+ }
+
+ /// Only show gists that were starred after the given ISO 8601 UTC timestamp.
+ pub fn since(mut self, last_updated: DateTime<Utc>) -> Self {
+ self.since = Some(last_updated);
+ self
+ }
+
+ /// The page number from the result set to fetch.
+ pub fn page(mut self, page_num: u32) -> Self {
+ self.page = Some(page_num);
+ self
+ }
+
+ pub fn per_page(mut self, count: u8) -> Self {
+ self.per_page = Some(count);
+ self
+ }
+
+ /// Sends the actual request.
+ pub async fn send(self) -> crate::Result<Page<Gist>> {
+ self.crab.get("/gists/starred", Some(&self)).await
+ }
+}