Skip to content

Commit

Permalink
Changes:
Browse files Browse the repository at this point in the history
1) Added get_config() method in LinkedInClient class to fetch config json.
2) Updated usage of get_config() method in discover & sync for tap.
  • Loading branch information
shantanu73 committed Nov 23, 2023
1 parent 4397501 commit 6bd4e7a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
8 changes: 3 additions & 5 deletions tap_linkedin_ads/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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),
Expand All @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions tap_linkedin_ads/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
3 changes: 2 additions & 1 deletion tap_linkedin_ads/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions tap_linkedin_ads/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6bd4e7a

Please sign in to comment.