diff --git a/myspace_api.py b/myspace_api.py index fdfeb1a..ce52f9d 100644 --- a/myspace_api.py +++ b/myspace_api.py @@ -21,7 +21,7 @@ from properties import Properties, PropertiesByOwner, PropertyDashboardByOwner from transactions import AllTransactions, TransactionsByOwner, TransactionsByOwnerByProperty from cashflow import CashflowByOwner -from profiles import OwnerProfile, TenantProfile +from profiles import OwnerProfile, TenantProfile, OwnerProfileByOwnerUid from documents import OwnerDocuments, TenantDocuments from leases import LeaseDetails from purchases import Bills, AddExpense, AddRevenue @@ -406,9 +406,11 @@ def get(self, tenant_id): api.add_resource(Payments, '/makePayment') -api.add_resource(OwnerProfile, '/ownerProfile/') +api.add_resource(OwnerProfileByOwnerUid, '/ownerProfile/') api.add_resource(TenantProfile, '/tenantProfile/') +api.add_resource(OwnerProfile, '/ownerProfile') # POST, PUT OwnerProfile + api.add_resource(OwnerDocuments, '/ownerDocuments/') api.add_resource(TenantDocuments, '/tenantDocuments/') diff --git a/profiles.py b/profiles.py index 623c65a..5e4dc8a 100644 --- a/profiles.py +++ b/profiles.py @@ -17,8 +17,27 @@ # BY MONTH X X X # BY YEAR X X X - class OwnerProfile(Resource): + def post(self): + print('in Owner Profile') + response = {} + payload = request.get_json() + with connect() as db: + response = db.insert('ownerProfileInfo', payload) + return response + + def put(self): + print('in Owner Profile') + response = {} + payload = request.get_json() + if payload.get('owner_uid') is None: + raise BadRequest("Request failed, no UID in payload.") + key = {'owner_uid': payload.pop('owner_uid')} + with connect() as db: + response = db.update('ownerProfileInfo', key, payload) + return response + +class OwnerProfileByOwnerUid(Resource): # decorators = [jwt_required()] def get(self, owner_id):