diff --git a/tap_linkedin_ads/__init__.py b/tap_linkedin_ads/__init__.py index 40be526..8da87df 100644 --- a/tap_linkedin_ads/__init__.py +++ b/tap_linkedin_ads/__init__.py @@ -19,9 +19,9 @@ ] -def do_discover(client, config): +def do_discover(client): LOGGER.info('Starting discover') - client.check_accounts(config) + client.check_accounts(client.get_config()) catalog = _discover() json.dump(catalog.to_dict(), sys.stdout, indent=2) LOGGER.info('Finished discover') @@ -30,7 +30,6 @@ def do_discover(client, config): @singer.utils.handle_top_exception(LOGGER) def main(): parsed_args = singer.utils.parse_args(REQUIRED_CONFIG_KEYS) - config = parsed_args.config with LinkedinClient(parsed_args.config.get('client_id', None), parsed_args.config.get('client_secret', None), @@ -45,10 +44,9 @@ def main(): if parsed_args.state: state = parsed_args.state if parsed_args.discover: - do_discover(client, config) + do_discover(client) elif parsed_args.catalog: _sync(client=client, - config=config, catalog=parsed_args.catalog, state=state) diff --git a/tap_linkedin_ads/client.py b/tap_linkedin_ads/client.py index a198311..eff32a9 100644 --- a/tap_linkedin_ads/client.py +++ b/tap_linkedin_ads/client.py @@ -175,6 +175,9 @@ def set_mock_expires_for_test(self, mock_expire): self.__expires = mock_expire return self.__expires + def get_config(self): + with open(self.__config_path) as file: + return json.load(file) def write_access_token_to_config(self): """ diff --git a/tap_linkedin_ads/sync.py b/tap_linkedin_ads/sync.py index f219901..61a2000 100644 --- a/tap_linkedin_ads/sync.py +++ b/tap_linkedin_ads/sync.py @@ -66,10 +66,11 @@ def get_page_size(config): except Exception: raise Exception("The entered page size ({}) is invalid".format(page_size)) -def sync(client, config, catalog, state): +def sync(client, catalog, state): """ sync selected streams. """ + config = client.get_config() start_date = config['start_date'] page_size = get_page_size(config) diff --git a/tap_linkedin_ads/transform.py b/tap_linkedin_ads/transform.py index c77321d..dbe8c86 100644 --- a/tap_linkedin_ads/transform.py +++ b/tap_linkedin_ads/transform.py @@ -254,6 +254,7 @@ def transform_creatives(data_dict): return new_dict + # Copy audit fields to root level def transform_audit_fields(data_dict): if 'change_audit_stamps' in data_dict: