def get(self, id=None): try: if not id: customers = Customers.return_all() return jsonify({'customers': customers}) else: customer = Customers.return_one(id) return jsonify({'customer': serialize(customer)}) except: return {'message': 'Something went wrong'}, 500
def put(self): try: data = parserC.parse_args() if data['id'] == None: return {'message': 'customer_id field cannot be blank'}, 400 customer = Customers.return_one(data['id']) if data['name'] != None: customer.name = data['name'] if data['dob'] != None: customer.dob = data['dob'] customer.updated_at = datetime.now() Customers.commit() return { 'message': 'Customer {} was updated'.format(data['name']), 'customer_id': data['id'] }, 200 except: return {'message': 'Something went wrong'}, 500