#NEWLINE# def request_raw( self , method , url , params = None , apiKeyRequired = True ) : #NEWLINE# #INDENT# if ( params is None ) : #NEWLINE# #INDENT# params = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# my_api_key = ( self . api_key or api_key ) #NEWLINE# if ( apiKeyRequired and ( my_api_key is None ) ) : #NEWLINE# #INDENT# raise Error ( 'No API key provided. Set an API key via "easypost.api_key = \'APIKEY\'. Your API keys can be found in your EasyPost dashboard, or you can email us at contact@easypost.com for assistance.' ) #NEWLINE# #UNINDENT# abs_url = self . api_url ( url ) #NEWLINE# params = self . _objects_to_ids ( params ) #NEWLINE# ua = { #NEWLINE# #INDENT# 'client_version' : VERSION , #NEWLINE# 'lang' : 'python' , #NEWLINE# 'publisher' : 'easypost' , #NEWLINE# 'request_lib' : request_lib , #NEWLINE# #UNINDENT# } #NEWLINE# for ( attr , func ) in [ [ 'lang_version' , platform . python_version ] , [ 'platform' , platform . platform ] , [ 'uname' , ( lambda : ' ' . join ( platform . uname ( ) ) ) ] ] : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# val = func ( ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# val = ( '!! %s' % e ) #NEWLINE# #UNINDENT# ua [ attr ] = val #NEWLINE# #UNINDENT# headers = { #NEWLINE# #INDENT# 'X-EasyPost-Client-User-Agent' : json . dumps ( ua ) , #NEWLINE# 'User-Agent' : ( 'EasyPost/v2 PythonClient/%s' % VERSION ) , #NEWLINE# 'Authorization' : ( 'Bearer %s' % my_api_key ) , #NEWLINE# 'Content-type' : 'application/x-www-form-urlencoded' , #NEWLINE# #UNINDENT# } #NEWLINE# if ( request_lib == 'urlfetch' ) : #NEWLINE# #INDENT# ( http_body , http_status ) = self . urlfetch_request ( method , abs_url , headers , params ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( request_lib == 'requests' ) : #NEWLINE# #INDENT# ( http_body , http_status ) = self . requests_request ( method , abs_url , headers , params ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Error ( ( 'Bug discovered: invalid request_lib: %s. Please report to contact@easypost.com.' % request_lib ) ) #NEWLINE# #UNINDENT# #UNINDENT# return ( http_body , http_status , my_api_key )