def create_api_call_func(api, verb):
<EOL>def api_call_func(self, **kwargs):<EOL><INDENT>request = api.request_classes[verb](**kwargs)<EOL>params = dict([ (k,v) for k,v in request.items() if v is not None ])<EOL>if HTTPVerb.GET == verb:<EOL><INDENT>raw_response = requests.get(api.url, params=params, **self.reqargs)<EOL><DEDENT>elif HTTPVerb.POST == verb:<EOL><INDENT>raw_response = requests.post(api.url, data=params, **self.reqargs)<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>'.format(verb))<EOL><DEDENT>if raw_response.status_code != HTTPStatus.OK:<EOL><INDENT>raw_response.raise_for_status()<EOL><DEDENT>ResponseClass = api.response_classes[verb]<EOL>try:<EOL><INDENT>response = raw_response.json(object_hook=lambda obj: ResponseClass(obj))<EOL><DEDENT>except ValueError as e:<EOL><INDENT>response = ResponseClass({'<STR_LIT:content>' : raw_response.content})<EOL><DEDENT>return response<EOL><DEDENT>method_name = api_method_name(verb, api)<EOL>api_call_func.__name__ = method_name<EOL>api_call_func.__doc__ = '<STR_LIT>'.format(<EOL>method_name, '<STR_LIT>'.join(api.request_classes[verb].__doc__.splitlines(True)[<NUM_LIT:1>:]))<EOL>return api_call_func<EOL>
From an api definition object create the related api call method
that will validate the arguments for the api call and then
dynamically dispatch the request to the appropriate requests module
convenience method for the specific HTTP verb .