<s> from __future__ import unicode_literals <EOL> import contextlib <EOL> import hashlib <EOL> import random <EOL> try : <EOL> from urllib . parse import quote , quote_plus <EOL> except ImportError : <EOL> from urllib import quote , quote_plus <EOL> import requests <EOL> from requests_oauthlib import OAuth1 <EOL> from . exceptions import LinkedInError <EOL> from . models import AccessToken , LinkedInInvitation , LinkedInMessage <EOL> from . utils import enum , to_utf8 , raise_for_error , json , StringIO <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> PERMISSIONS = enum ( '<STR_LIT>' , <EOL> COMPANY_ADMIN = '<STR_LIT>' , <EOL> BASIC_PROFILE = '<STR_LIT>' , <EOL> FULL_PROFILE = '<STR_LIT>' , <EOL> EMAIL_ADDRESS = '<STR_LIT>' , <EOL> NETWORK = '<STR_LIT>' , <EOL> CONTACT_INFO = '<STR_LIT>' , <EOL> NETWORK_UPDATES = '<STR_LIT>' , <EOL> GROUPS = '<STR_LIT>' , <EOL> MESSAGES = '<STR_LIT>' ) <EOL> ENDPOINTS = enum ( '<STR_LIT>' , <EOL> PEOPLE = '<STR_LIT>' , <EOL> PEOPLE_SEARCH = '<STR_LIT>' , <EOL> GROUPS = '<STR_LIT>' , <EOL> POSTS = '<STR_LIT>' , <EOL> COMPANIES = '<STR_LIT>' , <EOL> COMPANY_SEARCH = '<STR_LIT>' , <EOL> JOBS = '<STR_LIT>' , <EOL> JOB_SEARCH = '<STR_LIT>' ) <EOL> NETWORK_UPDATES = enum ( '<STR_LIT>' , <EOL> APPLICATION = '<STR_LIT>' , <EOL> COMPANY = '<STR_LIT>' , <EOL> CONNECTION = '<STR_LIT>' , <EOL> JOB = '<STR_LIT>' , <EOL> GROUP = '<STR_LIT>' , <EOL> PICTURE = '<STR_LIT>' , <EOL> EXTENDED_PROFILE = '<STR_LIT>' , <EOL> CHANGED_PROFILE = '<STR_LIT>' , <EOL> SHARED = '<STR_LIT>' , <EOL> VIRAL = '<STR_LIT>' ) <EOL> class LinkedInDeveloperAuthentication ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , consumer_key , consumer_secret , user_token , user_secret , <EOL> redirect_uri , permissions = [ ] ) : <EOL> self . consumer_key = consumer_key <EOL> self . consumer_secret = consumer_secret <EOL> self . user_token = user_token <EOL> self . user_secret = user_secret <EOL> self . redirect_uri = redirect_uri <EOL> self . permissions = permissions <EOL> class LinkedInAuthentication ( object ) : <EOL> """<STR_LIT>""" <EOL> AUTHORIZATION_URL = '<STR_LIT>' <EOL> ACCESS_TOKEN_URL = '<STR_LIT>' <EOL> def __init__ ( self , key , secret , redirect_uri , permissions = None ) : <EOL> self . key = key <EOL> self . secret = secret <EOL> self . redirect_uri = redirect_uri <EOL> self . permissions = permissions or [ ] <EOL> self . state = None <EOL> self . authorization_code = None <EOL> self . token = None <EOL> self . _error = None <EOL> @ property <EOL> def authorization_url ( self ) : <EOL> qd = { '<STR_LIT>' : '<STR_LIT:code>' , <EOL> '<STR_LIT>' : self . key , <EOL> '<STR_LIT>' : ( '<STR_LIT:U+0020>' . join ( self . permissions ) ) . strip ( ) , <EOL> '<STR_LIT:state>' : self . state or self . _make_new_state ( ) , <EOL> '<STR_LIT>' : self . redirect_uri } <EOL> qsl = [ '<STR_LIT>' % ( quote ( k ) , quote ( v ) ) for k , v in qd . items ( ) ] <EOL> return '<STR_LIT>' % ( self . AUTHORIZATION_URL , '<STR_LIT:&>' . join ( qsl ) ) <EOL> @ property <EOL> def last_error ( self ) : <EOL> return self . _error <EOL> def _make_new_state ( self ) : <EOL> return hashlib . md5 ( <EOL> '<STR_LIT>' . format ( random . randrange ( <NUM_LIT:0> , <NUM_LIT:2> ** <NUM_LIT> ) , self . secret ) . encode ( "<STR_LIT:utf8>" ) <EOL> ) . hexdigest ( ) <EOL> def get_access_token ( self , timeout = <NUM_LIT> ) : <EOL> assert self . authorization_code , '<STR_LIT>' <EOL> qd = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:code>' : self . authorization_code , <EOL> '<STR_LIT>' : self . redirect_uri , <EOL> '<STR_LIT>' : self . key , <EOL> '<STR_LIT>' : self . secret } <EOL> response = requests . post ( self . ACCESS_TOKEN_URL , data = qd , timeout = timeout ) <EOL> raise_for_error ( response ) <EOL> response = response . json ( ) <EOL> self . token = AccessToken ( response [ '<STR_LIT>' ] , response [ '<STR_LIT>' ] ) <EOL> return self . token <EOL> class LinkedInSelector ( object ) : <EOL> @ classmethod <EOL> def parse ( cls , selector ) : <EOL> with contextlib . closing ( StringIO ( ) ) as result : <EOL> if type ( selector ) == dict : <EOL> for k , v in selector . items ( ) : <EOL> result . write ( '<STR_LIT>' % ( to_utf8 ( k ) , cls . parse ( v ) ) ) <EOL> elif type ( selector ) in ( list , tuple ) : <EOL> result . write ( '<STR_LIT:U+002C>' . join ( map ( cls . parse , selector ) ) ) <EOL> else : <EOL> result . write ( to_utf8 ( selector ) ) <EOL> return result . getvalue ( ) <EOL> class LinkedInApplication ( object ) : <EOL> BASE_URL = '<STR_LIT>' <EOL> def __init__ ( self , authentication = None , token = None ) : <EOL> assert authentication or token , '<STR_LIT>' <EOL> self . authentication = authentication <EOL> if not self . authentication : <EOL> self . authentication = LinkedInAuthentication ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . authentication . token = AccessToken ( token , None ) <EOL> def make_request ( self , method , url , data = None , params = None , headers = None , <EOL> timeout = <NUM_LIT> ) : <EOL> if headers is None : <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } <EOL> else : <EOL> headers . update ( { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> if params is None : <EOL> params = { } <EOL> kw = dict ( data = data , params = params , <EOL> headers = headers , timeout = timeout ) <EOL> if isinstance ( self . authentication , LinkedInDeveloperAuthentication ) : <EOL> auth = OAuth1 ( self . authentication . consumer_key , self . authentication . consumer_secret , <EOL> self . authentication . user_token , self . authentication . user_secret ) <EOL> kw . update ( { '<STR_LIT>' : auth } ) <EOL> else : <EOL> params . update ( { '<STR_LIT>' : self . authentication . token . access_token } ) <EOL> return requests . request ( method . upper ( ) , url , ** kw ) <EOL> def get_profile ( self , member_id = None , member_url = None , selectors = None , <EOL> params = None , headers = None ) : <EOL> if member_id : <EOL> if type ( member_id ) is list : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE , <EOL> '<STR_LIT:U+002C>' . join ( member_id ) ) <EOL> else : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE , str ( member_id ) ) <EOL> elif member_url : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE , quote_plus ( member_url ) ) <EOL> else : <EOL> url = '<STR_LIT>' % ENDPOINTS . PEOPLE <EOL> if selectors : <EOL> url = '<STR_LIT>' % ( url , LinkedInSelector . parse ( selectors ) ) <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def search_profile ( self , selectors = None , params = None , headers = None ) : <EOL> if selectors : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE_SEARCH , <EOL> LinkedInSelector . parse ( selectors ) ) <EOL> else : <EOL> url = ENDPOINTS . PEOPLE_SEARCH <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def get_picture_urls ( self , member_id = None , member_url = None , <EOL> params = None , headers = None ) : <EOL> if member_id : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE , str ( member_id ) ) <EOL> elif member_url : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE , <EOL> quote_plus ( member_url ) ) <EOL> else : <EOL> url = '<STR_LIT>' % ENDPOINTS . PEOPLE <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def get_connections ( self , member_id = None , member_url = None , selectors = None , <EOL> params = None , headers = None ) : <EOL> if member_id : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE , str ( member_id ) ) <EOL> elif member_url : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE , <EOL> quote_plus ( member_url ) ) <EOL> else : <EOL> url = '<STR_LIT>' % ENDPOINTS . PEOPLE <EOL> if selectors : <EOL> url = '<STR_LIT>' % ( url , LinkedInSelector . parse ( selectors ) ) <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def get_memberships ( self , member_id = None , member_url = None , group_id = None , <EOL> selectors = None , params = None , headers = None ) : <EOL> if member_id : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE , str ( member_id ) ) <EOL> elif member_url : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE , <EOL> quote_plus ( member_url ) ) <EOL> else : <EOL> url = '<STR_LIT>' % ENDPOINTS . PEOPLE <EOL> if group_id : <EOL> url = '<STR_LIT>' % ( url , str ( group_id ) ) <EOL> if selectors : <EOL> url = '<STR_LIT>' % ( url , LinkedInSelector . parse ( selectors ) ) <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def get_group ( self , group_id , selectors = None , params = None , headers = None ) : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . GROUPS , str ( group_id ) ) <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def get_posts ( self , group_id , post_ids = None , selectors = None , params = None , <EOL> headers = None ) : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . GROUPS , str ( group_id ) ) <EOL> if post_ids : <EOL> url = '<STR_LIT>' % ( url , '<STR_LIT:U+002C>' . join ( map ( str , post_ids ) ) ) <EOL> if selectors : <EOL> url = '<STR_LIT>' % ( url , LinkedInSelector . parse ( selectors ) ) <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def get_post_comments ( self , post_id , selectors = None , params = None , headers = None ) : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . POSTS , post_id ) <EOL> if selectors : <EOL> url = '<STR_LIT>' % ( url , LinkedInSelector . parse ( selectors ) ) <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def join_group ( self , group_id ) : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE , str ( group_id ) ) <EOL> response = self . make_request ( '<STR_LIT>' , url , <EOL> data = json . dumps ( { '<STR_LIT>' : { '<STR_LIT:code>' : '<STR_LIT>' } } ) ) <EOL> raise_for_error ( response ) <EOL> return True <EOL> def leave_group ( self , group_id ) : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE , str ( group_id ) ) <EOL> response = self . make_request ( '<STR_LIT>' , url ) <EOL> raise_for_error ( response ) <EOL> return True <EOL> def submit_group_post ( self , group_id , title , summary , submitted_url , <EOL> submitted_image_url , content_title , description ) : <EOL> post = { <EOL> '<STR_LIT:title>' : title , '<STR_LIT>' : summary , <EOL> '<STR_LIT:content>' : { <EOL> '<STR_LIT>' : submitted_url , <EOL> '<STR_LIT:title>' : content_title , <EOL> '<STR_LIT:description>' : description <EOL> } <EOL> } <EOL> if submitted_image_url : <EOL> post [ '<STR_LIT:content>' ] [ '<STR_LIT>' ] = submitted_image_url <EOL> url = '<STR_LIT>' % ( ENDPOINTS . GROUPS , str ( group_id ) ) <EOL> response = self . make_request ( '<STR_LIT:POST>' , url , data = json . dumps ( post ) ) <EOL> raise_for_error ( response ) <EOL> return True <EOL> def like_post ( self , post_id , action ) : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . POSTS , str ( post_id ) ) <EOL> try : <EOL> self . make_request ( '<STR_LIT>' , url , data = json . dumps ( action ) ) <EOL> except ( requests . ConnectionError , requests . HTTPError ) as error : <EOL> raise LinkedInError ( error . message ) <EOL> else : <EOL> return True <EOL> def comment_post ( self , post_id , comment ) : <EOL> post = { <EOL> '<STR_LIT:text>' : comment <EOL> } <EOL> url = '<STR_LIT>' % ( ENDPOINTS . POSTS , str ( post_id ) ) <EOL> try : <EOL> self . make_request ( '<STR_LIT:POST>' , url , data = json . dumps ( post ) ) <EOL> except ( requests . ConnectionError , requests . HTTPError ) as error : <EOL> raise LinkedInError ( error . message ) <EOL> else : <EOL> return True <EOL> def get_company_by_email_domain ( self , email_domain , params = None , headers = None ) : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . COMPANIES , email_domain ) <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def get_companies ( self , company_ids = None , universal_names = None , selectors = None , <EOL> params = None , headers = None ) : <EOL> identifiers = [ ] <EOL> url = ENDPOINTS . COMPANIES <EOL> if company_ids : <EOL> identifiers += map ( str , company_ids ) <EOL> if universal_names : <EOL> identifiers += [ '<STR_LIT>' % un for un in universal_names ] <EOL> if identifiers : <EOL> url = '<STR_LIT>' % ( url , '<STR_LIT:U+002C>' . join ( identifiers ) ) <EOL> if selectors : <EOL> url = '<STR_LIT>' % ( url , LinkedInSelector . parse ( selectors ) ) <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def get_company_updates ( self , company_id , params = None , headers = None ) : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . COMPANIES , str ( company_id ) ) <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def get_company_products ( self , company_id , selectors = None , params = None , <EOL> headers = None ) : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . COMPANIES , str ( company_id ) ) <EOL> if selectors : <EOL> url = '<STR_LIT>' % ( url , LinkedInSelector . parse ( selectors ) ) <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def follow_company ( self , company_id ) : <EOL> url = '<STR_LIT>' % ENDPOINTS . PEOPLE <EOL> post = { '<STR_LIT:id>' : company_id } <EOL> response = self . make_request ( '<STR_LIT:POST>' , url , data = json . dumps ( post ) ) <EOL> raise_for_error ( response ) <EOL> return True <EOL> def unfollow_company ( self , company_id ) : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE , str ( company_id ) ) <EOL> response = self . make_request ( '<STR_LIT>' , url ) <EOL> raise_for_error ( response ) <EOL> return True <EOL> def search_company ( self , selectors = None , params = None , headers = None ) : <EOL> url = ENDPOINTS . COMPANY_SEARCH <EOL> if selectors : <EOL> url = '<STR_LIT>' % ( url , LinkedInSelector . parse ( selectors ) ) <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def submit_company_share ( self , company_id , comment = None , title = None , description = None , <EOL> submitted_url = None , submitted_image_url = None , <EOL> visibility_code = '<STR_LIT>' ) : <EOL> post = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:code>' : visibility_code , <EOL> } , <EOL> } <EOL> if comment is not None : <EOL> post [ '<STR_LIT>' ] = comment <EOL> if title is not None and submitted_url is not None : <EOL> post [ '<STR_LIT:content>' ] = { <EOL> '<STR_LIT:title>' : title , <EOL> '<STR_LIT>' : submitted_url , <EOL> '<STR_LIT:description>' : description , <EOL> } <EOL> if submitted_image_url : <EOL> post [ '<STR_LIT:content>' ] [ '<STR_LIT>' ] = submitted_image_url <EOL> url = '<STR_LIT>' % ( ENDPOINTS . COMPANIES , company_id ) <EOL> response = self . make_request ( '<STR_LIT:POST>' , url , data = json . dumps ( post ) ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def get_job ( self , job_id , selectors = None , params = None , headers = None ) : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . JOBS , str ( job_id ) ) <EOL> url = '<STR_LIT>' % ( url , LinkedInSelector . parse ( selectors ) ) <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def get_job_bookmarks ( self , selectors = None , params = None , headers = None ) : <EOL> url = '<STR_LIT>' % ENDPOINTS . PEOPLE <EOL> if selectors : <EOL> url = '<STR_LIT>' % ( url , LinkedInSelector . parse ( selectors ) ) <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def search_job ( self , selectors = None , params = None , headers = None ) : <EOL> url = ENDPOINTS . JOB_SEARCH <EOL> if selectors : <EOL> url = '<STR_LIT>' % ( url , LinkedInSelector . parse ( selectors ) ) <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def submit_share ( self , comment = None , title = None , description = None , <EOL> submitted_url = None , submitted_image_url = None , <EOL> visibility_code = '<STR_LIT>' ) : <EOL> post = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:code>' : visibility_code , <EOL> } , <EOL> } <EOL> if comment is not None : <EOL> post [ '<STR_LIT>' ] = comment <EOL> if title is not None and submitted_url is not None : <EOL> post [ '<STR_LIT:content>' ] = { <EOL> '<STR_LIT:title>' : title , <EOL> '<STR_LIT>' : submitted_url , <EOL> '<STR_LIT:description>' : description , <EOL> } <EOL> if submitted_image_url : <EOL> post [ '<STR_LIT:content>' ] [ '<STR_LIT>' ] = submitted_image_url <EOL> url = '<STR_LIT>' % ENDPOINTS . PEOPLE <EOL> response = self . make_request ( '<STR_LIT:POST>' , url , data = json . dumps ( post ) ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def get_network_updates ( self , types , member_id = None , <EOL> self_scope = True , params = None , headers = None ) : <EOL> if member_id : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE , <EOL> str ( member_id ) ) <EOL> else : <EOL> url = '<STR_LIT>' % ENDPOINTS . PEOPLE <EOL> if not params : <EOL> params = { } <EOL> if types : <EOL> params . update ( { '<STR_LIT:type>' : types } ) <EOL> if self_scope is True : <EOL> params . update ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def get_network_update ( self , types , update_key , <EOL> self_scope = True , params = None , headers = None ) : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE , str ( update_key ) ) <EOL> if not params : <EOL> params = { } <EOL> if types : <EOL> params . update ( { '<STR_LIT:type>' : types } ) <EOL> if self_scope is True : <EOL> params . update ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def get_network_status ( self , params = None , headers = None ) : <EOL> url = '<STR_LIT>' % ENDPOINTS . PEOPLE <EOL> response = self . make_request ( '<STR_LIT:GET>' , url , params = params , headers = headers ) <EOL> raise_for_error ( response ) <EOL> return response . json ( ) <EOL> def send_invitation ( self , invitation ) : <EOL> assert type ( invitation ) == LinkedInInvitation , '<STR_LIT>' <EOL> url = '<STR_LIT>' % ENDPOINTS . PEOPLE <EOL> response = self . make_request ( '<STR_LIT:POST>' , url , <EOL> data = json . dumps ( invitation . json ) ) <EOL> raise_for_error ( response ) <EOL> return True <EOL> def send_message ( self , message ) : <EOL> assert type ( message ) == LinkedInMessage , '<STR_LIT>' <EOL> url = '<STR_LIT>' % ENDPOINTS . PEOPLE <EOL> response = self . make_request ( '<STR_LIT:POST>' , url , <EOL> data = json . dumps ( message . json ) ) <EOL> raise_for_error ( response ) <EOL> return True <EOL> def comment_on_update ( self , update_key , comment ) : <EOL> comment = { '<STR_LIT>' : comment } <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE , update_key ) <EOL> response = self . make_request ( '<STR_LIT:POST>' , url , data = json . dumps ( comment ) ) <EOL> raise_for_error ( response ) <EOL> return True <EOL> def like_update ( self , update_key , is_liked = True ) : <EOL> url = '<STR_LIT>' % ( ENDPOINTS . PEOPLE , update_key ) <EOL> response = self . make_request ( '<STR_LIT>' , url , data = json . dumps ( is_liked ) ) <EOL> raise_for_error ( response ) <EOL> return True </s>
