@@ -65,22 +65,17 @@ class ApiClient(object):
6565 :param header_name: a header to pass when making calls to the API.
6666 :param header_value: a header value to pass when making calls to the API.
6767 """
68- def __init__ (self , host = None , header_name = None , header_value = None , cookie = None ):
69-
70- """
71- Constructor of the class.
72- """
73- self .rest_client = RESTClientObject ()
68+ def __init__ (self , configuration = None , header_name = None , header_value = None , cookie = None ):
69+ if configuration is None :
70+ configuration = Configuration ()
71+ self .configuration = configuration
72+ self .rest_client = RESTClientObject (configuration )
7473 self .default_headers = {}
7574 if header_name is not None :
7675 self .default_headers [header_name ] = header_value
77- if host is None :
78- self .host = Configuration ().host
79- else :
80- self .host = host
8176 self .cookie = cookie
8277 # Set default User-Agent.
83- self .user_agent = 'Square-Connect-Python/2.20180712.2 '
78+ self .user_agent = 'Square-Connect-Python/2.20180712.3 '
8479
8580 @property
8681 def user_agent (self ):
@@ -139,7 +134,7 @@ def __call_api(self, resource_path, method,
139134 body = self .sanitize_for_serialization (body )
140135
141136 # request url
142- url = self .host + resource_path
137+ url = self .configuration . host + resource_path
143138
144139 # perform request and return response
145140 response_data = self .request (method , url ,
@@ -448,13 +443,12 @@ def update_params_for_auth(self, headers, querys, auth_settings):
448443 :param querys: Query parameters dict to be updated.
449444 :param auth_settings: Authentication setting identifiers list.
450445 """
451- config = Configuration ()
452446
453447 if not auth_settings :
454448 return
455449
456450 for auth in auth_settings :
457- auth_setting = config .auth_settings ().get (auth )
451+ auth_setting = self . configuration .auth_settings ().get (auth )
458452 if auth_setting :
459453 if not auth_setting ['value' ]:
460454 continue
@@ -475,9 +469,8 @@ def __deserialize_file(self, response):
475469 :param response: RESTResponse.
476470 :return: file path.
477471 """
478- config = Configuration ()
479472
480- fd , path = tempfile .mkstemp (dir = config .temp_folder_path )
473+ fd , path = tempfile .mkstemp (dir = self . configuration .temp_folder_path )
481474 os .close (fd )
482475 os .remove (path )
483476
0 commit comments