module Instagram.Relationships (
getFollows
,getFollowedBy
,getFollowsParams
,getFollowedByParams
,getRequestedBy
,getRelationship
,setRelationShip
,RelationShipAction(..)
,FollowParams(..)
)where
import Instagram.Monad
import Instagram.Types
import Data.Typeable (Typeable)
import Data.String
import qualified Network.HTTP.Types as HT
import Data.Char (toLower)
getFollows :: (MonadBaseControl IO m, MonadResource m) => UserID
-> Maybe OAuthToken
-> InstagramT m (Envelope [User])
getFollows uid token =getGetEnvelopeM ["/v1/users/",uid,"/follows"] token ([]::HT.Query)
getFollowedBy :: (MonadBaseControl IO m, MonadResource m) => UserID
-> Maybe Int
-> Maybe OAuthToken
-> InstagramT m (Envelope [User])
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
} deriving (Show, Read, Eq, Ord)
instance HT.QueryLike FollowParams where
toQuery FollowParams{fpCount=count} =
["count" ?+ show count]
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
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
getRequestedBy :: (MonadBaseControl IO m, MonadResource m) =>
OAuthToken
-> InstagramT m (Envelope [User])
getRequestedBy token =getGetEnvelope ["/v1/users/self/requested-by"] token ([]::HT.Query)
getRelationship :: (MonadBaseControl IO m, MonadResource m) => UserID
-> OAuthToken
-> InstagramT m (Envelope Relationship)
getRelationship uid token =getGetEnvelope ["/v1/users/",uid,"/relationship"] token ([]::HT.Query)
data RelationShipAction = Follow
| Unfollow
| Block
| Unblock
| Approve
| Deny
deriving (Show,Read,Eq,Ord,Bounded,Enum,Typeable)
instance HT.QueryLike RelationShipAction where
toQuery a=
["action" ?+ map toLower (show a)]
setRelationShip :: (MonadBaseControl IO m, MonadResource m) => UserID
-> OAuthToken
-> RelationShipAction
-> InstagramT m (Envelope (Maybe Relationship))
setRelationShip uid=getPostEnvelope ["/v1/users/",uid,"/relationship"]