packages feed

ig 0.3 → 0.3.1

raw patch · 4 files changed

+50/−2 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Instagram: FollowParams :: Int -> FollowParams
+ Instagram: data FollowParams
+ Instagram: fpCount :: FollowParams -> Int
+ Instagram: getFollowedByParams :: (MonadBaseControl IO m, MonadResource m) => UserID -> Maybe OAuthToken -> FollowParams -> InstagramT m (Envelope [User])
+ Instagram: getFollowsParams :: (MonadBaseControl IO m, MonadResource m) => UserID -> Maybe OAuthToken -> FollowParams -> InstagramT m (Envelope [User])
+ Instagram: getNextPage :: (MonadBaseControl IO m, MonadResource m, FromJSON v) => Envelope v -> InstagramT m (Maybe (Envelope v))

Files

ig.cabal view
@@ -1,5 +1,5 @@ name:                ig-version:             0.3+version:             0.3.1 synopsis:            Bindings to Instagram's API. homepage:            https://github.com/prowdsponsor/ig license:             BSD3
src/Instagram.hs view
@@ -20,6 +20,7 @@      -- data   ,Envelope(..)+  ,getNextPage   ,Pagination(..)   ,Media(..)   ,Position(..)@@ -71,6 +72,9 @@   ,Relationship(..)   ,getFollows   ,getFollowedBy+  ,FollowParams(..)+  ,getFollowsParams+  ,getFollowedByParams   ,getRequestedBy   ,getRelationship   ,setRelationShip
src/Instagram/Monad.hs view
@@ -19,6 +19,7 @@   ,getPostEnvelopeM   ,getDeleteEnvelope   ,getDeleteEnvelopeM+  ,getNextPage   ,getManager   ,runResourceInIs   ,mapInstagramT@@ -61,7 +62,7 @@ import Data.Conduit.Attoparsec (sinkParser, ParseError) import Control.Exception.Base (throw) import qualified Data.Text.Encoding as TE-import qualified Data.Text as T (Text,concat)+import qualified Data.Text as T (Text,concat, unpack) import Data.Time.Clock.POSIX (POSIXTime)  #if DEBUG@@ -283,6 +284,22 @@ getEnvelopeM f urlComponents token ql=do    let url=TE.encodeUtf8 $ T.concat urlComponents    addTokenM token ql >>= f url >>= getJSONEnvelope++-- | Use the pagination links in an 'Envelope' to fetch the next page of+-- results.+--+-- If the Envelope has no pagination, or we have reached the final page+-- (indicated by the pNextUrl field being missing), returns Nothing.+getNextPage :: (MonadBaseControl IO m, R.MonadResource m, FromJSON v)+            => Envelope v+            -> InstagramT m (Maybe (Envelope v))+getNextPage e = case maybeRequest of+    Nothing -> return Nothing+    Just req -> Just <$> getJSONEnvelope req+  where+    maybeRequest = do  -- Maybe monad+        nextUrl <- pNextUrl =<< ePagination e+        H.parseUrl $ T.unpack nextUrl  -- | Get the 'H.Manager'. getManager :: Monad m => InstagramT m H.Manager
src/Instagram/Relationships.hs view
@@ -4,10 +4,13 @@ module Instagram.Relationships (   getFollows   ,getFollowedBy+  ,getFollowsParams+  ,getFollowedByParams   ,getRequestedBy   ,getRelationship   ,setRelationShip   ,RelationShipAction(..)+  ,FollowParams(..) )where  import Instagram.Monad@@ -30,6 +33,30 @@   -> Maybe OAuthToken   -> InstagramT m (Envelope [User]) getFollowedBy uid token  =getGetEnvelopeM ["/v1/users/",uid,"/followed-by"] token ([]::HT.Query)++data FollowParams = FollowParams {+    fpCount :: Int+    } deriving (Show, Read, Eq, Ord)++instance HT.QueryLike FollowParams where+  toQuery FollowParams{fpCount=count} =+    ["count" ?+ show count]++-- | Get the list of users this user follows.+getFollowsParams :: (MonadBaseControl IO m, MonadResource m) => UserID+  -> Maybe OAuthToken+  -> FollowParams+  -> InstagramT m (Envelope [User])+getFollowsParams uid token fp =+  getGetEnvelopeM ["/v1/users/",uid,"/follows"] token fp++-- | Get the list of users this user is followed by.+getFollowedByParams :: (MonadBaseControl IO m, MonadResource m) => UserID+  -> Maybe OAuthToken+  -> FollowParams+  -> InstagramT m (Envelope [User])+getFollowedByParams uid token fp =+  getGetEnvelopeM ["/v1/users/",uid,"/followed-by"] token fp  -- | List the users who have requested this user's permission to follow. getRequestedBy ::     (MonadBaseControl IO m, MonadResource m) =>