ig 0.1 → 0.2
raw patch · 2 files changed
+22/−31 lines, 2 filesdep ~aesondep ~attoparsecdep ~http-conduit
Dependency ranges changed: aeson, attoparsec, http-conduit
Files
- ig.cabal +12/−22
- src/Instagram/Monad.hs +10/−9
ig.cabal view
@@ -1,5 +1,5 @@ name: ig-version: 0.1+version: 0.2 synopsis: Bindings to Instagram's API. homepage: https://github.com/loyful/ig license: BSD3@@ -36,7 +36,6 @@ ghc-options: -Wall exposed-modules: Instagram--- other-modules: build-depends: base >= 4 && < 5 , bytestring >= 0.9 && < 0.11@@ -47,30 +46,21 @@ , resourcet , conduit == 1.0.* , http-types- , http-conduit == 1.9.*- , attoparsec == 0.10.*+ , http-conduit == 2.0.*+ , attoparsec >= 0.10 && < 0.12 , attoparsec-conduit == 1.0.*- , aeson >= 0.5 && < 0.7,- time,- data-default,- lifted-base,- unordered-containers- , crypto-api >= 0.11 && < 0.13- , cryptohash >= 0.7- , cryptohash-cryptoapi == 0.1.*- , base16-bytestring >= 0.1+ , aeson >= 0.5 && < 0.8+ , time+ , data-default+ , lifted-base+ , unordered-containers+ , crypto-api >= 0.11 && < 0.13+ , cryptohash >= 0.7+ , cryptohash-cryptoapi == 0.1.*+ , base16-bytestring >= 0.1 extensions: OverloadedStrings DeriveDataTypeable- -- -- Copied from fb-0.14.6, may be useful =).- -- EmptyDataDecls- -- GADTs- -- StandaloneDeriving- -- ScopedTypeVariables- -- GeneralizedNewtypeDeriving- -- TypeFamilies- -- FlexibleInstances- -- MultiParamTypeClasses other-modules: Instagram.Types, Instagram.Monad,
src/Instagram/Monad.hs view
@@ -41,6 +41,7 @@ , defaultRestoreM ) import Control.Monad.Trans.Reader (ReaderT(..), ask, mapReaderT) import Data.Typeable (Typeable)+import Data.Default import qualified Control.Monad.Trans.Resource as R import qualified Control.Exception.Lifted as L @@ -103,10 +104,10 @@ -- | build a post request to Instagram getPostRequest :: (Monad m,HT.QueryLike q) => ByteString -- ^ the url path -> q -- ^ the query parameters- -> InstagramT m (H.Request a) -- ^ the properly configured request+ -> InstagramT m H.Request -- ^ the properly configured request getPostRequest path query=do host<-getHost- return $ H.def {+ return $ def { H.secure=True , H.host = host , H.port = 443@@ -118,14 +119,14 @@ -- | build a get request to Instagram getGetRequest :: (Monad m,MonadIO m,HT.QueryLike q) => ByteString -- ^ the url path -> q -- ^ the query parameters- -> InstagramT m (H.Request a) -- ^ the properly configured request+ -> InstagramT m H.Request -- ^ the properly configured request getGetRequest path query=do host<-getHost let qs=HT.renderQuery True $ HT.toQuery query #if DEBUG liftIO $ BSC.putStrLn $ BS.append path qs #endif - return $ H.def {+ return $ def { H.secure=True , H.host = host , H.port = 443@@ -137,7 +138,7 @@ -- | build a delete request to Instagram getDeleteRequest :: (Monad m,MonadIO m,HT.QueryLike q) => ByteString -- ^ the url path -> q -- ^ the query parameters- -> InstagramT m (H.Request a) -- ^ the properly configured request+ -> InstagramT m H.Request -- ^ the properly configured request getDeleteRequest path query=do get<-getGetRequest path query return $ get {H.method=HT.methodDelete}@@ -153,7 +154,7 @@ -- | perform a HTTP request and deal with the JSON result igReq :: forall b (m :: * -> *) wrappedErr . (MonadBaseControl IO m, C.MonadResource m,FromJSON b,FromJSON wrappedErr) =>- H.Request (InstagramT m)+ H.Request -> (wrappedErr -> IGError) -- ^ extract the error from the JSON -> InstagramT m b igReq req extractError=do@@ -190,7 +191,7 @@ -- instagram returns either a result, or an error getJSONResponse :: forall (m :: * -> *) v. (MonadBaseControl IO m, C.MonadResource m,FromJSON v) =>- H.Request (InstagramT m)+ H.Request -> InstagramT m v getJSONResponse req=igReq req id@@ -199,7 +200,7 @@ -- the error is wrapped inside the envelope getJSONEnvelope :: forall (m :: * -> *) v. (MonadBaseControl IO m, C.MonadResource m,FromJSON v) =>- H.Request (InstagramT m)+ H.Request -> InstagramT m (Envelope v) getJSONEnvelope req=igReq req eeMeta@@ -254,7 +255,7 @@ -- | utility function to get an envelop, independently of how the request is built getEnvelopeM :: (MonadBaseControl IO m, C.MonadResource m,HT.QueryLike ql,FromJSON v) =>- (ByteString -> HT.Query -> InstagramT m (H.Request (InstagramT m))) -- ^ the request building method + (ByteString -> HT.Query -> InstagramT m H.Request) -- ^ the request building method -> [T.Text] -- ^ the URL components, will be concatenated -> Maybe OAuthToken -- ^ the access token -> ql -- ^ the query parameters