Subversion Repositories SmartDukaan

Rev

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

Rev 647 Rev 669
Line 14... Line 14...
14
except:
14
except:
15
  fastbinary = None
15
  fastbinary = None
16
 
16
 
17
 
17
 
18
class Iface:
18
class Iface:
-
 
19
  def getProvider(self, providerId):
-
 
20
    """
-
 
21
    Returns a provider for a given provider ID. Throws an exception if none found.
-
 
22
    
-
 
23
    Parameters:
-
 
24
     - providerId
-
 
25
    """
-
 
26
    pass
-
 
27
 
19
  def getLogisticsEstimation(self, itemId, destination_pin):
28
  def getLogisticsEstimation(self, itemId, destination_pin):
20
    """
29
    """
21
    Returns a LogisticsInfo structure w/o an airway bill number. Use this method during the estimation phase.
30
    Returns a LogisticsInfo structure w/o an airway bill number. Use this method during the estimation phase.
22
    Raises an exception if this pincode is not allocated to any warehouse zone or provider. Also, if the pincode
31
    Raises an exception if this pincode is not allocated to any warehouse zone or provider. Also, if the pincode
23
    is allocated to a warehouse zone but there are no actual warehouses in that zone, an exception is raised.
32
    is allocated to a warehouse zone but there are no actual warehouses in that zone, an exception is raised.
Line 63... Line 72...
63
    self._iprot = self._oprot = iprot
72
    self._iprot = self._oprot = iprot
64
    if oprot != None:
73
    if oprot != None:
65
      self._oprot = oprot
74
      self._oprot = oprot
66
    self._seqid = 0
75
    self._seqid = 0
67
 
76
 
-
 
77
  def getProvider(self, providerId):
-
 
78
    """
-
 
79
    Returns a provider for a given provider ID. Throws an exception if none found.
-
 
80
    
-
 
81
    Parameters:
-
 
82
     - providerId
-
 
83
    """
-
 
84
    self.send_getProvider(providerId)
-
 
85
    return self.recv_getProvider()
-
 
86
 
-
 
87
  def send_getProvider(self, providerId):
-
 
88
    self._oprot.writeMessageBegin('getProvider', TMessageType.CALL, self._seqid)
-
 
89
    args = getProvider_args()
-
 
90
    args.providerId = providerId
-
 
91
    args.write(self._oprot)
-
 
92
    self._oprot.writeMessageEnd()
-
 
93
    self._oprot.trans.flush()
-
 
94
 
-
 
95
  def recv_getProvider(self, ):
-
 
96
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
-
 
97
    if mtype == TMessageType.EXCEPTION:
-
 
98
      x = TApplicationException()
-
 
99
      x.read(self._iprot)
-
 
100
      self._iprot.readMessageEnd()
-
 
101
      raise x
-
 
102
    result = getProvider_result()
-
 
103
    result.read(self._iprot)
-
 
104
    self._iprot.readMessageEnd()
-
 
105
    if result.success != None:
-
 
106
      return result.success
-
 
107
    if result.lse != None:
-
 
108
      raise result.lse
-
 
109
    raise TApplicationException(TApplicationException.MISSING_RESULT, "getProvider failed: unknown result");
-
 
110
 
68
  def getLogisticsEstimation(self, itemId, destination_pin):
111
  def getLogisticsEstimation(self, itemId, destination_pin):
69
    """
112
    """
70
    Returns a LogisticsInfo structure w/o an airway bill number. Use this method during the estimation phase.
113
    Returns a LogisticsInfo structure w/o an airway bill number. Use this method during the estimation phase.
71
    Raises an exception if this pincode is not allocated to any warehouse zone or provider. Also, if the pincode
114
    Raises an exception if this pincode is not allocated to any warehouse zone or provider. Also, if the pincode
72
    is allocated to a warehouse zone but there are no actual warehouses in that zone, an exception is raised.
115
    is allocated to a warehouse zone but there are no actual warehouses in that zone, an exception is raised.
Line 212... Line 255...
212
 
255
 
213
class Processor(Iface, TProcessor):
256
class Processor(Iface, TProcessor):
214
  def __init__(self, handler):
257
  def __init__(self, handler):
215
    self._handler = handler
258
    self._handler = handler
216
    self._processMap = {}
259
    self._processMap = {}
-
 
260
    self._processMap["getProvider"] = Processor.process_getProvider
217
    self._processMap["getLogisticsEstimation"] = Processor.process_getLogisticsEstimation
261
    self._processMap["getLogisticsEstimation"] = Processor.process_getLogisticsEstimation
218
    self._processMap["getLogisticsInfo"] = Processor.process_getLogisticsInfo
262
    self._processMap["getLogisticsInfo"] = Processor.process_getLogisticsInfo
219
    self._processMap["getEmptyAWB"] = Processor.process_getEmptyAWB
263
    self._processMap["getEmptyAWB"] = Processor.process_getEmptyAWB
220
    self._processMap["getShipmentInfo"] = Processor.process_getShipmentInfo
264
    self._processMap["getShipmentInfo"] = Processor.process_getShipmentInfo
221
 
265
 
Line 232... Line 276...
232
      return
276
      return
233
    else:
277
    else:
234
      self._processMap[name](self, seqid, iprot, oprot)
278
      self._processMap[name](self, seqid, iprot, oprot)
235
    return True
279
    return True
236
 
280
 
-
 
281
  def process_getProvider(self, seqid, iprot, oprot):
-
 
282
    args = getProvider_args()
-
 
283
    args.read(iprot)
-
 
284
    iprot.readMessageEnd()
-
 
285
    result = getProvider_result()
-
 
286
    try:
-
 
287
      result.success = self._handler.getProvider(args.providerId)
-
 
288
    except LogisticsServiceException, lse:
-
 
289
      result.lse = lse
-
 
290
    oprot.writeMessageBegin("getProvider", TMessageType.REPLY, seqid)
-
 
291
    result.write(oprot)
-
 
292
    oprot.writeMessageEnd()
-
 
293
    oprot.trans.flush()
-
 
294
 
237
  def process_getLogisticsEstimation(self, seqid, iprot, oprot):
295
  def process_getLogisticsEstimation(self, seqid, iprot, oprot):
238
    args = getLogisticsEstimation_args()
296
    args = getLogisticsEstimation_args()
239
    args.read(iprot)
297
    args.read(iprot)
240
    iprot.readMessageEnd()
298
    iprot.readMessageEnd()
241
    result = getLogisticsEstimation_result()
299
    result = getLogisticsEstimation_result()
Line 291... Line 349...
291
    oprot.trans.flush()
349
    oprot.trans.flush()
292
 
350
 
293
 
351
 
294
# HELPER FUNCTIONS AND STRUCTURES
352
# HELPER FUNCTIONS AND STRUCTURES
295
 
353
 
-
 
354
class getProvider_args:
-
 
355
  """
-
 
356
  Attributes:
-
 
357
   - providerId
-
 
358
  """
-
 
359
 
-
 
360
  thrift_spec = (
-
 
361
    None, # 0
-
 
362
    (1, TType.I64, 'providerId', None, None, ), # 1
-
 
363
  )
-
 
364
 
-
 
365
  def __init__(self, providerId=None,):
-
 
366
    self.providerId = providerId
-
 
367
 
-
 
368
  def read(self, iprot):
-
 
369
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
-
 
370
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
-
 
371
      return
-
 
372
    iprot.readStructBegin()
-
 
373
    while True:
-
 
374
      (fname, ftype, fid) = iprot.readFieldBegin()
-
 
375
      if ftype == TType.STOP:
-
 
376
        break
-
 
377
      if fid == 1:
-
 
378
        if ftype == TType.I64:
-
 
379
          self.providerId = iprot.readI64();
-
 
380
        else:
-
 
381
          iprot.skip(ftype)
-
 
382
      else:
-
 
383
        iprot.skip(ftype)
-
 
384
      iprot.readFieldEnd()
-
 
385
    iprot.readStructEnd()
-
 
386
 
-
 
387
  def write(self, oprot):
-
 
388
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
-
 
389
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
-
 
390
      return
-
 
391
    oprot.writeStructBegin('getProvider_args')
-
 
392
    if self.providerId != None:
-
 
393
      oprot.writeFieldBegin('providerId', TType.I64, 1)
-
 
394
      oprot.writeI64(self.providerId)
-
 
395
      oprot.writeFieldEnd()
-
 
396
    oprot.writeFieldStop()
-
 
397
    oprot.writeStructEnd()
-
 
398
 
-
 
399
  def __repr__(self):
-
 
400
    L = ['%s=%r' % (key, value)
-
 
401
      for key, value in self.__dict__.iteritems()]
-
 
402
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
-
 
403
 
-
 
404
  def __eq__(self, other):
-
 
405
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
-
 
406
 
-
 
407
  def __ne__(self, other):
-
 
408
    return not (self == other)
-
 
409
 
-
 
410
class getProvider_result:
-
 
411
  """
-
 
412
  Attributes:
-
 
413
   - success
-
 
414
   - lse
-
 
415
  """
-
 
416
 
-
 
417
  thrift_spec = (
-
 
418
    (0, TType.STRUCT, 'success', (Provider, Provider.thrift_spec), None, ), # 0
-
 
419
    (1, TType.STRUCT, 'lse', (LogisticsServiceException, LogisticsServiceException.thrift_spec), None, ), # 1
-
 
420
  )
-
 
421
 
-
 
422
  def __init__(self, success=None, lse=None,):
-
 
423
    self.success = success
-
 
424
    self.lse = lse
-
 
425
 
-
 
426
  def read(self, iprot):
-
 
427
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
-
 
428
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
-
 
429
      return
-
 
430
    iprot.readStructBegin()
-
 
431
    while True:
-
 
432
      (fname, ftype, fid) = iprot.readFieldBegin()
-
 
433
      if ftype == TType.STOP:
-
 
434
        break
-
 
435
      if fid == 0:
-
 
436
        if ftype == TType.STRUCT:
-
 
437
          self.success = Provider()
-
 
438
          self.success.read(iprot)
-
 
439
        else:
-
 
440
          iprot.skip(ftype)
-
 
441
      elif fid == 1:
-
 
442
        if ftype == TType.STRUCT:
-
 
443
          self.lse = LogisticsServiceException()
-
 
444
          self.lse.read(iprot)
-
 
445
        else:
-
 
446
          iprot.skip(ftype)
-
 
447
      else:
-
 
448
        iprot.skip(ftype)
-
 
449
      iprot.readFieldEnd()
-
 
450
    iprot.readStructEnd()
-
 
451
 
-
 
452
  def write(self, oprot):
-
 
453
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
-
 
454
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
-
 
455
      return
-
 
456
    oprot.writeStructBegin('getProvider_result')
-
 
457
    if self.success != None:
-
 
458
      oprot.writeFieldBegin('success', TType.STRUCT, 0)
-
 
459
      self.success.write(oprot)
-
 
460
      oprot.writeFieldEnd()
-
 
461
    if self.lse != None:
-
 
462
      oprot.writeFieldBegin('lse', TType.STRUCT, 1)
-
 
463
      self.lse.write(oprot)
-
 
464
      oprot.writeFieldEnd()
-
 
465
    oprot.writeFieldStop()
-
 
466
    oprot.writeStructEnd()
-
 
467
 
-
 
468
  def __repr__(self):
-
 
469
    L = ['%s=%r' % (key, value)
-
 
470
      for key, value in self.__dict__.iteritems()]
-
 
471
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
-
 
472
 
-
 
473
  def __eq__(self, other):
-
 
474
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
-
 
475
 
-
 
476
  def __ne__(self, other):
-
 
477
    return not (self == other)
-
 
478
 
296
class getLogisticsEstimation_args:
479
class getLogisticsEstimation_args:
297
  """
480
  """
298
  Attributes:
481
  Attributes:
299
   - itemId
482
   - itemId
300
   - destination_pin
483
   - destination_pin