Skip to content

Commit

Permalink
Merge pull request #73 from tony-romanovych/master
Browse files Browse the repository at this point in the history
Extend DiscoveryBase with `api_factory` setting
  • Loading branch information
plaurynovich-hubspot authored Dec 1, 2021
2 parents ff3a0f7 + 8c53084 commit 5ab761d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.5
4.0.6
7 changes: 6 additions & 1 deletion hubspot/discovery/discovery_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ def __init__(self, config):
self.config = config

def _configure_api_client(self, api_client_package, api_name):
api_factory = self.config.get("api_factory") or self._default_api_factory
config = {k: v for k, v in self.config.items() if k != "api_factory" and v}
return api_factory(api_client_package, api_name, config)

@staticmethod
def _default_api_factory(api_client_package, api_name, config):
configuration = api_client_package.Configuration()
config = {k: v for k, v in self.config.items() if v is not None}
if "api_key" in config:
configuration.api_key["hapikey"] = config["api_key"]
if "access_token" in config:
Expand Down

0 comments on commit 5ab761d

Please sign in to comment.