Provides a single entry point for modifying all API methods. For now this is limited to allowing the client object to be modified with an `extra_params` keyword arg to each method, that is then used as the params for each web service request. Please note that this is an unsuppo
(func)
| 430 | from googlemaps.addressvalidation import addressvalidation |
| 431 | |
| 432 | def make_api_method(func): |
| 433 | """ |
| 434 | Provides a single entry point for modifying all API methods. |
| 435 | For now this is limited to allowing the client object to be modified |
| 436 | with an `extra_params` keyword arg to each method, that is then used |
| 437 | as the params for each web service request. |
| 438 | |
| 439 | Please note that this is an unsupported feature for advanced use only. |
| 440 | It's also currently incompatibile with multiple threads, see GH #160. |
| 441 | """ |
| 442 | @functools.wraps(func) |
| 443 | def wrapper(*args, **kwargs): |
| 444 | args[0]._extra_params = kwargs.pop("extra_params", None) |
| 445 | result = func(*args, **kwargs) |
| 446 | try: |
| 447 | del args[0]._extra_params |
| 448 | except AttributeError: |
| 449 | pass |
| 450 | return result |
| 451 | return wrapper |
| 452 | |
| 453 | |
| 454 | Client.directions = make_api_method(directions) |