def delete(self, related_user_id): theCustomer = CustomerModel.find_recent_by_related_user_id( related_user_id) if theCustomer: theCustomer.delete_from_db() return {'message': 'theCustomer deleted'}
def get(self, related_user_id): theCustomer = CustomerModel.find_recent_by_related_user_id( related_user_id) if theCustomer: return theCustomer.json() return { 'message': 'customer with related_user_id \'' + related_user_id + '\' not found' }, 404
def put(self, related_user_id): data = Customer.parser.parse_args() theCustomer = CustomerModel.find_recent_by_related_user_id( related_user_id) if theCustomer: # update if exists theCustomer.update_customer( data['credit_limit_balance'], EducationType(data['education']), MaritalStatusType(data['marriage']), data['age'], data['repayment_status_month_1'], data['repayment_status_month_2'], data['repayment_status_month_3'], data['repayment_status_month_4'], data['repayment_status_month_5'], data['repayment_status_month_6'], data['bill_amount_month_1'], data['bill_amount_month_2'], data['bill_amount_month_3'], data['bill_amount_month_4'], data['bill_amount_month_5'], data['bill_amount_month_6'], data['payment_amount_month_1'], data['payment_amount_month_2'], data['payment_amount_month_3'], data['payment_amount_month_4'], data['payment_amount_month_5'], data['payment_amount_month_6'], related_user_id, data['customer_result_id']) else: # create if dne theCustomer = CustomerModel( data['credit_limit_balance'], EducationType(data['education']), MaritalStatusType(data['marriage']), data['age'], data['repayment_status_month_1'], data['repayment_status_month_2'], data['repayment_status_month_3'], data['repayment_status_month_4'], data['repayment_status_month_5'], data['repayment_status_month_6'], data['bill_amount_month_1'], data['bill_amount_month_2'], data['bill_amount_month_3'], data['bill_amount_month_4'], data['bill_amount_month_5'], data['bill_amount_month_6'], data['payment_amount_month_1'], data['payment_amount_month_2'], data['payment_amount_month_3'], data['payment_amount_month_4'], data['payment_amount_month_5'], data['payment_amount_month_6'], related_user_id, data['customer_result_id']) # OR USE: theCustomer = CustomerModel(related_user_id, **data) theCustomer.save_to_db() return theCustomer.json()