packages feed

fb 0.9.1 → 0.9.3

raw patch · 5 files changed

+45/−4 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Facebook: fqlQuery :: (MonadResource m, MonadBaseControl IO m) => Text -> Maybe (AccessToken anyKind) -> FacebookT anyAuth m Value

Files

fb.cabal view
@@ -1,5 +1,5 @@ name:              fb-version:           0.9.1+version:           0.9.3 license:           BSD3 license-file:      LICENSE author:            Felipe Lessa@@ -35,6 +35,11 @@   location: git://github.com/meteficha/fb.git  +flag debug+  default: False+  description: Print debugging info.++ library   hs-source-dirs: src   ghc-options: -Wall@@ -75,6 +80,8 @@     TypeFamilies     FlexibleInstances     MultiParamTypeClasses+  if flag(debug)+    cpp-options: -DDEBUG   test-suite runtests
src/Facebook.hs view
@@ -42,6 +42,7 @@     , createAction     , Action     , createCheckin+    , fqlQuery     , (#=)     , SimpleType(..) 
src/Facebook/Base.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE DeriveDataTypeable, FlexibleContexts, OverloadedStrings #-}+{-# LANGUAGE DeriveDataTypeable, FlexibleContexts, OverloadedStrings, CPP #-} module Facebook.Base     ( fbreq     , ToSimpleQuery(..)@@ -27,7 +27,12 @@ import qualified Network.HTTP.Conduit as H import qualified Network.HTTP.Types as HT +#if DEBUG+import Control.Monad.IO.Class (liftIO)+import Text.Printf (printf)+#endif + import Facebook.Types import Facebook.Monad @@ -122,7 +127,13 @@ fbhttp req = do   manager <- getManager   let req' = req { H.checkStatus = \_ _ -> Nothing }+#if DEBUG+  _ <- liftIO $ printf "fbhttp doing request\n\tmethod: %s\n\tsecure: %s\n\thost: %s\n\tport: %s\n\tpath: %s\n\tqueryString: %s\n\trequestHeaders: %s\n" (show $ H.method req') (show $ H.secure req') (show $ H.host req') (show $ H.port req') (show $ H.path req') (show $ H.queryString req') (show $ H.requestHeaders req')+#endif   response@(H.Response status _ headers _) <- lift (H.http req' manager)+#if DEBUG+  _ <- liftIO $ printf "fbhttp response status: %s\n" (show status)+#endif   if isOkay status     then return response     else do
src/Facebook/OpenGraph.hs view
@@ -2,6 +2,7 @@ module Facebook.OpenGraph     ( createAction     , createCheckin+    , fqlQuery     , Action(..)     , (#=)     , SimpleType(..)@@ -37,7 +38,7 @@  import Facebook.Types import Facebook.Monad--- import Facebook.Base+import Facebook.Base import Facebook.Graph  @@ -81,6 +82,15 @@       toBS = TE.encodeUtf8 . TL.toStrict . toLazyText . AE.fromValue   postObject "me/checkins" body usertoken +-- | Query the Facebook Graph using FQL.+fqlQuery :: (C.MonadResource m, MonadBaseControl IO m) =>+             Text                        -- ^ FQL Query+          -> Maybe (AccessToken anyKind) -- ^ Optional access token+          -> FacebookT anyAuth m A.Value+fqlQuery fql mtoken =+  runResourceInFb $ do+    let query = ["q" #= fql]+    asJson =<< fbhttp =<< fbreq "/fql" mtoken query  -- | An action of your app.  Please refer to Facebook's -- documentation at
tests/runtests.hs view
@@ -22,7 +22,7 @@ import qualified Facebook as FB import qualified Network.HTTP.Conduit as H -import Test.HUnit ((@?=))+import Test.HUnit ((@?=), assertFailure) import Test.Hspec.Monadic import Test.Hspec.QuickCheck import Test.Hspec.HUnit ()@@ -144,7 +144,19 @@         FB.userLastName user   &?= Just "Zuckerberg"         FB.userGender user     &?= Just FB.Male +  describe' "fqlQuery" $ do+    it "is able to query Facebook's page name from its page id" $+      runNoAuth $ do+        A.Object obj <- FB.fqlQuery "SELECT name FROM page WHERE page_id = 20531316728" Nothing+        let mr = flip A.parseMaybe () $ const r+            r = do+                  dataArray <- obj A..: "data"+                  (head dataArray) A..: "name"+        case mr of+          Nothing -> liftIO $ assertFailure "Could not parse FQL query response."+          Just r' -> r' &?= ("Facebook" :: Text) +         libraryTests :: Specs libraryTests = do   describe "SimpleType" $ do