| 94 |
ashish |
1 |
#!/usr/bin/env python
|
|
|
2 |
#
|
|
|
3 |
# Autogenerated by Thrift
|
|
|
4 |
#
|
|
|
5 |
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
|
|
6 |
#
|
|
|
7 |
|
|
|
8 |
import sys
|
|
|
9 |
import pprint
|
|
|
10 |
from urlparse import urlparse
|
|
|
11 |
from thrift.transport import TTransport
|
|
|
12 |
from thrift.transport import TSocket
|
|
|
13 |
from thrift.transport import THttpClient
|
|
|
14 |
from thrift.protocol import TBinaryProtocol
|
|
|
15 |
|
|
|
16 |
import TransactionService
|
|
|
17 |
from ttypes import *
|
|
|
18 |
|
|
|
19 |
if len(sys.argv) <= 1 or sys.argv[1] == '--help':
|
|
|
20 |
print ''
|
|
|
21 |
print 'Usage: ' + sys.argv[0] + ' [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
|
|
|
22 |
print ''
|
|
|
23 |
print 'Functions:'
|
| 132 |
ashish |
24 |
print ' i64 createTransaction(Transaction transaction)'
|
| 94 |
ashish |
25 |
print ' Transaction getTransaction(i64 id)'
|
|
|
26 |
print ' getAllTransactions(TransactionStatus status, i64 from_date, i64 to_date)'
|
|
|
27 |
print ' getTransactionsForShipmentStatus(ShipmentStatus status, i64 from_date, i64 to_date)'
|
|
|
28 |
print ' getTransactionsForCustomer(i64 customerId, i64 from_date, i64 to_date, TransactionStatus status)'
|
|
|
29 |
print ' getTransactionsForCustomerAndShipmentStatus(i64 customerId, i64 from_date, i64 to_date, ShipmentStatus status)'
|
| 132 |
ashish |
30 |
print ' getTransactionsForShoppingCartId(i64 shoppingCartId)'
|
| 94 |
ashish |
31 |
print ' TransactionStatus getTransactionStatus(i64 transactionId)'
|
|
|
32 |
print ' bool changeTransactionStatus(i64 transactionId, TransactionStatus status, string description)'
|
|
|
33 |
print ' OrderInfo getOrderInfo(i64 transactionId)'
|
|
|
34 |
print ' ShipmentInfo getShippingInfo(i64 transactionId)'
|
|
|
35 |
print ' BillingInfo getBillingInfo(i64 transactionId)'
|
|
|
36 |
print ' bool addBilling(i64 tranactionId, Billing billing)'
|
|
|
37 |
print ' bool setShippingTracker(i64 transactionId, i64 shippingId, string trackingId, string airwayBillNo, string provider)'
|
|
|
38 |
print ' bool setShippingDate(i64 transactionId, i64 shippingId, i64 timestamp)'
|
|
|
39 |
print ' bool setDeliveryDate(i64 transactionId, i64 shippingid, i64 timestamp)'
|
|
|
40 |
print ' bool changeShippingStatus(i64 transactionId, i64 shippingId, ShipmentStatus status, string description)'
|
|
|
41 |
print ' bool addTrail(i64 transactionId, string description)'
|
|
|
42 |
print ''
|
|
|
43 |
sys.exit(0)
|
|
|
44 |
|
|
|
45 |
pp = pprint.PrettyPrinter(indent = 2)
|
|
|
46 |
host = 'localhost'
|
|
|
47 |
port = 9090
|
|
|
48 |
uri = ''
|
|
|
49 |
framed = False
|
|
|
50 |
http = False
|
|
|
51 |
argi = 1
|
|
|
52 |
|
|
|
53 |
if sys.argv[argi] == '-h':
|
|
|
54 |
parts = sys.argv[argi+1].split(':')
|
|
|
55 |
host = parts[0]
|
|
|
56 |
port = int(parts[1])
|
|
|
57 |
argi += 2
|
|
|
58 |
|
|
|
59 |
if sys.argv[argi] == '-u':
|
|
|
60 |
url = urlparse(sys.argv[argi+1])
|
|
|
61 |
parts = url[1].split(':')
|
|
|
62 |
host = parts[0]
|
|
|
63 |
if len(parts) > 1:
|
|
|
64 |
port = int(parts[1])
|
|
|
65 |
else:
|
|
|
66 |
port = 80
|
|
|
67 |
uri = url[2]
|
|
|
68 |
http = True
|
|
|
69 |
argi += 2
|
|
|
70 |
|
|
|
71 |
if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
|
|
|
72 |
framed = True
|
|
|
73 |
argi += 1
|
|
|
74 |
|
|
|
75 |
cmd = sys.argv[argi]
|
|
|
76 |
args = sys.argv[argi+1:]
|
|
|
77 |
|
|
|
78 |
if http:
|
|
|
79 |
transport = THttpClient.THttpClient(host, port, uri)
|
|
|
80 |
else:
|
|
|
81 |
socket = TSocket.TSocket(host, port)
|
|
|
82 |
if framed:
|
|
|
83 |
transport = TTransport.TFramedTransport(socket)
|
|
|
84 |
else:
|
|
|
85 |
transport = TTransport.TBufferedTransport(socket)
|
|
|
86 |
protocol = TBinaryProtocol.TBinaryProtocol(transport)
|
|
|
87 |
client = TransactionService.Client(protocol)
|
|
|
88 |
transport.open()
|
|
|
89 |
|
|
|
90 |
if cmd == 'createTransaction':
|
|
|
91 |
if len(args) != 1:
|
|
|
92 |
print 'createTransaction requires 1 args'
|
|
|
93 |
sys.exit(1)
|
|
|
94 |
pp.pprint(client.createTransaction(eval(args[0]),))
|
|
|
95 |
|
|
|
96 |
elif cmd == 'getTransaction':
|
|
|
97 |
if len(args) != 1:
|
|
|
98 |
print 'getTransaction requires 1 args'
|
|
|
99 |
sys.exit(1)
|
|
|
100 |
pp.pprint(client.getTransaction(eval(args[0]),))
|
|
|
101 |
|
|
|
102 |
elif cmd == 'getAllTransactions':
|
|
|
103 |
if len(args) != 3:
|
|
|
104 |
print 'getAllTransactions requires 3 args'
|
|
|
105 |
sys.exit(1)
|
|
|
106 |
pp.pprint(client.getAllTransactions(eval(args[0]),eval(args[1]),eval(args[2]),))
|
|
|
107 |
|
|
|
108 |
elif cmd == 'getTransactionsForShipmentStatus':
|
|
|
109 |
if len(args) != 3:
|
|
|
110 |
print 'getTransactionsForShipmentStatus requires 3 args'
|
|
|
111 |
sys.exit(1)
|
|
|
112 |
pp.pprint(client.getTransactionsForShipmentStatus(eval(args[0]),eval(args[1]),eval(args[2]),))
|
|
|
113 |
|
|
|
114 |
elif cmd == 'getTransactionsForCustomer':
|
|
|
115 |
if len(args) != 4:
|
|
|
116 |
print 'getTransactionsForCustomer requires 4 args'
|
|
|
117 |
sys.exit(1)
|
|
|
118 |
pp.pprint(client.getTransactionsForCustomer(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
|
|
|
119 |
|
|
|
120 |
elif cmd == 'getTransactionsForCustomerAndShipmentStatus':
|
|
|
121 |
if len(args) != 4:
|
|
|
122 |
print 'getTransactionsForCustomerAndShipmentStatus requires 4 args'
|
|
|
123 |
sys.exit(1)
|
|
|
124 |
pp.pprint(client.getTransactionsForCustomerAndShipmentStatus(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
|
|
|
125 |
|
| 132 |
ashish |
126 |
elif cmd == 'getTransactionsForShoppingCartId':
|
|
|
127 |
if len(args) != 1:
|
|
|
128 |
print 'getTransactionsForShoppingCartId requires 1 args'
|
|
|
129 |
sys.exit(1)
|
|
|
130 |
pp.pprint(client.getTransactionsForShoppingCartId(eval(args[0]),))
|
|
|
131 |
|
| 94 |
ashish |
132 |
elif cmd == 'getTransactionStatus':
|
|
|
133 |
if len(args) != 1:
|
|
|
134 |
print 'getTransactionStatus requires 1 args'
|
|
|
135 |
sys.exit(1)
|
|
|
136 |
pp.pprint(client.getTransactionStatus(eval(args[0]),))
|
|
|
137 |
|
|
|
138 |
elif cmd == 'changeTransactionStatus':
|
|
|
139 |
if len(args) != 3:
|
|
|
140 |
print 'changeTransactionStatus requires 3 args'
|
|
|
141 |
sys.exit(1)
|
|
|
142 |
pp.pprint(client.changeTransactionStatus(eval(args[0]),eval(args[1]),args[2],))
|
|
|
143 |
|
|
|
144 |
elif cmd == 'getOrderInfo':
|
|
|
145 |
if len(args) != 1:
|
|
|
146 |
print 'getOrderInfo requires 1 args'
|
|
|
147 |
sys.exit(1)
|
|
|
148 |
pp.pprint(client.getOrderInfo(eval(args[0]),))
|
|
|
149 |
|
|
|
150 |
elif cmd == 'getShippingInfo':
|
|
|
151 |
if len(args) != 1:
|
|
|
152 |
print 'getShippingInfo requires 1 args'
|
|
|
153 |
sys.exit(1)
|
|
|
154 |
pp.pprint(client.getShippingInfo(eval(args[0]),))
|
|
|
155 |
|
|
|
156 |
elif cmd == 'getBillingInfo':
|
|
|
157 |
if len(args) != 1:
|
|
|
158 |
print 'getBillingInfo requires 1 args'
|
|
|
159 |
sys.exit(1)
|
|
|
160 |
pp.pprint(client.getBillingInfo(eval(args[0]),))
|
|
|
161 |
|
|
|
162 |
elif cmd == 'addBilling':
|
|
|
163 |
if len(args) != 2:
|
|
|
164 |
print 'addBilling requires 2 args'
|
|
|
165 |
sys.exit(1)
|
|
|
166 |
pp.pprint(client.addBilling(eval(args[0]),eval(args[1]),))
|
|
|
167 |
|
|
|
168 |
elif cmd == 'setShippingTracker':
|
|
|
169 |
if len(args) != 5:
|
|
|
170 |
print 'setShippingTracker requires 5 args'
|
|
|
171 |
sys.exit(1)
|
|
|
172 |
pp.pprint(client.setShippingTracker(eval(args[0]),eval(args[1]),args[2],args[3],args[4],))
|
|
|
173 |
|
|
|
174 |
elif cmd == 'setShippingDate':
|
|
|
175 |
if len(args) != 3:
|
|
|
176 |
print 'setShippingDate requires 3 args'
|
|
|
177 |
sys.exit(1)
|
|
|
178 |
pp.pprint(client.setShippingDate(eval(args[0]),eval(args[1]),eval(args[2]),))
|
|
|
179 |
|
|
|
180 |
elif cmd == 'setDeliveryDate':
|
|
|
181 |
if len(args) != 3:
|
|
|
182 |
print 'setDeliveryDate requires 3 args'
|
|
|
183 |
sys.exit(1)
|
|
|
184 |
pp.pprint(client.setDeliveryDate(eval(args[0]),eval(args[1]),eval(args[2]),))
|
|
|
185 |
|
|
|
186 |
elif cmd == 'changeShippingStatus':
|
|
|
187 |
if len(args) != 4:
|
|
|
188 |
print 'changeShippingStatus requires 4 args'
|
|
|
189 |
sys.exit(1)
|
|
|
190 |
pp.pprint(client.changeShippingStatus(eval(args[0]),eval(args[1]),eval(args[2]),args[3],))
|
|
|
191 |
|
|
|
192 |
elif cmd == 'addTrail':
|
|
|
193 |
if len(args) != 2:
|
|
|
194 |
print 'addTrail requires 2 args'
|
|
|
195 |
sys.exit(1)
|
|
|
196 |
pp.pprint(client.addTrail(eval(args[0]),args[1],))
|
|
|
197 |
|
|
|
198 |
transport.close()
|