Esempio n. 1
0
def get_homeowner():
    service = zookeeper.get_service("homeowner-service")
    if service:
        manager = RequestManager(request, service)
        homeownerId = manager.authenticate()
        if homeownerId:
            return manager.get("homeowner/v1/Homeowner")
        return Response(response="Not Authorized", status=401)
    return Response(response="Error: Zookeeper down", status=503)
Esempio n. 2
0
def put_problem(problemId):
    homeownerService = zookeeper.get_service("homeowner-service")
    if homeownerService:
        homeownerManager = RequestManager(request, homeownerService)
        homeownerId = homeownerManager.authenticate()
        if homeownerId:
            tenantService = zookeeper.get_service("problem-service")
            if tenantService:
                tenantManager = RequestManager(request, tenantService)
                return tenantManager.put("problem/v1/Problem/" +
                                         str(problemId) + "/Status")
            return Response(response="Error: Tenant Not Available", status=503)
        return Response(response="Not Authorized", status=401)
    return Response(response="Error: Homeowner Not Available", status=503)
Esempio n. 3
0
def update_tenant(tenantId):
    homeownerService = zookeeper.get_service("homeowner-service")
    if homeownerService:
        homeownerManager = RequestManager(request, homeownerService)
        homeownerId = homeownerManager.authenticate()
        if homeownerId:
            tenantService = zookeeper.get_service("tenant-service")
            if tenantService:
                tenantManager = RequestManager(request, tenantService)
                return tenantManager.put("tenant/v1/Tenant/" + str(tenantId) +
                                         "/Approve")
            return Response(response="Error: Tenant Not Available", status=503)
        return Response(response="Not Authorized", status=401)
    return Response(response="Error: Homeowner Not Available", status=503)
Esempio n. 4
0
def get_tenants_by_house_id(houseId):
    homeownerService = zookeeper.get_service("homeowner-service")
    if homeownerService:
        homeownerManager = RequestManager(request, homeownerService)
        homeownerId = homeownerManager.authenticate()
        if homeownerId:
            tenantService = zookeeper.get_service("tenant-service")
            if tenantService:
                tenantManager = RequestManager(request, tenantService)
                return tenantManager.get("tenant/v1/House/" + str(houseId) +
                                         "/Tenant")
            return Response(response="Error: Tenant Not Available", status=503)
        return Response(response="Not Authorized", status=401)
    return Response(response="Error: Homeowner Not Available", status=503)
Esempio n. 5
0
def get_homeowner_documents(houseId):
    homeownerService = zookeeper.get_service("homeowner-service")
    if homeownerService:
        homeownerManager = RequestManager(request, homeownerService)
        homeownerId = homeownerManager.authenticate()
        if homeownerId:
            documentService = zookeeper.get_service("document-service")
            if documentService:
                documentManager = RequestManager(request, documentService)
                return documentManager.get("document/v1/Document/" +
                                           str(houseId))
            return Response(response="Error: Documents Not Available",
                            status=503)
        return Response(response="Not Authorized", status=401)
    return Response(response="Error: Homeowner Not Available", status=503)
Esempio n. 6
0
def get_problems(houseId):
    homeownerService = zookeeper.get_service("homeowner-service")
    if homeownerService:
        homeownerManager = RequestManager(request, homeownerService)
        homeownerId = homeownerManager.authenticate()
        if homeownerId:
            problemService = zookeeper.get_service("problem-service")
            if problemService:
                problemManager = RequestManager(request, problemService)
                return problemManager.get("problem/v1/House/" + str(houseId) +
                                          "/Problem")
            return Response(response="Error: problem service Not Available",
                            status=503)
        return Response(response="Not Authorized", status=401)
    return Response(response="Error: Homeowner Not Available", status=503)
Esempio n. 7
0
def get_arrangement_form():
    homeownerService = zookeeper.get_service("homeowner-service")
    if homeownerService:
        homeownerManager = RequestManager(request, homeownerService)
        homeownerId = homeownerManager.authenticate()
        if homeownerId:
            houseService = zookeeper.get_service("house-service")
            if houseService:
                houseManager = RequestManager(request, houseService)
                return houseManager.get_html("/house/v1/House/" +
                                             str(homeownerId))
            return Response(
                response="Error: House Service Currently Unavailable",
                status=503)
        return Response(response="Not Authorized", status=401)
    return Response(response="Error: Homeowner Not Available", status=503)
Esempio n. 8
0
def view_rent_details(province, houseId):
    homeownerService = zookeeper.get_service("homeowner-service")
    if homeownerService:
        homeownerManager = RequestManager(request, homeownerService)
        homeownerId = homeownerManager.authenticate()
        if homeownerId:
            leaseService = zookeeper.get_service("lease-service")
            if leaseService:
                leaseManager = RequestManager(request, leaseService)
                return leaseManager.get_html("/lease/v1/RentDetails/" +
                                             province + "/" + str(houseId))
            return Response(
                response="Error: House Service Currently Unavailable",
                status=503)
        return Response(response="Not Authorized", status=401)
    return Response(response="Error: Lease Not Available", status=503)
Esempio n. 9
0
def create_arrangement():
    homeownerService = zookeeper.get_service("homeowner-service")
    if homeownerService:
        headers = {"Authorization": "Bearer " + request.form.get("token")}
        homeownerManager = RequestManager(request, homeownerService)
        homeownerId = homeownerManager.authenticate(headers=headers)
        if homeownerId:
            houseService = zookeeper.get_service("house-service")
            if houseService:
                houseManager = RequestManager(request, houseService)
                return houseManager.post_html("/house/v1/House/" +
                                              str(homeownerId),
                                              headers=headers)
            return Response(
                response="Error: House Service Currently Unavailable",
                status=503)
        return Response(response="Not Authorized", status=401)
    return Response(response="Error: Homeowner Not Available", status=503)
Esempio n. 10
0
def create_rent_details(province, houseId):
    homeownerService = zookeeper.get_service("homeowner-service")
    if homeownerService:
        headers = {"Authorization": "Bearer " + request.form.get("token")}
        homeownerManager = RequestManager(request, homeownerService)
        homeownerId = homeownerManager.authenticate(headers=headers)
        if homeownerId:
            leaseService = zookeeper.get_service("lease-service")
            if leaseService:
                leaseManager = RequestManager(request, leaseService)
                return leaseManager.post_html("/lease/v1/RentDetails/" +
                                              province + "/" + str(houseId),
                                              headers=headers)
            return Response(
                response="Error: House Service Currently Unavailable",
                status=503)
        return Response(response="Not Authorized", status=401)
    return Response(response="Error: Lease Not Available", status=503)