Commit ab2be462 authored by Joshua Roesslein's avatar Joshua Roesslein
Browse files

Merge pull request #156 from kodkultur/master

Implemented /friendships/lookup
parents 65a26c2b aa055fe1
......@@ -279,6 +279,19 @@ class API(object):
'target_id', 'target_screen_name']
)
""" Perform bulk look up of friendships from user ID or screenname """
def lookup_friendships(self, user_ids=None, screen_names=None):
return self._lookup_friendships(list_to_csv(user_ids), list_to_csv(screen_names))
_lookup_friendships = bind_api(
path = '/friendships/lookup.json',
payload_type = 'relationship', payload_list = True,
allowed_param = ['user_id', 'screen_name'],
require_auth = True
)
""" friends/ids """
friends_ids = bind_api(
path = '/friends/ids.json',
......
......@@ -292,6 +292,17 @@ class Relation(Model):
setattr(result, k, v)
return result
class Relationship(Model):
@classmethod
def parse(cls, api, json):
result = cls(api)
for k,v in json.items():
if k == 'connections':
setattr(result, 'is_following', 'following' in v)
setattr(result, 'is_followed_by', 'followed_by' in v)
else:
setattr(result, k, v)
return result
class JSONModel(Model):
......@@ -325,6 +336,7 @@ class ModelFactory(object):
search_result = SearchResult
list = List
relation = Relation
relationship = Relationship
json = JSONModel
ids = IDModel
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment