Subversion Repositories SmartDukaan

Rev

Rev 13868 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
13804 amit.gupta 1
'''
2
Created on Feb 12, 2015
3
 
4
@author: amit
5
'''
6
from dtr import main
7
from dtr.storage import Mongo
8
import falcon
9
import json
10
class StoreOrder():
11
    def on_post(self, req, resp):
12
 
13
        try:
14
            string1 = req.stream.read()
15
            req_json = json.loads(string1, encoding='utf-8')
16
        except ValueError:
17
            raise falcon.HTTPError(falcon.HTTP_400,
18
                'Malformed JSON',
19
                'Could not decode the request body. The '
20
                'JSON was incorrect.')
21
 
22
        store = main.getStore(int(req_json['sourceId']))
23
        result = store.parseOrderRawHtml(int(req_json['orderId']), req_json['subTagId'], int(req_json['userId']), req_json['rawHtml'], req_json['orderSuccessUrl'])
24
        resp.body = json.dumps(result, encoding='utf-8')
25
 
26
    def on_get(self, req, resp, userId):
27
        page = req.get_param_as_int("page")
28
        window = req.get_param_as_int("window")
29
        result = Mongo.getMerchantOrdersByUser(int(userId), page, window)
30
        resp.body = json.dumps(result, encoding='utf-8')