@@ -53,7 +53,8 @@ def __init__(self, key=None, client_id=None, client_secret=None,
5353 timeout = None , connect_timeout = None , read_timeout = None ,
5454 retry_timeout = 60 , requests_kwargs = None ,
5555 queries_per_second = 50 , channel = None ,
56- retry_over_query_limit = True , experience_id = None ):
56+ retry_over_query_limit = True , experience_id = None ,
57+ base_url = _DEFAULT_BASE_URL ):
5758 """
5859 :param key: Maps API key. Required, unless "client_id" and
5960 "client_secret" are set. Most users should use an API key.
@@ -115,6 +116,10 @@ def __init__(self, key=None, client_id=None, client_secret=None,
115116 implemented. See the official requests docs for more info:
116117 http://docs.python-requests.org/en/latest/api/#main-interface
117118 :type requests_kwargs: dict
119+
120+ :param base_url: The base URL for all requests. Defaults to the Maps API
121+ server. Should not have a trailing slash.
122+ :type base_url: string
118123
119124 """
120125 if not key and not (client_secret and client_id ):
@@ -167,6 +172,7 @@ def __init__(self, key=None, client_id=None, client_secret=None,
167172 self .retry_over_query_limit = retry_over_query_limit
168173 self .sent_times = collections .deque ("" , queries_per_second )
169174 self .set_experience_id (experience_id )
175+ self .base_url = base_url
170176
171177 def set_experience_id (self , * experience_id_args ):
172178 """Sets the value for the HTTP header field name
@@ -204,7 +210,7 @@ def clear_experience_id(self):
204210 self .requests_kwargs ["headers" ] = headers
205211
206212 def _request (self , url , params , first_request_time = None , retry_counter = 0 ,
207- base_url = _DEFAULT_BASE_URL , accepts_clientid = True ,
213+ base_url = None , accepts_clientid = True ,
208214 extract_body = None , requests_kwargs = None , post_json = None ):
209215 """Performs HTTP GET/POST with credentials, returning the body as
210216 JSON.
@@ -246,6 +252,9 @@ def _request(self, url, params, first_request_time=None, retry_counter=0,
246252 exceute a request.
247253 """
248254
255+ if base_url is None :
256+ base_url = self .base_url
257+
249258 if not first_request_time :
250259 first_request_time = datetime .now ()
251260
0 commit comments