def customer_deleted(item): try: msg_data = json.loads(item['entity']) msg = """Dear {}! Good bye, hope to see you soon again at Ordershop. Cheers""".format(msg_data['name']) requests.post('http://msg-service:5000/email', json={ "to": msg_data['email'], "msg": msg }) except Exception as e: log_error(e)
def customer_created(item): try: msg_data = json.loads(item['entity']) msg = """Dear {}! Welcome to Ordershop. Cheers""".format(msg_data['name']) requests.post('http://msg-service:5000/email', json={ "to": msg_data['email'], "msg": msg }) except Exception as e: log_error(e)
def order_created(item): try: msg_data = json.loads(item['entity']) customer = store.find_one('customer', msg_data['customer_id']) products = [ store.find_one('product', product_id) for product_id in msg_data['product_ids'] ] msg = """Dear {}! Please transfer β¬ {} with your favourite payment method. Cheers""".format(customer['name'], sum([int(product['price']) for product in products])) requests.post('http://msg-service:5000/email', json={ "to": customer['email'], "msg": msg }) except Exception as e: log_error(e)
def billing_created(item): try: msg_data = json.loads(item['entity']) order = store.find_one('order', msg_data['order_id']) customer = store.find_one('customer', order['customer_id']) products = [ store.find_one('product', product_id) for product_id in order['product_ids'] ] msg = """Dear {}! We've just received β¬ {} from you, thank you for your transfer. Cheers""".format(customer['name'], sum([int(product['price']) for product in products])) requests.post('http://msg-service:5000/email', json={ "to": customer['email'], "msg": msg }) except Exception as e: log_error(e)
def order_created(item): try: msg_data = json.loads(item['entity']) customer = store.find_one('customer', msg_data['customer_id']) products = [ store.find_one('product', product_id) for product_id in msg_data['product_ids'] ] msg = """Dear {}! Thank you for buying following {} products from Ordershop: {} Cheers""".format(customer['name'], len(products), ", ".join([product['name'] for product in products])) requests.post('http://msg-service:5000/email', json={ "to": customer['email'], "msg": msg }) except Exception as e: log_error(e)