Skip to content

Commit c82c184

Browse files
committed
Add ItemSymLink as a new content type
1 parent 01c1154 commit c82c184

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/GitHub/Data/Content.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ data ContentItem = ContentItem {
4646
instance NFData ContentItem where rnf = genericRnf
4747
instance Binary ContentItem
4848

49-
data ContentItemType = ItemFile | ItemDir
49+
data ContentItemType = ItemFile | ItemSymlink | ItemDir
5050
deriving (Show, Data, Typeable, Eq, Ord, Generic)
5151

5252
instance NFData ContentItemType where rnf = genericRnf
@@ -149,9 +149,10 @@ instance FromJSON ContentItem where
149149

150150
instance FromJSON ContentItemType where
151151
parseJSON = withText "ContentItemType" $ \t -> case T.toLower t of
152-
"file" -> pure ItemFile
153-
"dir" -> pure ItemDir
154-
_ -> fail $ "Unknown ContentItemType: " <> T.unpack t
152+
"file" -> pure ItemFile
153+
"dir" -> pure ItemDir
154+
"symlink" -> pure ItemSymlink
155+
_ -> fail $ "Unknown ContentItemType: " <> T.unpack t
155156

156157
instance FromJSON ContentInfo where
157158
parseJSON = withObject "ContentInfo" $ \o ->

src/GitHub/Request.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ import GitHub.Data.Request
118118

119119
import Paths_github (version)
120120

121+
import Control.Monad.IO.Class (liftIO)
122+
121123
-------------------------------------------------------------------------------
122124
-- Convenience
123125
-------------------------------------------------------------------------------
@@ -235,6 +237,7 @@ executeRequestWithMgrAndRes mgr auth req = runExceptT $ do
235237
performHttpReq :: forall rw mt b. ParseResponse mt b => HTTP.Request -> GenRequest mt rw b -> ExceptT Error IO (HTTP.Response b)
236238
performHttpReq httpReq Query {} = do
237239
res <- httpLbs' httpReq
240+
liftIO $ LBS.writeFile "response.json" (HTTP.responseBody res)
238241
(<$ res) <$> unTagged (parseResponse httpReq res :: Tagged mt (ExceptT Error IO b))
239242

240243
performHttpReq httpReq (PagedQuery _ _ l) =

0 commit comments

Comments
 (0)