def put(self, customer_id): ''' Update an existing customer. It is not possible to update the email address or the password using this service. TODO: Use patch when wtf-forms will be ready :param customer_id: The id of the customer to update Returns a json representation of a customer. ''' form = CustomerForm.from_json(request.get_json()) if not form.validate_on_submit(): return jsonify(errors=form.errors) customer = CustomerService.get_customer_by_id(customer_id) if customer is None: return jsonify(msg="Could not find customer") customer.data.cellphone = form.cellphone.data customer.data.first_name = form.first_name.data customer.data.last_name = form.last_name.data customer.data.newsletter = form.newsletter.data CustomerService.update_customer(customer) return jsonify(customer=customer.json)
def put(self, customer_id): ''' Update an existing customer. It is not possible to update the email address or the password using this service. TODO: Use patch when wtf-forms will be ready :param customer_id: The id of the customer to update Returns a json representation of a customer. ''' form = CustomerForm.from_json(request.get_json()) if not form.validate_on_submit(): return jsonify(errors=form.errors) customer = CustomerService.get_customer_by_id(customer_id) if customer is None: return jsonify(msg="Could not find customer") customer.data.cellphone = form.cellphone.data customer.data.first_name = form.first_name.data customer.data.last_name = form.last_name.data customer.data.newsletter = form.newsletter.data CustomerService.update_customer(customer) return jsonify(customer=customer.json)
def get(self, customer_id): ''' Returns one customer :param customer_id: The ID of the customer to retrieve. ''' customer = CustomerService.get_customer_by_id(customer_id) if customer is None: return jsonify(msg="Could not find customer") return jsonify(customer=customer.json)
def get(self, customer_id): ''' Returns one customer :param customer_id: The ID of the customer to retrieve. ''' customer = CustomerService.get_customer_by_id(customer_id) if customer is None: return jsonify( msg="Could not find customer" ) return jsonify( customer=customer.json )