From 8900c11d2cd0003ab2a8a5fa00592f1d618b5969 Mon Sep 17 00:00:00 2001 From: Katherine Fleming <2205659+kflemin@users.noreply.github.com> Date: Tue, 16 Jan 2024 12:35:30 -0700 Subject: [PATCH] add new method to get AT submission metadata (#39) --- pyseed/seed_client.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/pyseed/seed_client.py b/pyseed/seed_client.py index 15f3e53..85d83a6 100644 --- a/pyseed/seed_client.py +++ b/pyseed/seed_client.py @@ -1427,6 +1427,27 @@ def retrieve_at_building_and_update(self, audit_template_building_id: int, cycle return response + def retrieve_at_submission_metadata(self, audit_template_submission_id: int) -> dict: + """Connect to audit template and retrieve audit report json (metadata only) by submission ID + + Args: + audit_template_submission_id (int): ID of the AT submission report (different than building ID) + + Returns: + dict: Response from the SEED API + """ + + # api/v3/audit_template/pk/get_submission + response = self.client.get( + None, + required_pk=False, + endpoint="audit_template_submission", + url_args={"PK": audit_template_submission_id}, + report_format='json' + ) + + return response + def retrieve_at_submission_and_update(self, audit_template_submission_id: int, cycle_id: int, seed_id: int, report_format: str = 'pdf', filename: str = None) -> dict: """Connect to audit template and retrieve audit report by submission ID @@ -1434,7 +1455,7 @@ def retrieve_at_submission_and_update(self, audit_template_submission_id: int, c audit_template_submission_id (int): ID of the AT submission report (different than building ID) cycle_id (int): Cycle ID in SEED (needed for XML but not actually for PDF) seed_id (int): PropertyView ID in SEED - file_format (str): pdf or xml report, defaults to pdf + file_format (str): pdf, or xml report, defaults to pdf filename (str): filename to use to upload to SEED Returns: @@ -1443,7 +1464,7 @@ def retrieve_at_submission_and_update(self, audit_template_submission_id: int, c """ # api/v3/audit_template/pk/get_submission - # accepts pdf or xml + # accepts pdf, xml response = self.client.get( None, required_pk=False, @@ -1454,6 +1475,7 @@ def retrieve_at_submission_and_update(self, audit_template_submission_id: int, c if response['status'] == 'success': if report_format.lower() == 'pdf': + # for PDF, store pdf report as inventory document pdf_file = response['content'] if not filename: filename = 'at_submission_report_' + str(audit_template_submission_id) + '.pdf' @@ -1470,7 +1492,7 @@ def retrieve_at_submission_and_update(self, audit_template_submission_id: int, c ) response2['pdf_report'] = pdf_file else: - # assume XML + # assume XML. for XML, update property with BuildingSync # now post to api/v3/properties/PK/update_with_buildingsync xml_file = response['content'] if not filename: