diff --git a/linkedin/linkedin.py b/linkedin/linkedin.py index 5c3a1b0..4fabf17 100644 --- a/linkedin/linkedin.py +++ b/linkedin/linkedin.py @@ -291,16 +291,16 @@ def leave_group(self, group_id): raise_for_error(response) return True - def submit_group_post(self, group_id, title, summary, submitted_url, - submitted_image_url, content_title, description): - post = { - 'title': title, 'summary': summary, - 'content': { + def submit_group_post(self, group_id, title, summary, submitted_url=None, + submitted_image_url=None, content_title=None, + description=None): + post = {'title': title, 'summary': summary} + if content_title and submitted_url: + post['content'] = { 'submitted-url': submitted_url, 'title': content_title, 'description': description } - } if submitted_image_url: post['content']['submitted-image-url'] = submitted_image_url @@ -541,3 +541,42 @@ def like_update(self, update_key, is_liked=True): response = self.make_request('PUT', url, data=json.dumps(is_liked)) raise_for_error(response) return True + + def get_post_likes(self, post_id, selectors=None, params=None, + headers=None): + url = '%s/%s/likes' % (ENDPOINTS.POSTS, post_id) + if selectors: + url = '%s:(%s)' % (url, LinkedInSelector.parse(selectors)) + + response = self.make_request('GET', url, params=params, headers=headers) + raise_for_error(response) + return response.json() + + def get_share_comments(self, post_id, selectors=None, params=None, + headers=None): + url = '%s/~/network/updates/key=%s/update-comments' % (ENDPOINTS.PEOPLE, + post_id) + if selectors: + url = '%s:(%s)' % (url, LinkedInSelector.parse(selectors)) + + response = self.make_request('GET', url, params=params, headers=headers) + raise_for_error(response) + return response.json() + + def get_share_likes(self, post_id, selectors=None, params=None, + headers=None): + url = '%s/~/network/updates/key=%s/likes' % (ENDPOINTS.PEOPLE, post_id) + if selectors: + url = '%s:(%s)' % (url, LinkedInSelector.parse(selectors)) + + response = self.make_request('GET', url, params=params, headers=headers) + raise_for_error(response) + return response.json() + + def comment_as_company(self, company_id, update_key, comment): + comment = {'comment': comment} + url = '%s/updates/key=%s/update-comments-as-company' % ( + ENDPOINTS.COMPANIES, company_id, update_key) + response = self.make_request('PUT', url, data=json.dumps(comment)) + raise_for_error(response) + return True