From 5a5d20eb754f3344c37ca5ac608f455fe9d40059 Mon Sep 17 00:00:00 2001 From: gthampi Date: Wed, 6 Sep 2023 16:10:19 -0400 Subject: [PATCH 1/2] get post put maintenanceQuotes --- maintenance.py | 27 +++++++++++++++++++++++++++ myspace_api.py | 8 ++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/maintenance.py b/maintenance.py index 08f2ec0..73d20b8 100644 --- a/maintenance.py +++ b/maintenance.py @@ -288,6 +288,33 @@ def put(self): return response +class MaintenanceQuotes(Resource): + def post(self): + print('in MaintenanceQuotes') + payload = request.get_json() + with connect() as db: + response = db.insert('maintenanceQuotes', payload) + return response + + def put(self): + print('in MaintenanceQuotes') + payload = request.get_json() + if payload.get('maintenance_quote_uid') is None: + raise BadRequest("Request failed, no UID in payload.") + key = {'maintenance_quote_uid': payload.pop('maintenance_quote_uid')} + with connect() as db: + response = db.update('maintenanceQuotes', key, payload) + return response + + +class MaintenanceQuotesByUid(Resource): + def get(self, maintenance_quote_uid): + print('in MaintenanceQuotesByUid') + with connect() as db: + response = db.select('maintenanceQuotes', {"maintenance_quote_uid": maintenance_quote_uid}) + return response + + class MaintenanceSummaryByOwner(Resource): def get(self, owner_id): diff --git a/myspace_api.py b/myspace_api.py index aaa0689..2a6e814 100644 --- a/myspace_api.py +++ b/myspace_api.py @@ -25,7 +25,8 @@ from documents import OwnerDocuments, TenantDocuments from leases import LeaseDetails from purchases import Bills, AddExpense, AddRevenue -from maintenance import MaintenanceStatusByProperty, MaintenanceByProperty, MaintenanceStatusByOwner, MaintenanceRequestsByOwner, MaintenanceRequests, MaintenanceSummaryByOwner, MaintenanceStatusByOwnerSimplified +from maintenance import MaintenanceStatusByProperty, MaintenanceByProperty, MaintenanceStatusByOwner, \ + MaintenanceRequestsByOwner, MaintenanceRequests, MaintenanceQuotes, MaintenanceQuotesByUid from contacts import ContactsMaintenance, ContactsOwnerContactsDetails, ContactsBusinessContacts, ContactsBusinessContactsOwnerDetails, ContactsBusinessContactsTenantDetails, ContactsBusinessContactsMaintenanceDetails from contracts import Contracts, ContractsByUid from settings import Account @@ -393,9 +394,8 @@ def get(self, tenant_id): api.add_resource(MaintenanceByProperty, '/maintenanceByProperty/') api.add_resource(MaintenanceStatusByProperty, '/maintenanceStatusByProperty/') api.add_resource(MaintenanceStatusByOwner, '/maintenanceStatusByOwner/') -api.add_resource(MaintenanceSummaryByOwner, '/maintenanceSummaryByOwner/') -api.add_resource(MaintenanceStatusByOwnerSimplified, '/maintenanceStatusByOwnerSimplified/') - +api.add_resource(MaintenanceQuotes, '/maintenanceQuotes') +api.add_resource(MaintenanceQuotesByUid, '/maintenanceQuotes/') api.add_resource(Bills, '/bills') api.add_resource(ContractsByUid, '/contracts/') From 4a3f8906e0e645b17abf3adaf60138ef44e542e0 Mon Sep 17 00:00:00 2001 From: gthampi Date: Wed, 6 Sep 2023 16:14:30 -0400 Subject: [PATCH 2/2] overridden imports readded --- myspace_api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/myspace_api.py b/myspace_api.py index 2a6e814..79d0b04 100644 --- a/myspace_api.py +++ b/myspace_api.py @@ -26,7 +26,8 @@ from leases import LeaseDetails from purchases import Bills, AddExpense, AddRevenue from maintenance import MaintenanceStatusByProperty, MaintenanceByProperty, MaintenanceStatusByOwner, \ - MaintenanceRequestsByOwner, MaintenanceRequests, MaintenanceQuotes, MaintenanceQuotesByUid + MaintenanceRequestsByOwner, MaintenanceRequests, MaintenanceQuotes, MaintenanceQuotesByUid, \ + MaintenanceSummaryByOwner, MaintenanceStatusByOwnerSimplified from contacts import ContactsMaintenance, ContactsOwnerContactsDetails, ContactsBusinessContacts, ContactsBusinessContactsOwnerDetails, ContactsBusinessContactsTenantDetails, ContactsBusinessContactsMaintenanceDetails from contracts import Contracts, ContractsByUid from settings import Account @@ -394,6 +395,8 @@ def get(self, tenant_id): api.add_resource(MaintenanceByProperty, '/maintenanceByProperty/') api.add_resource(MaintenanceStatusByProperty, '/maintenanceStatusByProperty/') api.add_resource(MaintenanceStatusByOwner, '/maintenanceStatusByOwner/') +api.add_resource(MaintenanceSummaryByOwner, '/maintenanceSummaryByOwner/') +api.add_resource(MaintenanceStatusByOwnerSimplified, '/maintenanceStatusByOwnerSimplified/') api.add_resource(MaintenanceQuotes, '/maintenanceQuotes') api.add_resource(MaintenanceQuotesByUid, '/maintenanceQuotes/')