Skip to content

Commit

Permalink
modifying naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
sgandhi1311 committed Nov 9, 2023
1 parent 595abe6 commit 1d2529c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions tap_hubspot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class StateFields:
"tickets_properties": "/crm/v3/properties/tickets",
"tickets": "/crm/v4/objects/tickets",

"custom_objects": "/crm/v3/schemas",
"custom_object_record": "/crm/v3/objects/p_{object_name}"
"custom_objects_schema": "/crm/v3/schemas",
"custom_objects": "/crm/v3/objects/p_{object_name}"
}

def get_start(state, tap_stream_id, bookmark_key, older_bookmark_key=None):
Expand Down Expand Up @@ -1139,7 +1139,7 @@ def sync_records(stream_id, primary_key, bookmark_key, catalog, STATE, params):
"""
mdata = metadata.to_map(catalog.get('metadata'))
if stream_id.startswith("custom_"):
url = get_url("custom_object_record", object_name=stream_id[len("custom_"):])
url = get_url("custom_objects", object_name=stream_id[len("custom_"):])
else:
url = get_url(stream_id)
max_bk_value = bookmark_value = utils.strptime_with_tz(
Expand All @@ -1162,10 +1162,7 @@ def sync_records(stream_id, primary_key, bookmark_key, catalog, STATE, params):
# is greater than or equal to defined previous bookmark value
if modified_time and modified_time >= bookmark_value:
# transforms the data and filters out the selected fields from the catalog
if stream_id == "custom_objects":
record = transformer.transform(row, schema, mdata)
else:
record = transformer.transform(lift_properties_and_versions(row), schema, mdata)
record = transformer.transform(lift_properties_and_versions(row), schema, mdata)
singer.write_record(stream_id, record, catalog.get(
'stream_alias'), time_extracted=utils.now())
if modified_time and modified_time >= max_bk_value:
Expand Down Expand Up @@ -1224,15 +1221,15 @@ class Stream:


def add_custom_streams(mode):
custom_objects_url = get_url("custom_objects")
custom_objects_schema_url = get_url("custom_objects_schema")
# Load Hubspot's shared schemas
refs = load_shared_schema_refs()
try:
for custom_object in gen_request_custom_objects("custom_objects", custom_objects_url, {}, 'results', "paging"):
for custom_object in gen_request_custom_objects("custom_objects_schema", custom_objects_schema_url, {}, 'results', "paging"):
stream_id = "custom_" + custom_object["name"]
STREAMS.append(Stream(stream_id, sync_custom_object_records, ['id'], 'updatedAt', 'INCREMENTAL'))
if mode == "DISCOVER":
schema = utils.load_json(get_abs_path('schemas/shared/custom_object_record.json'))
schema = utils.load_json(get_abs_path('schemas/shared/custom_objects.json'))
custom_schema = parse_custom_schema(stream_id, custom_object["properties"])
schema["properties"]["properties"] = {
"type": "object",
Expand Down

0 comments on commit 1d2529c

Please sign in to comment.