Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

post put ownerProfileInfo #2

Merged
merged 2 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Expand Down Expand Up @@ -399,9 +399,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