Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
22636 amit.gupta 1
from shop2020.thriftpy.logistics.ttypes import DeliveryType
2
import urllib
3
import urllib2
4
import json
5
 
6
#Live
7
#username = 'ecomexpress'
8
#password = 'Ke$3c@4oT5m6h#$'
9
#wayBillApi = "http://staging.ecomexpress.in/apiv2/fetch_awb/";
10
#forwardApi = "http://staging.ecomexpress.in/apiv2/manifest_awb/";
11
 
12
#Test
13
username = 'ecomexpress'
14
password = 'Ke$3c@4oT5m6h#$'
15
wayBillApi = "http://staging.ecomexpress.in/apiv2/fetch_awb/";
16
forwardApi = "http://staging.ecomexpress.in/apiv2/manifest_awb/";
17
 
18
#returns list of awb of specified type
19
def generate_awb(deliveryType):
20
    if deliveryType == DeliveryType.COD:
21
        ecomDeliveryType = "COD"
22
    if deliveryType == DeliveryType.PREPAID:
23
        ecomDeliveryType = "PPD"
24
    values = {'username' : username,
25
              'password' : password,
26
              'count' : '100',
27
              'type' : ecomDeliveryType }
28
 
29
    data = urllib.urlencode(values)
30
    req = urllib2.Request(wayBillApi, data)
31
    response = urllib2.urlopen(req)
32
    the_page = response.read()
33
    return json.loads(the_page)['awb']
34
 
35
 
36
 
37
 
38
 
39
def main():
40
    print generate_awb(DeliveryType.PREPAID)
41
 
42
 
43
 
44
if __name__ == '__main__':
45
    main()