ig 0.2.2 → 0.3
raw patch · 3 files changed
+43/−6 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Instagram: UserCounts :: Int -> Int -> Int -> UserCounts
+ Instagram: data UserCounts
+ Instagram: uBio :: User -> Maybe Text
+ Instagram: uCounts :: User -> Maybe UserCounts
+ Instagram: ucFollowedBy :: UserCounts -> Int
+ Instagram: ucFollows :: UserCounts -> Int
+ Instagram: ucMedia :: UserCounts -> Int
- Instagram: User :: UserID -> Text -> Text -> Maybe Text -> Maybe Text -> User
+ Instagram: User :: UserID -> Text -> Text -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe UserCounts -> User
Files
- ig.cabal +1/−1
- src/Instagram.hs +1/−0
- src/Instagram/Types.hs +41/−5
ig.cabal view
@@ -1,5 +1,5 @@ name: ig-version: 0.2.2+version: 0.3 synopsis: Bindings to Instagram's API. homepage: https://github.com/prowdsponsor/ig license: BSD3
src/Instagram.hs view
@@ -15,6 +15,7 @@ ,OAuthToken(..) ,AccessToken(..) -- we open this type so that the api client can just use the token data outside of your type (as a simple Text) ,User(..)+ ,UserCounts(..) ,Scope(..) -- data
src/Instagram/Types.hs view
@@ -8,6 +8,7 @@ ,AccessToken(..) ,UserID ,User(..)+ ,UserCounts(..) ,Scope(..) ,IGException(..) ,Envelope(..)@@ -109,13 +110,22 @@ uUsername :: Text, uFullName :: Text, uProfilePicture :: Maybe Text,- uWebsite :: Maybe Text- } + uWebsite :: Maybe Text,+ uBio :: Maybe Text,+ uCounts :: Maybe UserCounts+ } deriving (Show,Read,Eq,Ord,Typeable) -- | to json as per Instagram format instance ToJSON User where- toJSON u=object ["id" .= uID u, "username" .= uUsername u , "full_name" .= uFullName u, "profile_picture" .= uProfilePicture u, "website" .= uWebsite u] + toJSON u = object+ [ "id" .= uID u+ , "username" .= uUsername u+ , "full_name" .= uFullName u+ , "profile_picture" .= uProfilePicture u+ , "website" .= uWebsite u+ , "bio" .= uBio u+ ] -- | from json as per Instagram format instance FromJSON User where@@ -124,9 +134,35 @@ v .: "username" <*> v .: "full_name" <*> v .:? "profile_picture" <*>- v .:? "website"+ v .:? "website" <*>+ v .:? "bio" <*>+ v .:? "counts" parseJSON _= fail "User"- ++-- | the User counts info returned by some endpoints+data UserCounts = UserCounts+ { ucMedia :: Int+ , ucFollows :: Int+ , ucFollowedBy :: Int+ }+ deriving (Show,Read,Eq,Ord,Typeable)++-- | from json as per Instagram format+instance FromJSON UserCounts where+ parseJSON (Object v) = UserCounts <$>+ v .: "media" <*>+ v .: "follows" <*>+ v .: "followed_by"+ parseJSON _= fail "UserCounts"++-- | to json as per Instagram format+instance ToJSON UserCounts where+ toJSON uc = object+ [ "media" .= ucMedia uc+ , "follows" .= ucFollows uc+ , "followed_by" .= ucFollowedBy uc+ ]+ -- | the scopes of the authentication data Scope=Basic | Comments | Relationships | Likes deriving (Show,Read,Eq,Ord,Enum,Bounded,Typeable)