From 5d407cfe1bf0246fca086e2fd160a01c7e741547 Mon Sep 17 00:00:00 2001 From: gthampi Date: Thu, 31 Aug 2023 18:09:52 -0400 Subject: [PATCH 1/2] post put ownerProfileInfo --- myspace_api.py | 6 ++++-- profiles.py | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/myspace_api.py b/myspace_api.py index e4991ea..d52224a 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 @@ -399,9 +399,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..4cef576 100644 --- a/profiles.py +++ b/profiles.py @@ -17,8 +17,25 @@ # 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() + 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): From 9400383dc791d59ad5300e70dfbef1b410221122 Mon Sep 17 00:00:00 2001 From: Aditya Baravkar Date: Mon, 4 Sep 2023 15:07:32 -0700 Subject: [PATCH 2/2] Update profiles.py --- profiles.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/profiles.py b/profiles.py index 4cef576..5e4dc8a 100644 --- a/profiles.py +++ b/profiles.py @@ -30,6 +30,8 @@ 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)