Ejemplo n.º 1
0
 async def get(self, request, contract_id):
     """Get all payments from database for current contract"""
     payments = await get_all_payments_for_current_contract(contract_id)
     producer.send(
         'sanic',
         b'Operation: Get all payments for current contract. Success: True')
     return response.json(payments)
Ejemplo n.º 2
0
 async def post(self, request):
     """Add new contract to database"""
     data, err = ContractSchema().load(request.json)
     if err:
         raise ValidationError('ValidationError')
     contract_id = await post_new_contract(data)
     contract = await get_contract_by_id(contract_id)
     producer.send('sanic', b'Operation: Add new contract. Success: True')
     return response.json(contract)
Ejemplo n.º 3
0
 async def put(self, request, contract_id):
     """Change contract by id in database"""
     data, err = ContractSchema().load(request.json)
     if err:
         raise ValidationError('ValidationError')
     contract = await put_contract_by_id(data, contract_id)
     producer.send('sanic',
                   b'Operation: Change contract by id. Success: True')
     return response.json(contract)
Ejemplo n.º 4
0
 async def post(self, request, contract_id):
     """Add new payment to database"""
     data, err = PaymentSchema().load(request.json)
     if err:
         raise ValidationError('ValidationError')
     data['contracts_id'] = contract_id
     payment_id = await post_new_payment(data)
     payment = await get_payment_by_id(contract_id, payment_id)
     producer.send('sanic', b'Operation: Add new payment. Success: True')
     return response.json(payment)
Ejemplo n.º 5
0
 async def get(self, request):
     """Get all contracts from database"""
     contracts = await get_all_contracts()
     producer.send('sanic', b'Operation: Get all contracts. Success: True')
     return response.json(contracts)
Ejemplo n.º 6
0
 async def delete(self, request, contract_id):
     """Delete contract by id from database"""
     contract = await delete_contract_by_id(contract_id)
     producer.send('sanic',
                   b'Operation: Delete contract by id. Success: True')
     return response.json(contract)
Ejemplo n.º 7
0
 async def get(self, request, contract_id):
     """Get contract by id from database"""
     contract = await get_contract_by_id(contract_id)
     producer.send('sanic', b'Operation: Get contract by id. Success: True')
     return response.json(contract)
Ejemplo n.º 8
0
 async def delete(self, request, contract_id, payment_id):
     """Delete payment by id in database"""
     payment = await delete_payment_by_id(contract_id, payment_id)
     producer.send('sanic',
                   b'Operation: Delete payment by id. Success: True')
     return response.json(payment)