diff --git a/maintenance.py b/maintenance.py index f94011e..800a2ce 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 16f6268..c146ab5 100644 --- a/myspace_api.py +++ b/myspace_api.py @@ -25,7 +25,7 @@ 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, MaintenanceSummaryAndStatusByOwner +from maintenance import MaintenanceStatusByProperty, MaintenanceByProperty, MaintenanceStatusByOwner, MaintenanceRequestsByOwner, MaintenanceRequests, MaintenanceSummaryByOwner, MaintenanceStatusByOwnerSimplified, MaintenanceSummaryAndStatusByOwner, MaintenanceQuotes, MaintenanceQuotesByUid from contacts import ContactsMaintenance, ContactsOwnerContactsDetails, ContactsBusinessContacts, ContactsBusinessContactsOwnerDetails, ContactsBusinessContactsTenantDetails, ContactsBusinessContactsMaintenanceDetails from contracts import Contracts, ContractsByUid from settings import Account @@ -398,6 +398,8 @@ def get(self, tenant_id): api.add_resource(MaintenanceStatusByOwnerSimplified, '/maintenanceStatusByOwnerSimplified/') api.add_resource(MaintenanceSummaryAndStatusByOwner, '/maintenanceSummaryAndStatusByOwner/') +api.add_resource(MaintenanceQuotes, '/maintenanceQuotes') +api.add_resource(MaintenanceQuotesByUid, '/maintenanceQuotes/') api.add_resource(QuotesByBusiness, '/quotesByBusiness') api.add_resource(QuotesStatusByBusiness, '/quotesStatusByBusiness')