Skip to content

Commit

Permalink
fix: return types for OdkCentral submission methods
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Jan 23, 2024
1 parent 7425086 commit 41c10b5
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions osm_fieldwork/OdkCentral.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,20 +640,29 @@ def listSubmissionBasicInfo(
def listSubmissions(self, projectId: int, xform: str, filters: dict = None):
"""Fetch a list of submission instances for a given form.
Returns data in format:
{
"value":[],
"@odata.context": "URL/v1/projects/52/forms/103.svc/$metadata#Submissions",
"@odata.count":0
}
Args:
projectId (int): The ID of the project on ODK Central
xform (str): The XForm to get the details of from ODK Central
Returns:
(list): The list of Submissions
(json): The JSON of Submissions.
"""
url = f"{self.base}projects/{projectId}/forms/{xform}.svc/Submissions"
result = self.session.get(url, auth=self.auth, params=filters, verify=self.verify)

if result.ok:
self.submissions = result.json()
return self.submissions
else:
return list()

return {}

def listAssignments(
self,
Expand Down Expand Up @@ -693,7 +702,7 @@ def getSubmissions(
json (bool): Download JSON or CSV format
Returns:
(list): The lit of submissions
(bytes): The list of submissions as JSON or CSV bytes object.
"""
headers = {"Content-Type": "application/json"}
now = datetime.now()
Expand Down Expand Up @@ -725,7 +734,7 @@ def getSubmissions(
return result.content
else:
log.error(f"Submissions for {projectId}, Form {xform}" + " doesn't exist")
return list()
return bytes()

def getSubmissionMedia(
self,
Expand Down

0 comments on commit 41c10b5

Please sign in to comment.