From 5a52859be26d07f987e3241944776ae2b8202ba2 Mon Sep 17 00:00:00 2001 From: sunpriya Date: Sat, 5 Nov 2016 12:44:02 +0530 Subject: [PATCH] Create db.py --- sunpriya/db.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 sunpriya/db.py diff --git a/sunpriya/db.py b/sunpriya/db.py new file mode 100644 index 0000000..84fd146 --- /dev/null +++ b/sunpriya/db.py @@ -0,0 +1,24 @@ +import constants as constants +from pymongo import MongoClient +from exception import CSSException +import requests + +client=MongoClient() + +db=client[constants.DB_NAME] + +email_id_col=db[constants.EMAIL_ID_COLLECTION] +def get_email_id(): + + resp = email_id_col.find_one() + if resp is not None: + def send_email(): + return requests.post( + "https://api.mailgun.net/v3/samples.mailgun.org/messages", + auth=("api", "key-3ax6xnjp29jd6fds4gc373sgvjxteol0"), + data={"from": "Excited User ", + "to": ["devs@mailgun.net"], + "subject": "Hello", + "text": "Testing some Mailgun awesomeness!", + "o:tracking":True}) + raise CSSException(501, constants.RESPONSE_MESSAGE_NOT_IMPLEMENTED)