| Line 28... |
Line 28... |
| 28 |
window = req.get_param_as_int("window")
|
28 |
window = req.get_param_as_int("window")
|
| 29 |
result = Mongo.getMerchantOrdersByUser(int(userId), page, window)
|
29 |
result = Mongo.getMerchantOrdersByUser(int(userId), page, window)
|
| 30 |
resp.body = json.dumps(result, encoding='utf-8')
|
30 |
resp.body = json.dumps(result, encoding='utf-8')
|
| 31 |
|
31 |
|
| 32 |
class Track():
|
32 |
class Track():
|
| 33 |
def on_post(self, req, resp):
|
33 |
def on_post(self, req, resp, userId):
|
| 34 |
try:
|
34 |
try:
|
| 35 |
string1 = req.stream.read()
|
35 |
string1 = req.stream.read()
|
| 36 |
req_json = json.loads(string1, encoding='utf-8')
|
36 |
req_json = json.loads(string1, encoding='utf-8')
|
| 37 |
except ValueError:
|
37 |
except ValueError:
|
| 38 |
raise falcon.HTTPError(falcon.HTTP_400,
|
38 |
raise falcon.HTTPError(falcon.HTTP_400,
|
| Line 40... |
Line 40... |
| 40 |
'Could not decode the request body. The '
|
40 |
'Could not decode the request body. The '
|
| 41 |
'JSON was incorrect.')
|
41 |
'JSON was incorrect.')
|
| 42 |
try:
|
42 |
try:
|
| 43 |
store = main.getStore(req.get_param_as_int("storeId"))
|
43 |
store = main.getStore(req.get_param_as_int("storeId"))
|
| 44 |
if req.get_param_as_int("storeId") == 1:
|
44 |
if req.get_param_as_int("storeId") == 1:
|
| 45 |
result = store.trackOrdersForUser(req.get_param_as_int("userId"),req_json['url'],req_json['html'])
|
45 |
result = store.trackOrdersForUser(int(userId),req_json['url'],req_json['html'])
|
| 46 |
resp.body = json.dumps({'result':result}, encoding='utf-8')
|
46 |
resp.body = json.dumps({'result':result}, encoding='utf-8')
|
| 47 |
else:
|
47 |
else:
|
| 48 |
resp.body = json.dumps({'result':'NOT_IMPLEMENTED'}, encoding='utf-8')
|
48 |
resp.body = json.dumps({'result':'NOT_IMPLEMENTED'}, encoding='utf-8')
|
| 49 |
except:
|
49 |
except:
|
| 50 |
resp.body = json.dumps({'result':'PARSE_ERROR'}, encoding='utf-8')
|
50 |
resp.body = json.dumps({'result':'PARSE_ERROR'}, encoding='utf-8')
|
| 51 |
|
51 |
|
| 52 |
def on_get(self, req, resp):
|
52 |
def on_get(self, req, resp, userId):
|
| 53 |
try:
|
53 |
try:
|
| 54 |
userId = req.get_param_as_int("userId")
|
- |
|
| 55 |
storeId = req.get_param_as_int("storeId")
|
54 |
storeId = req.get_param_as_int("storeId")
|
| 56 |
result = main.getStore(storeId).getTrackingUrls(userId)
|
55 |
result = main.getStore(storeId).getTrackingUrls(int(userId))
|
| 57 |
resp.body = json.dumps({'result':result}, encoding='utf-8')
|
56 |
resp.body = json.dumps({'result':result}, encoding='utf-8')
|
| 58 |
except ValueError:
|
57 |
except ValueError:
|
| 59 |
raise falcon.HTTPError(falcon.HTTP_400,
|
58 |
raise falcon.HTTPError(falcon.HTTP_400,
|
| 60 |
'Malformed JSON',
|
59 |
'Malformed JSON',
|
| 61 |
'Could not decode the request body. The '
|
60 |
'Could not decode the request body. The '
|