Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 645b280

Browse files
authored
Merge pull request haskell-github#297 from y-taka-23/delete-gist
Add endpoints for deleting gists
2 parents 8ce718f + 422f399 commit 645b280

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

samples/Gists/DeleteGist.hs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
module DeleteGist where
3+
4+
import qualified GitHub.Data.Name as N
5+
import qualified GitHub.Endpoints.Gists as GH
6+
7+
import qualified Data.Text as T
8+
import qualified Data.Text.IO as T
9+
10+
main :: IO ()
11+
main = do
12+
let gid = "your-gist-id"
13+
result <- GH.deleteGist (GH.OAuth "your-token") gid
14+
case result of
15+
Left err -> putStrLn $ "Error: " ++ show err
16+
Right () -> T.putStrLn $ T.concat ["Deleted: ", N.untagName gid]

src/GitHub.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ module GitHub (
5757
-- * Check if a gist is starred
5858
-- * Fork a gist
5959
-- * List gist forks
60-
-- * Delete a gist
6160
gistsR,
6261
gistR,
62+
deleteGistR,
6363

6464
-- ** Comments
6565
-- | See <https://developer.github.com/v3/gists/comments/>

src/GitHub/Endpoints/Gists.hs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ module GitHub.Endpoints.Gists (
1111
gist,
1212
gist',
1313
gistR,
14+
deleteGist,
15+
deleteGistR,
1416
module GitHub.Data,
1517
) where
1618

@@ -55,3 +57,14 @@ gist = gist' Nothing
5557
gistR :: Name Gist -> Request k Gist
5658
gistR gid =
5759
query ["gists", toPathPart gid] []
60+
61+
-- | Delete a gist by the authenticated user.
62+
--
63+
-- > deleteGist ("github-username", "github-password") "225074"
64+
deleteGist :: Auth -> Name Gist -> IO (Either Error ())
65+
deleteGist auth gid = executeRequest auth $ deleteGistR gid
66+
67+
-- | Delete a gist by the authenticated user.
68+
-- See <https://developer.github.com/v3/gists/#delete-a-gist>
69+
deleteGistR :: Name Gist -> Request 'RW ()
70+
deleteGistR gid = command Delete ["gists", toPathPart gid] mempty

0 commit comments

Comments
 (0)