| Line 13... |
Line 13... |
| 13 |
result = Mongo.getAllCategoryDiscount()
|
13 |
result = Mongo.getAllCategoryDiscount()
|
| 14 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
14 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
| 15 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
15 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
| 16 |
|
16 |
|
| 17 |
def on_post(self, req, resp):
|
17 |
def on_post(self, req, resp):
|
| 18 |
|
18 |
print "Inside post"
|
| 19 |
try:
|
19 |
try:
|
| 20 |
result_json = json.loads(req.stream.read(), encoding='utf-8')
|
20 |
result_json = json.loads(req.stream.read(), encoding='utf-8')
|
| 21 |
except ValueError:
|
21 |
except ValueError:
|
| 22 |
raise falcon.HTTPError(falcon.HTTP_400,
|
22 |
raise falcon.HTTPError(falcon.HTTP_400,
|
| 23 |
'Malformed JSON',
|
23 |
'Malformed JSON',
|
| 24 |
'Could not decode the request body. The '
|
24 |
'Could not decode the request body. The '
|
| 25 |
'JSON was incorrect.')
|
25 |
'JSON was incorrect.')
|
| 26 |
|
26 |
|
| 27 |
result = Mongo.addCategoryDiscount(result_json)
|
27 |
result = Mongo.addCategoryDiscount(result_json)
|
| 28 |
resp.body = json.dumps(result, encoding='utf-8')
|
28 |
resp.body = json.dumps(result, encoding='utf-8')
|
| 29 |
|
29 |
|
| 30 |
class SkuSchemeDetails(object):
|
30 |
class SkuSchemeDetails(object):
|
| 31 |
|
31 |
|
| 32 |
def on_get(self, req, resp):
|
32 |
def on_get(self, req, resp):
|
| 33 |
|
33 |
|
| 34 |
result = Mongo.getAllSkuWiseSchemeDetails()
|
34 |
result = Mongo.getAllSkuWiseSchemeDetails()
|
| Line 99... |
Line 99... |
| 99 |
limit = req.get_param_as_int("limit")
|
99 |
limit = req.get_param_as_int("limit")
|
| 100 |
sort = req.get_param("sort")
|
100 |
sort = req.get_param("sort")
|
| 101 |
direction = req.get_param_as_int("direction")
|
101 |
direction = req.get_param_as_int("direction")
|
| 102 |
result = Mongo.getDeals(categoryId, offset, limit, sort, direction)
|
102 |
result = Mongo.getDeals(categoryId, offset, limit, sort, direction)
|
| 103 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
103 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
| 104 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
104 |
resp.body = json_docs
|
| 105 |
|
105 |
|
| 106 |
class MasterData():
|
106 |
class MasterData():
|
| 107 |
def on_get(self,req, resp, skuId):
|
107 |
def on_get(self,req, resp, skuId):
|
| 108 |
result = Mongo.getItem(skuId)
|
108 |
result = Mongo.getItem(skuId)
|
| 109 |
try:
|
109 |
try:
|
| 110 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
110 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
| 111 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
111 |
resp.body = json_docs
|
| 112 |
except:
|
112 |
except:
|
| 113 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
113 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
| 114 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
114 |
resp.body = json_docs
|
| 115 |
|
115 |
|
| 116 |
class LiveData():
|
116 |
class LiveData():
|
| 117 |
def on_get(self,req, resp):
|
117 |
def on_get(self,req, resp):
|
| 118 |
if req.get_param_as_int("id") is not None:
|
118 |
if req.get_param_as_int("id") is not None:
|
| 119 |
print "****getting only for id"
|
119 |
print "****getting only for id"
|
| 120 |
id = req.get_param_as_int("id")
|
120 |
id = req.get_param_as_int("id")
|
| 121 |
try:
|
121 |
try:
|
| 122 |
result = FetchLivePrices.getLatestPriceById(id)
|
122 |
result = FetchLivePrices.getLatestPriceById(id)
|
| 123 |
json_docs = json.dumps(result, default=json_util.default)
|
123 |
json_docs = json.dumps(result, default=json_util.default)
|
| 124 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
124 |
resp.body = json_docs
|
| 125 |
except:
|
125 |
except:
|
| 126 |
json_docs = json.dumps({}, default=json_util.default)
|
126 |
json_docs = json.dumps({}, default=json_util.default)
|
| 127 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
127 |
resp.body = json_docs
|
| 128 |
|
128 |
|
| 129 |
else:
|
129 |
else:
|
| 130 |
print "****getting only for skuId"
|
130 |
print "****getting only for skuId"
|
| 131 |
skuBundleId = req.get_param_as_int("skuBundleId")
|
131 |
skuBundleId = req.get_param_as_int("skuBundleId")
|
| 132 |
source_id = req.get_param_as_int("source_id")
|
132 |
source_id = req.get_param_as_int("source_id")
|
| 133 |
try:
|
133 |
try:
|
| 134 |
result = FetchLivePrices.getLatestPrice(skuBundleId, source_id)
|
134 |
result = FetchLivePrices.getLatestPrice(skuBundleId, source_id)
|
| 135 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
135 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
| 136 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
136 |
resp.body = json_docs
|
| 137 |
except:
|
137 |
except:
|
| 138 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in [{}]]
|
138 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in [{}]]
|
| 139 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
139 |
resp.body = json_docs
|
| 140 |
|
140 |
|
| 141 |
class CashBack():
|
141 |
class CashBack():
|
| 142 |
def on_get(self,req, resp):
|
142 |
def on_get(self,req, resp):
|
| 143 |
identifier = req.get_param("identifier")
|
143 |
identifier = req.get_param("identifier")
|
| 144 |
source_id = req.get_param_as_int("source_id")
|
144 |
source_id = req.get_param_as_int("source_id")
|
| Line 146... |
Line 146... |
| 146 |
result = Mongo.getCashBackDetails(identifier, source_id)
|
146 |
result = Mongo.getCashBackDetails(identifier, source_id)
|
| 147 |
json_docs = json.dumps(result, default=json_util.default)
|
147 |
json_docs = json.dumps(result, default=json_util.default)
|
| 148 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
148 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
| 149 |
except:
|
149 |
except:
|
| 150 |
json_docs = json.dumps({}, default=json_util.default)
|
150 |
json_docs = json.dumps({}, default=json_util.default)
|
| 151 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
151 |
resp.body = json_docs
|
| 152 |
|
152 |
|
| 153 |
class DealSheet():
|
153 |
class DealSheet():
|
| 154 |
def on_get(self,req, resp):
|
154 |
def on_get(self,req, resp):
|
| 155 |
X_DealSheet.sendMail()
|
155 |
X_DealSheet.sendMail()
|
| 156 |
json_docs = json.dumps({'True':'Sheet generated, mail sent.'}, default=json_util.default)
|
156 |
json_docs = json.dumps({'True':'Sheet generated, mail sent.'}, default=json_util.default)
|
| 157 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
157 |
resp.body = json_docs
|
| 158 |
|
158 |
|
| 159 |
|
159 |
|
| 160 |
|
160 |
|