packages feed

twitter-conduit 0.0.7 → 0.0.8

raw patch · 5 files changed

+35/−17 lines, 5 files

Files

.travis.yml view
@@ -32,6 +32,7 @@       export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/1.18/bin:$PATH       echo "use ppa:hvr/ghc: `which ghc` `ghc --numeric-version`"     fi+    cabal install Cabal --constraint="Cabal >= 1.18 && < 1.19"  install:   - export PATH=$HOME/.cabal/bin:$PATH
Web/Twitter/Conduit.hs view
@@ -18,7 +18,6 @@         -- * Re-exports          module Web.Twitter.Conduit.Api-       , module Web.Twitter.Conduit.Base        , module Web.Twitter.Conduit.Cursor        , module Web.Twitter.Conduit.Monad        , module Web.Twitter.Conduit.Parameters@@ -26,6 +25,17 @@        , module Web.Twitter.Conduit.Response        , module Web.Twitter.Conduit.Status        , module Web.Twitter.Conduit.Stream++       -- * 'Web.Twitter.Conduit.Base'+       , TwitterBaseM+       , call+       , call'+       , callWithResponse+       , callWithResponse'+       , sourceWithMaxId+       , sourceWithMaxId'+       , sourceWithCursor+       , sourceWithCursor'  #if !MIN_VERSION_twitter_types(0,5,0)        , UploadedMedia
Web/Twitter/Conduit/Base.hs view
@@ -9,6 +9,8 @@        , getResponse        , call        , call'+       , callWithResponse+       , callWithResponse'        , checkResponse        , sourceWithMaxId        , sourceWithMaxId'@@ -116,10 +118,12 @@               -> Either TwitterError Value checkResponse Response{..} =     case responseBody ^? key "errors" of-        Just errs ->+        Just errs@(Array _) ->             case fromJSON errs of                 Success errList -> Left $ TwitterErrorResponse responseStatus responseHeaders errList                 Error msg -> Left $ FromJSONError msg+        Just err ->+            Left $ TwitterUnknownErrorResponse responseStatus responseHeaders err         Nothing ->             if sci < 200 || sci > 400                 then Left $ TwitterStatusError responseStatus responseHeaders responseBody@@ -129,21 +133,15 @@  getValueOrThrow :: (MonadThrow m, MonadLogger m, FromJSON a)                 => Response (C.ResumableSource m ByteString)-                -> m a+                -> m (Response a) getValueOrThrow res = do-    val <- getValueOrThrow' res-    case fromJSON val of-        Success r -> return r-        Error err -> monadThrow $ FromJSONError err--getValueOrThrow' :: (MonadLogger m, MonadThrow m)-                 => Response (C.ResumableSource m ByteString)-                 -> m Value-getValueOrThrow' res = do     res' <- getValue res     case checkResponse res' of         Left err -> monadThrow err-        Right v -> return v+        Right _ -> return ()+    case fromJSON (responseBody res') of+        Success r -> return $ res' { responseBody = r }+        Error err -> monadThrow $ FromJSONError err  call :: (TwitterBaseM m, FromJSON responseType)      => APIRequest apiName responseType@@ -153,9 +151,17 @@ call' :: (TwitterBaseM m, FromJSON value)       => APIRequest apiName responseType       -> TW m value-call' req = do-    res <- getResponse =<< makeRequest req-    getValueOrThrow res+call' = fmap responseBody . callWithResponse'++callWithResponse :: (TwitterBaseM m, FromJSON responseType)+                 => APIRequest apiName responseType+                 -> TW m (Response responseType)+callWithResponse = callWithResponse'++callWithResponse' :: (TwitterBaseM m, FromJSON value)+                  => APIRequest apiName responseType+                  -> TW m (Response value)+callWithResponse' req = getValueOrThrow =<< getResponse =<< makeRequest req  sourceWithMaxId :: ( TwitterBaseM m                    , FromJSON responseType
Web/Twitter/Conduit/Response.hs view
@@ -28,6 +28,7 @@ data TwitterError     = FromJSONError String     | TwitterErrorResponse Status ResponseHeaders [TwitterErrorMessage]+    | TwitterUnknownErrorResponse Status ResponseHeaders Value     | TwitterStatusError Status ResponseHeaders Value     deriving (Show, Typeable, Eq) 
twitter-conduit.cabal view
@@ -1,5 +1,5 @@ name:              twitter-conduit-version:           0.0.7+version:           0.0.8 license:           BSD3 license-file:      LICENSE author:            HATTORI Hiroki, Hideyuki Tanaka, Takahiro HIMURA