Skip to content

Commit a017a2d

Browse files
committed
Handle documents in root dir of projects
1 parent 4ffb7f9 commit a017a2d

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

.DS_Store

-6 KB
Binary file not shown.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ hidden-tests/
22
.secrets/
33
.pytest_cache/
44
__pycache__/
5+
.DS_Store

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "tap-procore"
3-
version = "0.0.6"
3+
version = "0.0.7"
44
description = "`tap-procore` is Singer tap for procore, built with the Singer SDK."
55
authors = ["hotglue"]
66
license = "Apache 2.0"

tap_procore/streams.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ def partitions(self) -> Optional[List[dict]]:
113113
})
114114
return result or None
115115

116+
def post_process(self, row: dict, context: Optional[dict] = None) -> dict:
117+
"""As needed, append or transform raw data to match expected structure."""
118+
# Add project_id to response
119+
row['company_id'] = context['company_id']
120+
return row
121+
116122
def get_url_params(
117123
self,
118124
partition: Optional[dict],
@@ -129,6 +135,7 @@ def get_url_params(
129135

130136
schema = PropertiesList(
131137
Property("id", IntegerType),
138+
Property("company_id", IntegerType),
132139
Property("name", StringType)
133140
).to_dict()
134141

@@ -372,6 +379,9 @@ def get_folders(self, headers):
372379
r = requests.get(endpoint, headers=headers)
373380
data = r.json().get('folders', [])
374381

382+
# Add root folder
383+
folders.append({'folder': -1, 'project': project['id']})
384+
375385
# Add these folders to final output
376386
folders.extend(
377387
[{'folder': x['id'], 'project': project['id']} for x in data])
@@ -384,8 +394,13 @@ def get_folders(self, headers):
384394

385395
def get_url(self, partition: Optional[dict]) -> str:
386396
url = super().get_url(partition)
387-
sub_url = f"{url}/{partition['folder']}"
388-
return sub_url
397+
398+
# Handle sub folders
399+
if partition['folder'] != -1:
400+
sub_url = f"{url}/{partition['folder']}"
401+
return sub_url
402+
403+
return url
389404

390405
@property
391406
def partitions(self) -> Optional[List[dict]]:

0 commit comments

Comments
 (0)