def update_customer_credit(customer_id, credit_limit): """ :param customer_id: :type customer_id: :param credit_limit: :type credit_limit: :return: :rtype: """ customer = Customer.get(Customer.customer_id == customer_id) LOGGER.info('Credit limit before the change is {}'.format(customer.credit_limit)) customer.credit_limit = int(credit_limit) customer.save() LOGGER.info('New credit limit is {}'.format(customer.credit_limit))
def delete_customer(customer_id): """ :param customer_id: :type customer_id: :return: :rtype: """ LOGGER.info('Deleting customer with id {}'.format(customer_id)) try: customer = Customer.get(Customer.customer_id == customer_id) customer.delete_instance() except IndexError: LOGGER.info("Customer with id {} doesn't exist".format(customer_id))
def search_customer(customer_id): """ :param customer_id: :type customer_id: :return: :rtype: """ try: customer = Customer.get(Customer.customer_id == customer_id) LOGGER.info('Found customer with id {} '.format(customer_id)) customer_info = {'name': customer.customer_name, 'last_name': customer.customer_last_name, 'email_address': customer.email_address, 'phone_number': customer.phone_number} return customer_info except Customer.DoesNotExist as error: LOGGER.info("Could not find customer with id {}".format(customer_id)) LOGGER.info(error) return {}