| 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)'
|
| 358 |
ashish |
26 |
print ' getAllTransactions(TransactionStatus status, i64 from_date, i64 to_date, i64 warehouse_id)'
|
| 94 |
ashish |
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)'
|
| 304 |
ashish |
42 |
print ' getAlerts(i64 transactionId, bool valid)'
|
|
|
43 |
print ' void setAlert(i64 transactionId, bool unset, i64 type, string comment)'
|
|
|
44 |
print ' ExtraOrderInfo getExtraInfo(i64 transaction_id)'
|
|
|
45 |
print ' void setExtraInfo(i64 transaction_id, i64 sku_id, string model, string colour, string vendor)'
|
| 94 |
ashish |
46 |
print ''
|
|
|
47 |
sys.exit(0)
|
|
|
48 |
|
|
|
49 |
pp = pprint.PrettyPrinter(indent = 2)
|
|
|
50 |
host = 'localhost'
|
|
|
51 |
port = 9090
|
|
|
52 |
uri = ''
|
|
|
53 |
framed = False
|
|
|
54 |
http = False
|
|
|
55 |
argi = 1
|
|
|
56 |
|
|
|
57 |
if sys.argv[argi] == '-h':
|
|
|
58 |
parts = sys.argv[argi+1].split(':')
|
|
|
59 |
host = parts[0]
|
|
|
60 |
port = int(parts[1])
|
|
|
61 |
argi += 2
|
|
|
62 |
|
|
|
63 |
if sys.argv[argi] == '-u':
|
|
|
64 |
url = urlparse(sys.argv[argi+1])
|
|
|
65 |
parts = url[1].split(':')
|
|
|
66 |
host = parts[0]
|
|
|
67 |
if len(parts) > 1:
|
|
|
68 |
port = int(parts[1])
|
|
|
69 |
else:
|
|
|
70 |
port = 80
|
|
|
71 |
uri = url[2]
|
|
|
72 |
http = True
|
|
|
73 |
argi += 2
|
|
|
74 |
|
|
|
75 |
if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
|
|
|
76 |
framed = True
|
|
|
77 |
argi += 1
|
|
|
78 |
|
|
|
79 |
cmd = sys.argv[argi]
|
|
|
80 |
args = sys.argv[argi+1:]
|
|
|
81 |
|
|
|
82 |
if http:
|
|
|
83 |
transport = THttpClient.THttpClient(host, port, uri)
|
|
|
84 |
else:
|
|
|
85 |
socket = TSocket.TSocket(host, port)
|
|
|
86 |
if framed:
|
|
|
87 |
transport = TTransport.TFramedTransport(socket)
|
|
|
88 |
else:
|
|
|
89 |
transport = TTransport.TBufferedTransport(socket)
|
|
|
90 |
protocol = TBinaryProtocol.TBinaryProtocol(transport)
|
|
|
91 |
client = TransactionService.Client(protocol)
|
|
|
92 |
transport.open()
|
|
|
93 |
|
|
|
94 |
if cmd == 'createTransaction':
|
|
|
95 |
if len(args) != 1:
|
|
|
96 |
print 'createTransaction requires 1 args'
|
|
|
97 |
sys.exit(1)
|
|
|
98 |
pp.pprint(client.createTransaction(eval(args[0]),))
|
|
|
99 |
|
|
|
100 |
elif cmd == 'getTransaction':
|
|
|
101 |
if len(args) != 1:
|
|
|
102 |
print 'getTransaction requires 1 args'
|
|
|
103 |
sys.exit(1)
|
|
|
104 |
pp.pprint(client.getTransaction(eval(args[0]),))
|
|
|
105 |
|
|
|
106 |
elif cmd == 'getAllTransactions':
|
| 358 |
ashish |
107 |
if len(args) != 4:
|
|
|
108 |
print 'getAllTransactions requires 4 args'
|
| 94 |
ashish |
109 |
sys.exit(1)
|
| 358 |
ashish |
110 |
pp.pprint(client.getAllTransactions(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
|
| 94 |
ashish |
111 |
|
|
|
112 |
elif cmd == 'getTransactionsForShipmentStatus':
|
|
|
113 |
if len(args) != 3:
|
|
|
114 |
print 'getTransactionsForShipmentStatus requires 3 args'
|
|
|
115 |
sys.exit(1)
|
|
|
116 |
pp.pprint(client.getTransactionsForShipmentStatus(eval(args[0]),eval(args[1]),eval(args[2]),))
|
|
|
117 |
|
|
|
118 |
elif cmd == 'getTransactionsForCustomer':
|
|
|
119 |
if len(args) != 4:
|
|
|
120 |
print 'getTransactionsForCustomer requires 4 args'
|
|
|
121 |
sys.exit(1)
|
|
|
122 |
pp.pprint(client.getTransactionsForCustomer(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
|
|
|
123 |
|
|
|
124 |
elif cmd == 'getTransactionsForCustomerAndShipmentStatus':
|
|
|
125 |
if len(args) != 4:
|
|
|
126 |
print 'getTransactionsForCustomerAndShipmentStatus requires 4 args'
|
|
|
127 |
sys.exit(1)
|
|
|
128 |
pp.pprint(client.getTransactionsForCustomerAndShipmentStatus(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
|
|
|
129 |
|
| 132 |
ashish |
130 |
elif cmd == 'getTransactionsForShoppingCartId':
|
|
|
131 |
if len(args) != 1:
|
|
|
132 |
print 'getTransactionsForShoppingCartId requires 1 args'
|
|
|
133 |
sys.exit(1)
|
|
|
134 |
pp.pprint(client.getTransactionsForShoppingCartId(eval(args[0]),))
|
|
|
135 |
|
| 94 |
ashish |
136 |
elif cmd == 'getTransactionStatus':
|
|
|
137 |
if len(args) != 1:
|
|
|
138 |
print 'getTransactionStatus requires 1 args'
|
|
|
139 |
sys.exit(1)
|
|
|
140 |
pp.pprint(client.getTransactionStatus(eval(args[0]),))
|
|
|
141 |
|
|
|
142 |
elif cmd == 'changeTransactionStatus':
|
|
|
143 |
if len(args) != 3:
|
|
|
144 |
print 'changeTransactionStatus requires 3 args'
|
|
|
145 |
sys.exit(1)
|
|
|
146 |
pp.pprint(client.changeTransactionStatus(eval(args[0]),eval(args[1]),args[2],))
|
|
|
147 |
|
|
|
148 |
elif cmd == 'getOrderInfo':
|
|
|
149 |
if len(args) != 1:
|
|
|
150 |
print 'getOrderInfo requires 1 args'
|
|
|
151 |
sys.exit(1)
|
|
|
152 |
pp.pprint(client.getOrderInfo(eval(args[0]),))
|
|
|
153 |
|
|
|
154 |
elif cmd == 'getShippingInfo':
|
|
|
155 |
if len(args) != 1:
|
|
|
156 |
print 'getShippingInfo requires 1 args'
|
|
|
157 |
sys.exit(1)
|
|
|
158 |
pp.pprint(client.getShippingInfo(eval(args[0]),))
|
|
|
159 |
|
|
|
160 |
elif cmd == 'getBillingInfo':
|
|
|
161 |
if len(args) != 1:
|
|
|
162 |
print 'getBillingInfo requires 1 args'
|
|
|
163 |
sys.exit(1)
|
|
|
164 |
pp.pprint(client.getBillingInfo(eval(args[0]),))
|
|
|
165 |
|
|
|
166 |
elif cmd == 'addBilling':
|
|
|
167 |
if len(args) != 2:
|
|
|
168 |
print 'addBilling requires 2 args'
|
|
|
169 |
sys.exit(1)
|
|
|
170 |
pp.pprint(client.addBilling(eval(args[0]),eval(args[1]),))
|
|
|
171 |
|
|
|
172 |
elif cmd == 'setShippingTracker':
|
|
|
173 |
if len(args) != 5:
|
|
|
174 |
print 'setShippingTracker requires 5 args'
|
|
|
175 |
sys.exit(1)
|
|
|
176 |
pp.pprint(client.setShippingTracker(eval(args[0]),eval(args[1]),args[2],args[3],args[4],))
|
|
|
177 |
|
|
|
178 |
elif cmd == 'setShippingDate':
|
|
|
179 |
if len(args) != 3:
|
|
|
180 |
print 'setShippingDate requires 3 args'
|
|
|
181 |
sys.exit(1)
|
|
|
182 |
pp.pprint(client.setShippingDate(eval(args[0]),eval(args[1]),eval(args[2]),))
|
|
|
183 |
|
|
|
184 |
elif cmd == 'setDeliveryDate':
|
|
|
185 |
if len(args) != 3:
|
|
|
186 |
print 'setDeliveryDate requires 3 args'
|
|
|
187 |
sys.exit(1)
|
|
|
188 |
pp.pprint(client.setDeliveryDate(eval(args[0]),eval(args[1]),eval(args[2]),))
|
|
|
189 |
|
|
|
190 |
elif cmd == 'changeShippingStatus':
|
|
|
191 |
if len(args) != 4:
|
|
|
192 |
print 'changeShippingStatus requires 4 args'
|
|
|
193 |
sys.exit(1)
|
|
|
194 |
pp.pprint(client.changeShippingStatus(eval(args[0]),eval(args[1]),eval(args[2]),args[3],))
|
|
|
195 |
|
|
|
196 |
elif cmd == 'addTrail':
|
|
|
197 |
if len(args) != 2:
|
|
|
198 |
print 'addTrail requires 2 args'
|
|
|
199 |
sys.exit(1)
|
|
|
200 |
pp.pprint(client.addTrail(eval(args[0]),args[1],))
|
|
|
201 |
|
| 304 |
ashish |
202 |
elif cmd == 'getAlerts':
|
|
|
203 |
if len(args) != 2:
|
|
|
204 |
print 'getAlerts requires 2 args'
|
|
|
205 |
sys.exit(1)
|
|
|
206 |
pp.pprint(client.getAlerts(eval(args[0]),eval(args[1]),))
|
|
|
207 |
|
|
|
208 |
elif cmd == 'setAlert':
|
|
|
209 |
if len(args) != 4:
|
|
|
210 |
print 'setAlert requires 4 args'
|
|
|
211 |
sys.exit(1)
|
|
|
212 |
pp.pprint(client.setAlert(eval(args[0]),eval(args[1]),eval(args[2]),args[3],))
|
|
|
213 |
|
|
|
214 |
elif cmd == 'getExtraInfo':
|
|
|
215 |
if len(args) != 1:
|
|
|
216 |
print 'getExtraInfo requires 1 args'
|
|
|
217 |
sys.exit(1)
|
|
|
218 |
pp.pprint(client.getExtraInfo(eval(args[0]),))
|
|
|
219 |
|
|
|
220 |
elif cmd == 'setExtraInfo':
|
|
|
221 |
if len(args) != 5:
|
|
|
222 |
print 'setExtraInfo requires 5 args'
|
|
|
223 |
sys.exit(1)
|
|
|
224 |
pp.pprint(client.setExtraInfo(eval(args[0]),eval(args[1]),args[2],args[3],args[4],))
|
|
|
225 |
|
| 94 |
ashish |
226 |
transport.close()
|