Subversion Repositories SmartDukaan

Rev

Rev 13887 | Rev 13939 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13887 Rev 13927
Line 37... Line 37...
37
        except ValueError:
37
        except ValueError:
38
            raise falcon.HTTPError(falcon.HTTP_400,
38
            raise falcon.HTTPError(falcon.HTTP_400,
39
                'Malformed JSON',
39
                'Malformed JSON',
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
        
42
        try:
43
        store = main.getStore(int(req_json['sourceId']))
43
            store = main.getStore(req.get_param_as_int("storeId"))
44
        return store.getUrls(int(req_json['userId']))
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'])
-
 
46
                resp.body = json.dumps({'result':result}, encoding='utf-8')
-
 
47
            else:
-
 
48
                resp.body = json.dumps({'result':'NOT_IMPLEMENTED'}, encoding='utf-8')
-
 
49
        except:
-
 
50
            resp.body = json.dumps({'result':'PARSE_ERROR'}, encoding='utf-8')
45
    
51
    
46
    def on_get(self, req, resp):
52
    def on_get(self, req, resp):
47
        try:
53
        try:
48
            userId = req.get_param_as_int("userId")
54
            userId = req.get_param_as_int("userId")
49
            storeId = req.get_param_as_int("storeId")
55
            storeId = req.get_param_as_int("storeId")
50
            result = main.getStore(storeId).getTrackingUrls(userId)
56
            result = main.getStore(storeId).getTrackingUrls(userId)
51
            print result
-
 
52
            resp.body = json.dumps({'result':result}, encoding='utf-8')
57
            resp.body = json.dumps({'result':result}, encoding='utf-8')
53
        except ValueError:
58
        except ValueError:
54
            raise falcon.HTTPError(falcon.HTTP_400,
59
            raise falcon.HTTPError(falcon.HTTP_400,
55
                'Malformed JSON',
60
                'Malformed JSON',
56
                'Could not decode the request body. The '
61
                'Could not decode the request body. The '
57
                'JSON was incorrect.')
62
                'JSON was incorrect.')
58
        
63
        
59
        
-
 
60
64
class Refunds():
-
 
65
    def on_get(self, req, resp):
-
 
66
        try:
-
 
67
            userId = req.get_param_as_int("userId")
-
 
68
            page = req.get_param_as_int("page")
-
 
69
            window = req.get_param_as_int("window")
-
 
70
            result = Mongo.getRefunds(userId,page,window)
-
 
71
            resp.body = json.dumps(result, encoding='utf-8')
-
 
72
        except ValueError:
-
 
73
            raise falcon.HTTPError(falcon.HTTP_400,
-
 
74
                'Malformed JSON',
-
 
75
                'Could not decode the request body. The '
-
 
76
                'JSON was incorrect.')
-
 
77
        
-
 
78
class PendingRefunds():
-
 
79
    def on_get(self, req, resp,userId):
-
 
80
        try:
-
 
81
            page = req.get_param_as_int("page")
-
 
82
            window = req.get_param_as_int("window")
-
 
83
            result = Mongo.getPendingRefunds(int(userId))
-
 
84
            resp.body = json.dumps(result, encoding='utf-8')
-
 
85
        except ValueError:
-
 
86
            raise falcon.HTTPError(falcon.HTTP_400,
-
 
87
                'Malformed JSON',
-
 
88
                'Could not decode the request body. The '
-
 
89
                'JSON was incorrect.')
-
 
90
61
91