ig 0.5.1 → 0.6
raw patch · 5 files changed
+37/−20 lines, 5 filesdep +attoparsecPVP ok
version bump matches the API change (PVP)
Dependencies added: attoparsec
API changes (from Hackage documentation)
- Instagram: cClientID :: Credentials -> Text
- Instagram: cClientSecret :: Credentials -> Text
- Instagram: cCount :: Collection a -> Integer
- Instagram: cCreated :: Comment -> POSIXTime
- Instagram: cData :: Collection a -> [a]
- Instagram: cFrom :: Comment -> User
- Instagram: cID :: Comment -> CommentID
- Instagram: cText :: Comment -> Text
- Instagram: doID :: DeletionParams -> Text
- Instagram: eData :: Envelope d -> d
- Instagram: eMeta :: Envelope d -> IGError
- Instagram: ePagination :: Envelope d -> Maybe Pagination
- Instagram: fpCount :: FollowParams -> Int
- Instagram: gmpCount :: GeographyMediaParams -> Maybe Integer
- Instagram: gmpMinId :: GeographyMediaParams -> Maybe Text
- Instagram: grLatitude :: SubscriptionRequest -> Double
- Instagram: grLongitude :: SubscriptionRequest -> Double
- Instagram: grRadius :: SubscriptionRequest -> Integer
- Instagram: iLowRes :: Images -> ImageData
- Instagram: iStandardRes :: Images -> ImageData
- Instagram: iThumbnail :: Images -> ImageData
- Instagram: idHeight :: ImageData -> Integer
- Instagram: idURL :: ImageData -> Text
- Instagram: idWidth :: ImageData -> Integer
- Instagram: igeCode :: IGError -> Int
- Instagram: igeMessage :: IGError -> Maybe Text
- Instagram: igeType :: IGError -> Maybe Text
- Instagram: lID :: Location -> Maybe LocationID
- Instagram: lLatitude :: Location -> Maybe Double
- Instagram: lLongitude :: Location -> Maybe Double
- Instagram: lName :: Location -> Maybe Text
- Instagram: lStreetAddress :: Location -> Maybe Text
- Instagram: lmspMaxID :: LocationMediaParams -> Maybe Text
- Instagram: lmspMaxTimestamp :: LocationMediaParams -> Maybe POSIXTime
- Instagram: lmspMinId :: LocationMediaParams -> Maybe Text
- Instagram: lmspMinTimestamp :: LocationMediaParams -> Maybe POSIXTime
- Instagram: lrID :: SubscriptionRequest -> Text
- Instagram: lspDistance :: LocationSearchParams -> Maybe Integer
- Instagram: lspFoursquareID :: LocationSearchParams -> Maybe Text
- Instagram: lspFoursquareIDv2 :: LocationSearchParams -> Maybe Text
- Instagram: lspLatitude :: LocationSearchParams -> Maybe Double
- Instagram: lspLongitude :: LocationSearchParams -> Maybe Double
- Instagram: mAttribution :: Media -> Maybe Object
- Instagram: mCaption :: Media -> Maybe Comment
- Instagram: mComments :: Media -> Collection Comment
- Instagram: mCreated :: Media -> POSIXTime
- Instagram: mFilter :: Media -> Maybe Text
- Instagram: mID :: Media -> MediaID
- Instagram: mImages :: Media -> Images
- Instagram: mLikes :: Media -> Collection User
- Instagram: mLink :: Media -> Text
- Instagram: mLocation :: Media -> Maybe Location
- Instagram: mTags :: Media -> [Text]
- Instagram: mType :: Media -> Text
- Instagram: mUser :: Media -> User
- Instagram: mUserHasLiked :: Media -> Bool
- Instagram: mUsersInPhoto :: Media -> [UserPosition]
- Instagram: mspDistance :: MediaSearchParams -> Maybe Integer
- Instagram: mspLatitude :: MediaSearchParams -> Maybe Double
- Instagram: mspLongitude :: MediaSearchParams -> Maybe Double
- Instagram: mspMaxTimestamp :: MediaSearchParams -> Maybe POSIXTime
- Instagram: mspMinTimestamp :: MediaSearchParams -> Maybe POSIXTime
- Instagram: oaAccessToken :: OAuthToken -> AccessToken
- Instagram: oaUser :: OAuthToken -> User
- Instagram: pMinTagID :: Pagination -> Maybe Text
- Instagram: pNextMaxID :: Pagination -> Maybe Text
- Instagram: pNextMaxTagID :: Pagination -> Maybe Text
- Instagram: pNextMinID :: Pagination -> Maybe Text
- Instagram: pNextUrl :: Pagination -> Maybe Text
- Instagram: pX :: Position -> Double
- Instagram: pY :: Position -> Double
- Instagram: rIncoming :: Relationship -> IncomingStatus
- Instagram: rOutgoing :: Relationship -> OutgoingStatus
- Instagram: rTargetUserPrivate :: Relationship -> Bool
- Instagram: rpCount :: RecentParams -> Maybe Integer
- Instagram: rpMaxID :: RecentParams -> Maybe Text
- Instagram: rpMaxTimestamp :: RecentParams -> Maybe POSIXTime
- Instagram: rpMinId :: RecentParams -> Maybe Text
- Instagram: rpMinTimestamp :: RecentParams -> Maybe POSIXTime
- Instagram: rtpMaxID :: RecentTagParams -> Maybe Text
- Instagram: rtpMinID :: RecentTagParams -> Maybe Text
- Instagram: sAspect :: Subscription -> Aspect
- Instagram: sCallbackUrl :: Subscription -> CallbackUrl
- Instagram: sID :: Subscription -> Text
- Instagram: sLatitude :: Subscription -> Maybe Double
- Instagram: sLongitude :: Subscription -> Maybe Double
- Instagram: sObject :: Subscription -> Text
- Instagram: sObjectID :: Subscription -> Maybe Text
- Instagram: sRadius :: Subscription -> Maybe Integer
- Instagram: sType :: Subscription -> Text
- Instagram: sfpCount :: SelfFeedParams -> Maybe Integer
- Instagram: sfpMaxID :: SelfFeedParams -> Maybe Text
- Instagram: sfpMinId :: SelfFeedParams -> Maybe Text
- Instagram: slpCount :: SelfLikedParams -> Maybe Integer
- Instagram: slpMaxLikeID :: SelfLikedParams -> Maybe Text
- Instagram: spAspect :: SubscriptionParams -> Aspect
- Instagram: spCallback :: SubscriptionParams -> CallbackUrl
- Instagram: spRequest :: SubscriptionParams -> SubscriptionRequest
- Instagram: spVerifyToken :: SubscriptionParams -> Maybe Text
- Instagram: tMediaCount :: Tag -> Integer
- Instagram: tName :: Tag -> TagName
- Instagram: trTag :: SubscriptionRequest -> Text
- Instagram: uBio :: User -> Maybe Text
- Instagram: uChangedAspect :: Update -> Aspect
- Instagram: uCounts :: User -> Maybe UserCounts
- Instagram: uFullName :: User -> Text
- Instagram: uID :: User -> UserID
- Instagram: uObject :: Update -> Text
- Instagram: uObjectID :: Update -> Text
- Instagram: uProfilePicture :: User -> Maybe Text
- Instagram: uSubscriptionID :: Update -> Integer
- Instagram: uTime :: Update -> POSIXTime
- Instagram: uUsername :: User -> Text
- Instagram: uWebsite :: User -> Maybe Text
- Instagram: ucFollowedBy :: UserCounts -> Int
- Instagram: ucFollows :: UserCounts -> Int
- Instagram: ucMedia :: UserCounts -> Int
- Instagram: upPosition :: UserPosition -> Position
- Instagram: upUser :: UserPosition -> User
- Instagram: uspCount :: UserSearchParams -> Maybe Integer
- Instagram: uspQuery :: UserSearchParams -> Text
+ Instagram: [cClientID] :: Credentials -> Text
+ Instagram: [cClientSecret] :: Credentials -> Text
+ Instagram: [cCount] :: Collection a -> Integer
+ Instagram: [cCreated] :: Comment -> POSIXTime
+ Instagram: [cData] :: Collection a -> [a]
+ Instagram: [cFrom] :: Comment -> User
+ Instagram: [cID] :: Comment -> CommentID
+ Instagram: [cText] :: Comment -> Text
+ Instagram: [doID] :: DeletionParams -> Text
+ Instagram: [eData] :: Envelope d -> d
+ Instagram: [eMeta] :: Envelope d -> IGError
+ Instagram: [ePagination] :: Envelope d -> Maybe Pagination
+ Instagram: [fpCount] :: FollowParams -> Int
+ Instagram: [gmpCount] :: GeographyMediaParams -> Maybe Integer
+ Instagram: [gmpMinId] :: GeographyMediaParams -> Maybe Text
+ Instagram: [grLatitude] :: SubscriptionRequest -> Double
+ Instagram: [grLongitude] :: SubscriptionRequest -> Double
+ Instagram: [grRadius] :: SubscriptionRequest -> Integer
+ Instagram: [iLowRes] :: Images -> ImageData
+ Instagram: [iStandardRes] :: Images -> ImageData
+ Instagram: [iThumbnail] :: Images -> ImageData
+ Instagram: [idHeight] :: ImageData -> Integer
+ Instagram: [idURL] :: ImageData -> Text
+ Instagram: [idWidth] :: ImageData -> Integer
+ Instagram: [igeCode] :: IGError -> Int
+ Instagram: [igeMessage] :: IGError -> Maybe Text
+ Instagram: [igeType] :: IGError -> Maybe Text
+ Instagram: [lID] :: Location -> Maybe LocationID
+ Instagram: [lLatitude] :: Location -> Maybe Double
+ Instagram: [lLongitude] :: Location -> Maybe Double
+ Instagram: [lName] :: Location -> Maybe Text
+ Instagram: [lStreetAddress] :: Location -> Maybe Text
+ Instagram: [lmspMaxID] :: LocationMediaParams -> Maybe Text
+ Instagram: [lmspMaxTimestamp] :: LocationMediaParams -> Maybe POSIXTime
+ Instagram: [lmspMinId] :: LocationMediaParams -> Maybe Text
+ Instagram: [lmspMinTimestamp] :: LocationMediaParams -> Maybe POSIXTime
+ Instagram: [lrID] :: SubscriptionRequest -> Text
+ Instagram: [lspDistance] :: LocationSearchParams -> Maybe Integer
+ Instagram: [lspFoursquareID] :: LocationSearchParams -> Maybe Text
+ Instagram: [lspFoursquareIDv2] :: LocationSearchParams -> Maybe Text
+ Instagram: [lspLatitude] :: LocationSearchParams -> Maybe Double
+ Instagram: [lspLongitude] :: LocationSearchParams -> Maybe Double
+ Instagram: [mAttribution] :: Media -> Maybe Object
+ Instagram: [mCaption] :: Media -> Maybe Comment
+ Instagram: [mComments] :: Media -> Collection Comment
+ Instagram: [mCreated] :: Media -> POSIXTime
+ Instagram: [mFilter] :: Media -> Maybe Text
+ Instagram: [mID] :: Media -> MediaID
+ Instagram: [mImages] :: Media -> Images
+ Instagram: [mLikes] :: Media -> Collection User
+ Instagram: [mLink] :: Media -> Text
+ Instagram: [mLocation] :: Media -> Maybe Location
+ Instagram: [mTags] :: Media -> [Text]
+ Instagram: [mType] :: Media -> Text
+ Instagram: [mUserHasLiked] :: Media -> Bool
+ Instagram: [mUser] :: Media -> User
+ Instagram: [mUsersInPhoto] :: Media -> [UserPosition]
+ Instagram: [mspDistance] :: MediaSearchParams -> Maybe Integer
+ Instagram: [mspLatitude] :: MediaSearchParams -> Maybe Double
+ Instagram: [mspLongitude] :: MediaSearchParams -> Maybe Double
+ Instagram: [mspMaxTimestamp] :: MediaSearchParams -> Maybe POSIXTime
+ Instagram: [mspMinTimestamp] :: MediaSearchParams -> Maybe POSIXTime
+ Instagram: [oaAccessToken] :: OAuthToken -> AccessToken
+ Instagram: [oaUser] :: OAuthToken -> User
+ Instagram: [pMinTagID] :: Pagination -> Maybe Text
+ Instagram: [pNextMaxID] :: Pagination -> Maybe Text
+ Instagram: [pNextMaxTagID] :: Pagination -> Maybe Text
+ Instagram: [pNextMinID] :: Pagination -> Maybe Text
+ Instagram: [pNextUrl] :: Pagination -> Maybe Text
+ Instagram: [pX] :: Position -> Double
+ Instagram: [pY] :: Position -> Double
+ Instagram: [rIncoming] :: Relationship -> IncomingStatus
+ Instagram: [rOutgoing] :: Relationship -> OutgoingStatus
+ Instagram: [rTargetUserPrivate] :: Relationship -> Bool
+ Instagram: [rpCount] :: RecentParams -> Maybe Integer
+ Instagram: [rpMaxID] :: RecentParams -> Maybe Text
+ Instagram: [rpMaxTimestamp] :: RecentParams -> Maybe POSIXTime
+ Instagram: [rpMinId] :: RecentParams -> Maybe Text
+ Instagram: [rpMinTimestamp] :: RecentParams -> Maybe POSIXTime
+ Instagram: [rtpMaxID] :: RecentTagParams -> Maybe Text
+ Instagram: [rtpMinID] :: RecentTagParams -> Maybe Text
+ Instagram: [sAspect] :: Subscription -> Aspect
+ Instagram: [sCallbackUrl] :: Subscription -> CallbackUrl
+ Instagram: [sID] :: Subscription -> Text
+ Instagram: [sLatitude] :: Subscription -> Maybe Double
+ Instagram: [sLongitude] :: Subscription -> Maybe Double
+ Instagram: [sObjectID] :: Subscription -> Maybe Text
+ Instagram: [sObject] :: Subscription -> Text
+ Instagram: [sRadius] :: Subscription -> Maybe Integer
+ Instagram: [sType] :: Subscription -> Text
+ Instagram: [sfpCount] :: SelfFeedParams -> Maybe Integer
+ Instagram: [sfpMaxID] :: SelfFeedParams -> Maybe Text
+ Instagram: [sfpMinId] :: SelfFeedParams -> Maybe Text
+ Instagram: [slpCount] :: SelfLikedParams -> Maybe Integer
+ Instagram: [slpMaxLikeID] :: SelfLikedParams -> Maybe Text
+ Instagram: [spAspect] :: SubscriptionParams -> Aspect
+ Instagram: [spCallback] :: SubscriptionParams -> CallbackUrl
+ Instagram: [spRequest] :: SubscriptionParams -> SubscriptionRequest
+ Instagram: [spVerifyToken] :: SubscriptionParams -> Maybe Text
+ Instagram: [tMediaCount] :: Tag -> Integer
+ Instagram: [tName] :: Tag -> TagName
+ Instagram: [trTag] :: SubscriptionRequest -> Text
+ Instagram: [uBio] :: User -> Maybe Text
+ Instagram: [uChangedAspect] :: Update -> Aspect
+ Instagram: [uCounts] :: User -> Maybe UserCounts
+ Instagram: [uFullName] :: User -> Text
+ Instagram: [uID] :: User -> UserID
+ Instagram: [uObjectID] :: Update -> Text
+ Instagram: [uObject] :: Update -> Text
+ Instagram: [uProfilePicture] :: User -> Maybe Text
+ Instagram: [uSubscriptionID] :: Update -> Integer
+ Instagram: [uTime] :: Update -> POSIXTime
+ Instagram: [uUsername] :: User -> Text
+ Instagram: [uWebsite] :: User -> Maybe Text
+ Instagram: [ucFollowedBy] :: UserCounts -> Int
+ Instagram: [ucFollows] :: UserCounts -> Int
+ Instagram: [ucMedia] :: UserCounts -> Int
+ Instagram: [upPosition] :: UserPosition -> Position
+ Instagram: [upUser] :: UserPosition -> User
+ Instagram: [uspCount] :: UserSearchParams -> Maybe Integer
+ Instagram: [uspQuery] :: UserSearchParams -> Text
+ Instagram: getLikesMaxId :: (MonadBaseControl IO m, MonadResource m) => MediaID -> Maybe UserID -> Maybe OAuthToken -> InstagramT m (Envelope [User])
- Instagram: getFollowedBy :: (MonadBaseControl IO m, MonadResource m) => UserID -> Maybe OAuthToken -> InstagramT m (Envelope [User])
+ Instagram: getFollowedBy :: (MonadBaseControl IO m, MonadResource m) => UserID -> Maybe Int -> Maybe OAuthToken -> InstagramT m (Envelope [User])
Files
- ig.cabal +2/−1
- src/Instagram.hs +11/−12
- src/Instagram/Likes.hs +13/−2
- src/Instagram/Relationships.hs +7/−2
- src/Instagram/Types.hs +4/−3
ig.cabal view
@@ -1,5 +1,5 @@ name: ig-version: 0.5.1+version: 0.6 synopsis: Bindings to Instagram's API. homepage: https://github.com/prowdsponsor/ig license: BSD3@@ -50,6 +50,7 @@ , resourcet , http-types , http-conduit >= 2.0 && < 2.2+ , attoparsec >= 0.10 && < 0.13 , aeson >= 0.5 , time , data-default
src/Instagram.hs view
@@ -18,7 +18,7 @@ ,User(..) ,UserCounts(..) ,Scope(..)- + -- data ,Envelope(..) ,getNextPage@@ -32,7 +32,7 @@ ,Comment(..) ,Collection(..) ,NoResult- + -- user ,UserID ,getUser@@ -44,7 +44,7 @@ ,getSelfLiked ,UserSearchParams(..) ,searchUsers- + -- real time ,Aspect -- do not export constructor since only media is supported ,media@@ -58,7 +58,7 @@ ,DeletionParams(..) ,Update(..) ,verifySignature- + -- Tags ,Tag(..) ,TagName@@ -66,7 +66,7 @@ ,RecentTagParams(..) ,getRecentTagged ,searchTags- + -- relationships ,OutgoingStatus(..) ,IncomingStatus(..)@@ -80,25 +80,26 @@ ,getRelationship ,setRelationShip ,RelationShipAction(..)- + -- media ,MediaID ,getMedia ,getPopularMedia ,MediaSearchParams(..) ,searchMedia- + -- comments ,CommentID ,getComments ,postComment ,deleteComment- + -- likes ,getLikes+ , getLikesMaxId ,like ,unlike- + -- locations ,LocationID ,getLocation@@ -106,7 +107,7 @@ ,getLocationRecentMedia ,LocationSearchParams(..) ,searchLocations- + -- geographies ,GeographyID ,GeographyMediaParams(..)@@ -138,5 +139,3 @@ -- let d=eitherDecode t -- print (d::Either String (Envelope [Media])) -- return()- -
src/Instagram/Likes.hs view
@@ -1,15 +1,17 @@-{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleContexts, OverloadedStrings #-} -- | Likes handling -- <http://instagram.com/developer/endpoints/likes/#> module Instagram.Likes ( getLikes+ ,getLikesMaxId ,like ,unlike )where import Instagram.Monad import Instagram.Types-+import Data.String+import qualified Data.Text as T import qualified Network.HTTP.Types as HT @@ -18,6 +20,15 @@ -> Maybe OAuthToken -> InstagramT m (Envelope [User]) getLikes mid token =getGetEnvelopeM ["/v1/media/",mid,"/likes"] token ([]::HT.Query)++getLikesMaxId :: (MonadBaseControl IO m, MonadResource m) => MediaID+ -> Maybe UserID+ -> Maybe OAuthToken+ -> InstagramT m (Envelope [User])+getLikesMaxId mid Nothing token =getGetEnvelopeM ["/v1/media/",mid,"/likes"] token ([]::HT.Query)+getLikesMaxId mid (Just maxUserId) token =+ let maxid = (T.unpack maxUserId) :: String+ in getGetEnvelopeM ["/v1/media/",mid,"/likes"] token ([("MAX_ID", Just $ fromString $ maxid)]::HT.Query) -- | Set a like on this media by the currently authenticated user. like :: (MonadBaseControl IO m, MonadResource m) => MediaID
src/Instagram/Relationships.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleContexts, OverloadedStrings #-} -- | relationship handling -- <http://instagram.com/developer/endpoints/relationships/#> module Instagram.Relationships (@@ -17,6 +17,7 @@ import Instagram.Types import Data.Typeable (Typeable)+import Data.String import qualified Network.HTTP.Types as HT import Data.Char (toLower)@@ -30,9 +31,13 @@ -- | Get the list of users this user is followed by. getFollowedBy :: (MonadBaseControl IO m, MonadResource m) => UserID+ -> Maybe Int -> Maybe OAuthToken -> InstagramT m (Envelope [User])-getFollowedBy uid token =getGetEnvelopeM ["/v1/users/",uid,"/followed-by"] token ([]::HT.Query)+getFollowedBy uid Nothing token =getGetEnvelopeM ["/v1/users/",uid,"/followed-by"] token ([]::HT.Query)+getFollowedBy uid (Just count) token =getGetEnvelopeM ["/v1/users/",uid,"/followed-by"]+ token+ ([("count", Just $ fromString $ show count)]::HT.Query) data FollowParams = FollowParams { fpCount :: Int
src/Instagram/Types.hs view
@@ -43,6 +43,7 @@ import Control.Applicative import Data.Text import Data.Typeable (Typeable)+import Data.Data (Data) import Data.ByteString (ByteString) import Data.Aeson@@ -60,7 +61,7 @@ cClientID :: Text -- ^ client id ,cClientSecret :: Text -- ^ client secret }- deriving (Show,Read,Eq,Ord,Typeable)+ deriving (Show,Read,Eq,Ord,Typeable, Data) -- | get client id in ByteString form clientIDBS :: Credentials -> ByteString@@ -125,6 +126,7 @@ , "profile_picture" .= uProfilePicture u , "website" .= uWebsite u , "bio" .= uBio u+ , "counts" .= uCounts u ] -- | from json as per Instagram format@@ -373,7 +375,7 @@ parseID :: Object -> Parser (Maybe LocationID) parseID obj=case HM.lookup "id" obj of Just (String s)->pure $ Just s- Just (Number n)->pure $ Just $ T.pack $ show n+ Just (Number n)->pure $ Just $ T.pack $ show $ (round n :: Int) Nothing->pure Nothing _->fail "LocationID" parseJSON _= fail "Location"@@ -640,4 +642,3 @@ -- | geography ID type GeographyID = Text-