From 9ad2e7631be2f1e275a2b83d7b8e8fbaed41b2bb Mon Sep 17 00:00:00 2001 From: Vaibhav Yenamandra <3663231+envp@users.noreply.github.com> Date: Wed, 12 Apr 2023 12:19:15 -0400 Subject: [PATCH] Handle `DELETE /gists/{gist_id}` (#333) --- src/api/gists.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/api/gists.rs b/src/api/gists.rs index 40f7c558..785554f9 100644 --- a/src/api/gists.rs +++ b/src/api/gists.rs @@ -79,6 +79,22 @@ impl<'octo> GistsHandler<'octo> { self.crab.get(format!("/gists/{id}"), None::<&()>).await } + /// Delete a single gist. + /// + /// ```no_run + /// # async fn run() -> octocrab::Result<()> { + /// octocrab::instance().gists().delete("00000000000000000000000000000000").await?; + /// # Ok(()) + /// # } + /// ``` + pub async fn delete(&self, gist_id: impl AsRef) -> Result<()> { + let gist_id = gist_id.as_ref(); + self.crab + ._delete(format!("/gists/{gist_id}"), None::<&()>) + .await + .map(|_| ()) + } + /// Get a single gist revision. /// ```no_run /// # async fn run() -> octocrab::Result<()> { @@ -141,10 +157,7 @@ impl<'octo> GistsHandler<'octo> { /// [docs]: https://docs.github.com/en/rest/gists/gists?apiVersion=2022-11-28#check-if-a-gist-is-starred pub async fn is_starred(&self, gist_id: impl AsRef) -> Result { let gist_id = gist_id.as_ref(); - let response = self - .crab - ._get(format!("/gists/{gist_id}/star")) - .await?; + let response = self.crab._get(format!("/gists/{gist_id}/star")).await?; // Gist API returns 204 (NO CONTENT) if a gist is starred Ok(response.status() == StatusCode::NO_CONTENT) }