Skip to content

Commit

Permalink
Merge pull request #22 from infinite-options/rp0905
Browse files Browse the repository at this point in the history
added endpoints for tenantProfile and searchManager
  • Loading branch information
adityabaravkar authored Sep 7, 2023
2 parents 48ff5aa + 30f10d9 commit f5b4791
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 3 deletions.
45 changes: 45 additions & 0 deletions managers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from flask import request
from flask_restful import Resource
from flask_jwt_extended import jwt_required, get_jwt_identity

from data_pm import connect, uploadImage, s3

class SearchManager(Resource):

# def get(self):
# response = {}
# business_location = request.args.get('business_location')
# business_name = request.args.get('business_name')

# with connect() as db:
# searchQuery = f"""
# SELECT *
# FROM space.businessProfileInfo
# JOIN JSON_TABLE(
# space.businessProfileInfo.business_locations,
# '$[*]'
# COLUMNS (
# distance VARCHAR(255) PATH '$.distance',
# location VARCHAR(255) PATH '$.location'
# )
# ) AS json_data ON json_data.location = '{business_location}'
# WHERE space.businessProfileInfo.business_name = '{business_name}';
# """
# # print(searchQuery)
# response = db.execute(searchQuery)
# return response

def get(self):
response = {}
# filters = ['business_uid', 'business_type',
# 'business_name', 'business_locations']
where = {}
# for filter in filters:
# filterValue = request.args.get(filter)
# if filterValue is not None:
# where[filter] = filterValue
where['business_type'] = 'MANAGEMENT'
# print(where)
with connect() as db:
response = db.select('b_details', where)
return response
8 changes: 6 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, OwnerProfileByOwnerUid
from profiles import OwnerProfile, OwnerProfileByOwnerUid, TenantProfile, TenantProfileByTenantUid
from documents import OwnerDocuments, TenantDocuments
from leases import LeaseDetails
from purchases import Bills, AddExpense, AddRevenue
Expand All @@ -30,7 +30,9 @@
from contracts import Contracts, ContractsByUid
from settings import Account
from lists import List
from managers import SearchManager
from quotes import QuotesByBusiness, QuotesStatusByBusiness

# from refresh import Refresh
# from data import connect, disconnect, execute, helper_upload_img, helper_icon_img
from data_pm import connect, uploadImage, s3
Expand Down Expand Up @@ -419,9 +421,10 @@ def get(self, tenant_id):


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

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

api.add_resource(OwnerDocuments, '/ownerDocuments/<string:owner_id>')
api.add_resource(TenantDocuments, '/tenantDocuments/<string:tenant_id>')
Expand All @@ -440,6 +443,7 @@ def get(self, tenant_id):
api.add_resource(Account, '/account')
api.add_resource(TenantDashboard, '/tenantDashboard/<string:tenant_id>')

api.add_resource(SearchManager, '/searchManager')

# refresh
# api.add_resource(Refresh, '/refresh')
Expand Down
22 changes: 21 additions & 1 deletion profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,28 @@ def get(self, owner_id):

return response

class TenantProfile(Resource):
def post(self):
response = {}
print('in TenantProfile')
payload = request.get_json()

with connect() as db:
response = db.insert('tenantProfileInfo', payload)
return response

def put(self):
response = {}
print('in TenantProfile')
payload = request.get_json()
if payload.get('tenant_uid') is None:
raise BadRequest("Request failed, no UID in payload.")
key = {'tenant_uid': payload.pop('tenant_uid')}
with connect() as db:
response = db.update('tenantProfileInfo', key, payload)
return response

class TenantProfile(Resource):
class TenantProfileByTenantUid(Resource):
# decorators = [jwt_required()]

def get(self, tenant_id):
Expand Down

0 comments on commit f5b4791

Please sign in to comment.