def readAll(ownerId):
     # Authenticate
     authenticator = Authenticator(request.headers.get(HeaderKey.TOKEN)).allowAgent().allowOwner(ownerId)
     authentification = authenticator.authenticate()
     if FieldKey.ERROR in authentification:
         return ResponseFormatter.getFormattedValidatorResponse(authentification)
     # Call Service Layer
     response = PropertyService.readAll(ownerId)
     return ResponseFormatter.getFormmattedServiceListResponse(PropertyConverter.toResource, response)
Exemplo n.º 2
0
 def getAll(customerId):
     # Authenticate
     authenticator = Authenticator(request.headers.get(HeaderKey.TOKEN)).allowAgent().allowCustomer(customerId)
     authentification = authenticator.authenticate()
     if FieldKey.ERROR in authentification:
         return ResponseFormatter.getFormattedValidatorResponse(authentification)
     # Call Service Layer
     response = ViewingService.readAll(customerId)
     return ResponseFormatter.getFormmattedServiceListResponse(ViewingConverter.toResource, response)
 def history(ownerId):
     # Authenticate
     authenticator = Authenticator(request.headers.get(HeaderKey.TOKEN)).allowAgent().allowOwner(ownerId)
     authentification = authenticator.authenticate()
     if FieldKey.ERROR in authentification:
         return ResponseFormatter.getFormattedValidatorResponse(authentification)
     # Create Domain Instance
     start = request.args.get('start', default=None, type=str)
     end = request.args.get('end', default=None, type=str)
     # Call Service Layer
     response = PropertyService.history(ownerId, start, end)
     return ResponseFormatter.getFormmattedServiceListResponse(PropertyConverter.toResource, response)
Exemplo n.º 4
0
 def remove(propertyId, imageId):
     # Authenticate
     authenticator = Authenticator(request.headers.get(
         HeaderKey.TOKEN)).allowAgent().allowOwnerOf(
             Property, "ownerId", propertyId)
     authentification = authenticator.authenticate()
     if FieldKey.ERROR in authentification:
         return ResponseFormatter.getFormattedValidatorResponse(
             authentification)
     # Call Service Layer
     response = ImageService.remove(propertyId, imageId)
     return ResponseFormatter.getFormmattedServiceResponse(
         ImageConverter.toResource, response)
Exemplo n.º 5
0
 def delete(accountId):
     # Authenticate
     authenticator = Authenticator(request.headers.get(
         HeaderKey.TOKEN)).allowAgent().allowCustomer(accountId).allowOwner(
             accountId)
     authentification = authenticator.authenticate()
     if FieldKey.ERROR in authentification:
         return ResponseFormatter.getFormattedValidatorResponse(
             authentification)
     # Call Service Layer
     response = AccountService.delete(accountId)
     return ResponseFormatter.getFormmattedServiceResponse(
         AccountConverter.toResource, response)
Exemplo n.º 6
0
 def read(rentalId):
     # Authenticate
     authenticator = Authenticator(request.headers.get(
         HeaderKey.TOKEN)).allowAgent().allowOwnerOf(
             Rental, "customer", rentalId)
     authentification = authenticator.authenticate()
     if FieldKey.ERROR in authentification:
         return ResponseFormatter.getFormattedValidatorResponse(
             authentification)
     # Call Service Layer
     response = RentalService.read(rentalId)
     return ResponseFormatter.getFormmattedServiceResponse(
         RentalConverter.toResource, response)
Exemplo n.º 7
0
 def update(customerId, viewingId, viewingResource):
     # Authenticate
     authenticator = Authenticator(request.headers.get(HeaderKey.TOKEN)).allowAgent().allowCustomer(customerId)
     authentification = authenticator.authenticate()
     if FieldKey.ERROR in authentification:
         return ResponseFormatter.getFormattedValidatorResponse(authentification)
     # Validate Resource
     viewingResourceValidation = ViewingValidator.validateUpdate(viewingResource)
     if FieldKey.ERROR in viewingResourceValidation:
         return ResponseFormatter.getFormattedValidatorResponse(viewingResourceValidation)
     # Create Domain Instance
     viewing = ViewingConverter.toDomain(viewingResource)
     viewing.id = viewingId
     # Call Service Layer
     response = ViewingService.update(viewing)
     return ResponseFormatter.getFormmattedServiceResponse(ViewingConverter.toResource, response)
 def update(ownerId, propertyId, propertyResource):
     # Authenticate
     authenticator = Authenticator(request.headers.get(HeaderKey.TOKEN)).allowAgent().allowOwner(ownerId)
     authentification = authenticator.authenticate()
     if FieldKey.ERROR in authentification:
         return ResponseFormatter.getFormattedValidatorResponse(authentification)
     # Validate Resource
     propertyResourceValidation = PropertyValidator.validateUpdate(propertyResource)
     if FieldKey.ERROR in propertyResourceValidation:
         return ResponseFormatter.getFormattedValidatorResponse(propertyResourceValidation)
     # Create Domain Instance
     property = PropertyConverter.toDomain(propertyResource)
     property.id = propertyId
     # Call Service Layer
     response = PropertyService.update(ownerId, property)
     return ResponseFormatter.getFormmattedServiceResponse(PropertyConverter.toResource, response)
Exemplo n.º 9
0
 def readAll(propertyId):
     # Authenticate
     # All Access
     # Call Service Layer
     response = ImageService.readAll(propertyId)
     return ResponseFormatter.getFormmattedServiceListResponse(
         ImageConverter.toResource, response)
Exemplo n.º 10
0
 def cancel(rentalId):
     # Authenticate
     authenticator = Authenticator(request.headers.get(
         HeaderKey.TOKEN)).allowAgent()
     authentification = authenticator.authenticate()
     if FieldKey.ERROR in authentification:
         return ResponseFormatter.getFormattedValidatorResponse(
             authentification)
     # Create Domain Instance
     rental = Rental()
     rental.id = rentalId
     rental.status = RentalStatus.CANCELLED
     # Call Service Layer
     response = RentalService.update(rental)
     return ResponseFormatter.getFormmattedServiceResponse(
         RentalConverter.toResource, response)
Exemplo n.º 11
0
 def add(propertyId):
     # Authentication
     authenticator = Authenticator(request.headers.get(
         HeaderKey.TOKEN)).allowAgent().allowOwnerOf(
             Property, "ownerId", propertyId)
     authentification = authenticator.authenticate()
     if FieldKey.ERROR in authentification:
         return ResponseFormatter.getFormattedValidatorResponse(
             authentification)
     # Create Domain Instance
     image = ImageFactory.createDomain()
     image.id = IdGenerator.generate()
     image.propertyId = propertyId
     image.file = request.files.get("image")
     # Call Service Layer
     response = ImageService.add(image)
     return ResponseFormatter.getFormmattedServiceResponse(
         ImageConverter.toResource, response)
Exemplo n.º 12
0
 def update(propertyId, imageId, imageResource):
     # Authenticate
     authenticator = Authenticator(request.headers.get(
         HeaderKey.TOKEN)).allowAgent().allowOwnerOf(
             Property, "ownerId", propertyId)
     authentification = authenticator.authenticate()
     if FieldKey.ERROR in authentification:
         return ResponseFormatter.getFormattedValidatorResponse(
             authentification)
     # Validate Resource
     imageResourceValidation = ImageValidator.validateUpdate(imageResource)
     if FieldKey.ERROR in imageResourceValidation:
         return ResponseFormatter.getFormattedValidatorResponse(
             imageResourceValidation)
     # Create Domain Instance
     image = ImageConverter.toDomain(imageResource)
     image.id = imageId
     image.propertyId = propertyId
     # Call Service Layer
     response = ImageService.update(image)
     return ResponseFormatter.getFormmattedServiceResponse(
         ImageConverter.toResource, response)
Exemplo n.º 13
0
 def search():
     # Authenticate
         # All Access
     # Create Domain Instance
     criteria = {
         "city": request.args.get("city", default=None, type=str),
         "province": request.args.get("prov", default=None, type=str),
         "min": request.args.get("min", default=None, type=int),
         "max": request.args.get("max", default=None, type=int)
     }
     # Call Service Layer
     response = PropertyService.search(criteria)
     return ResponseFormatter.getFormmattedServiceListResponse(PropertyConverter.toResource, response)
Exemplo n.º 14
0
 def create(rentalResource):
     # Authenticate
     authenticator = Authenticator(request.headers.get(
         HeaderKey.TOKEN)).allowAgent().allowCustomer(
             rentalResource[RentalField.CUSTOMER])
     authentification = authenticator.authenticate()
     if FieldKey.ERROR in authentification:
         return ResponseFormatter.getFormattedValidatorResponse(
             authentification)
     # Validate Resource
     rentalResourceValidation = RentalValidator.validateCreate(
         rentalResource)
     if FieldKey.ERROR in rentalResourceValidation:
         return ResponseFormatter.getFormattedValidatorResponse(
             rentalResourceValidation)
     # Create Domain Instance
     rental = RentalConverter.toDomain(rentalResource)
     rental.id = IdGenerator.generate()
     rental.status = RentalStatus.PROPOSED
     # Call Service Layer
     response = RentalService.create(rental)
     return ResponseFormatter.getFormmattedServiceResponse(
         RentalConverter.toResource, response)
Exemplo n.º 15
0
 def update(rentalId, rentalResource):
     # Authenticate
     authenticator = Authenticator(request.headers.get(
         HeaderKey.TOKEN)).allowAgent().allowOwnerOf(
             Rental, "customer", rentalId)
     authentification = authenticator.authenticate()
     if FieldKey.ERROR in authentification:
         return ResponseFormatter.getFormattedValidatorResponse(
             authentification)
     # Validate Resource
     rentalResourceValidation = RentalValidator.validateUpdate(
         rentalResource)
     if FieldKey.ERROR in rentalResourceValidation:
         return ResponseFormatter.getFormattedValidatorResponse(
             rentalResourceValidation)
     # Create Domain Instance
     rental = RentalConverter.toDomain(rentalResource)
     rental.id = rentalId
     rental.status = RentalStatus.PROPOSED
     # Call Service Layer
     response = RentalService.update(rental)
     return ResponseFormatter.getFormmattedServiceResponse(
         RentalConverter.toReso0urce, response)
Exemplo n.º 16
0
 def update(accountId, accountResource):
     # Authenticate
     authenticator = Authenticator(request.headers.get(
         HeaderKey.TOKEN)).allowAgent().allowCustomer(accountId).allowOwner(
             accountId)
     authentification = authenticator.authenticate()
     if FieldKey.ERROR in authentification:
         return ResponseFormatter.getFormattedValidatorResponse(
             authentification)
     # Validate Resource
     accountResourceValidation = AccountValidator.validateUpdate(
         accountResource)
     if FieldKey.ERROR in accountResourceValidation:
         return ResponseFormatter.getFormattedValidatorResponse(
             accountResourceValidation)
     # Create Domain Instance
     account = AccountConverter.toDomain(accountResource)
     account.id = accountId
     credential = CredentialFactory.createDomain(
         account.id, accountResource[AccountField.PASSWORD])
     # Call Service Layer
     response = AccountService.update(account, credential)
     return ResponseFormatter.getFormmattedServiceResponse(
         AccountConverter.toResource, response)
Exemplo n.º 17
0
 def logout():
     response = SessionService.logout(request.headers.get(HeaderKey.TOKEN))
     return ResponseFormatter.getFormmattedServiceResponse(SessionConverter.toResource, response)
Exemplo n.º 18
0
 def login(resource):
     session = SessionFactory.createDomain(resource[AccountField.USERNAME])
     response = SessionService.login(session, resource[AccountField.PASSWORD])
     return ResponseFormatter.getFormmattedServiceResponse(SessionConverter.toResource, response)
Exemplo n.º 19
0
 def read(propertyId):
     # Authenticate
         # All Access
     # Call Service Layer
     response = PropertyService.read(propertyId)
     return ResponseFormatter.getFormmattedServiceResponse(PropertyConverter.toResource, response)
Exemplo n.º 20
0
 def read(propertyId, imageId):
     # Authenticate
     # All Access
     # Call Service Layer
     file, type = ImageService.read(propertyId, imageId)
     return ResponseFormatter.getFileResponse(file, type)