Example #1
0
 def put(self):
     # update a single customer
     print('Customer API: update a single customer')
     requestData = request.get_data().decode('utf8')
     customerData = json.loads(requestData)        
     newCustomer = Customer()
     newCustomer.id = customerData['p_customer_id']
     newCustomer.firstName = customerData['p_first_name']
     newCustomer.lastName = customerData['p_last_name']
     newCustomer.email = customerData['p_email']
     newCustomer.subscribe = customerData['p_subscribe']
     newCustomer.category = customerData['p_category']
     mod_customer(newCustomer) 
     return jsonify({"data":"5"})
Example #2
0
 def post(self):
     # create a new customer
     print('Customer API: create a new customer')
     # print(type(json.dumps(request.data)))
     requestData = request.get_data().decode('utf8')
     customerData = json.loads(requestData)
     newCustomer = Customer()
     newCustomer.firstName = customerData['p_first_name']
     newCustomer.lastName = customerData['p_last_name']
     newCustomer.email = customerData['p_email']
     newCustomer.subscribe = customerData['p_subscribe']
     newCustomer.category = customerData['p_category']
     add_customer(newCustomer)
     # TODO: Finish this section, then do "def put()"
     return jsonify({"Saved": True})