@@ -113,6 +113,12 @@ def partitions(self) -> Optional[List[dict]]:
113
113
})
114
114
return result or None
115
115
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
+
116
122
def get_url_params (
117
123
self ,
118
124
partition : Optional [dict ],
@@ -129,6 +135,7 @@ def get_url_params(
129
135
130
136
schema = PropertiesList (
131
137
Property ("id" , IntegerType ),
138
+ Property ("company_id" , IntegerType ),
132
139
Property ("name" , StringType )
133
140
).to_dict ()
134
141
@@ -372,6 +379,9 @@ def get_folders(self, headers):
372
379
r = requests .get (endpoint , headers = headers )
373
380
data = r .json ().get ('folders' , [])
374
381
382
+ # Add root folder
383
+ folders .append ({'folder' : - 1 , 'project' : project ['id' ]})
384
+
375
385
# Add these folders to final output
376
386
folders .extend (
377
387
[{'folder' : x ['id' ], 'project' : project ['id' ]} for x in data ])
@@ -384,8 +394,13 @@ def get_folders(self, headers):
384
394
385
395
def get_url (self , partition : Optional [dict ]) -> str :
386
396
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
389
404
390
405
@property
391
406
def partitions (self ) -> Optional [List [dict ]]:
0 commit comments