Skip to content

Commit

Permalink
Merge pull request #2 from gthampi/GT-08-31
Browse files Browse the repository at this point in the history
post put ownerProfileInfo
  • Loading branch information
adityabaravkar authored Sep 4, 2023
2 parents 47e72f7 + 9400383 commit 8260569
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
6 changes: 4 additions & 2 deletions myspace_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -406,9 +406,11 @@ def get(self, tenant_id):
api.add_resource(Payments, '/makePayment')


api.add_resource(OwnerProfile, '/ownerProfile/<string:owner_id>')
api.add_resource(OwnerProfileByOwnerUid, '/ownerProfile/<string:owner_id>')
api.add_resource(TenantProfile, '/tenantProfile/<string:tenant_id>')

api.add_resource(OwnerProfile, '/ownerProfile') # POST, PUT OwnerProfile

api.add_resource(OwnerDocuments, '/ownerDocuments/<string:owner_id>')
api.add_resource(TenantDocuments, '/tenantDocuments/<string:tenant_id>')

Expand Down
21 changes: 20 additions & 1 deletion profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 8260569

Please sign in to comment.