Subversion Repositories SmartDukaan

Rev

Rev 2981 | Rev 3385 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#
# Autogenerated by Thrift
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#

from thrift.Thrift import *
import shop2020.thriftpy.generic.GenericService
from ttypes import *
from thrift.Thrift import TProcessor
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
try:
  from thrift.protocol import fastbinary
except:
  fastbinary = None


class Iface(shop2020.thriftpy.generic.GenericService.Iface):
  """
  Promotion Service
  """
  def closeSession(self, ):
    """
    For closing the open session in sqlalchemy
    """
    pass

  def createPromotion(self, name, ruleExecutionSrc, startOn, endOn):
    """
    Parameters:
     - name
     - ruleExecutionSrc
     - startOn
     - endOn
    """
    pass

  def getAllPromotions(self, ):
    pass

  def getPromotionById(self, promotionId):
    """
    Parameters:
     - promotionId
    """
    pass

  def generateCouponsForPromotion(self, promotionId, couponCode):
    """
    Parameters:
     - promotionId
     - couponCode
    """
    pass

  def applyCoupon(self, couponCode, cartId):
    """
    Parameters:
     - couponCode
     - cartId
    """
    pass

  def trackCouponUsage(self, couponCode, transactionId, userId):
    """
    Parameters:
     - couponCode
     - transactionId
     - userId
    """
    pass

  def getCouponUsageCountByUser(self, couponCode, userId):
    """
    Parameters:
     - couponCode
     - userId
    """
    pass


class Client(shop2020.thriftpy.generic.GenericService.Client, Iface):
  """
  Promotion Service
  """
  def __init__(self, iprot, oprot=None):
    shop2020.thriftpy.generic.GenericService.Client.__init__(self, iprot, oprot)

  def closeSession(self, ):
    """
    For closing the open session in sqlalchemy
    """
    self.send_closeSession()
    self.recv_closeSession()

  def send_closeSession(self, ):
    self._oprot.writeMessageBegin('closeSession', TMessageType.CALL, self._seqid)
    args = closeSession_args()
    args.write(self._oprot)
    self._oprot.writeMessageEnd()
    self._oprot.trans.flush()

  def recv_closeSession(self, ):
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
    if mtype == TMessageType.EXCEPTION:
      x = TApplicationException()
      x.read(self._iprot)
      self._iprot.readMessageEnd()
      raise x
    result = closeSession_result()
    result.read(self._iprot)
    self._iprot.readMessageEnd()
    return

  def createPromotion(self, name, ruleExecutionSrc, startOn, endOn):
    """
    Parameters:
     - name
     - ruleExecutionSrc
     - startOn
     - endOn
    """
    self.send_createPromotion(name, ruleExecutionSrc, startOn, endOn)
    self.recv_createPromotion()

  def send_createPromotion(self, name, ruleExecutionSrc, startOn, endOn):
    self._oprot.writeMessageBegin('createPromotion', TMessageType.CALL, self._seqid)
    args = createPromotion_args()
    args.name = name
    args.ruleExecutionSrc = ruleExecutionSrc
    args.startOn = startOn
    args.endOn = endOn
    args.write(self._oprot)
    self._oprot.writeMessageEnd()
    self._oprot.trans.flush()

  def recv_createPromotion(self, ):
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
    if mtype == TMessageType.EXCEPTION:
      x = TApplicationException()
      x.read(self._iprot)
      self._iprot.readMessageEnd()
      raise x
    result = createPromotion_result()
    result.read(self._iprot)
    self._iprot.readMessageEnd()
    if result.pex != None:
      raise result.pex
    return

  def getAllPromotions(self, ):
    self.send_getAllPromotions()
    return self.recv_getAllPromotions()

  def send_getAllPromotions(self, ):
    self._oprot.writeMessageBegin('getAllPromotions', TMessageType.CALL, self._seqid)
    args = getAllPromotions_args()
    args.write(self._oprot)
    self._oprot.writeMessageEnd()
    self._oprot.trans.flush()

  def recv_getAllPromotions(self, ):
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
    if mtype == TMessageType.EXCEPTION:
      x = TApplicationException()
      x.read(self._iprot)
      self._iprot.readMessageEnd()
      raise x
    result = getAllPromotions_result()
    result.read(self._iprot)
    self._iprot.readMessageEnd()
    if result.success != None:
      return result.success
    if result.pex != None:
      raise result.pex
    raise TApplicationException(TApplicationException.MISSING_RESULT, "getAllPromotions failed: unknown result");

  def getPromotionById(self, promotionId):
    """
    Parameters:
     - promotionId
    """
    self.send_getPromotionById(promotionId)
    return self.recv_getPromotionById()

  def send_getPromotionById(self, promotionId):
    self._oprot.writeMessageBegin('getPromotionById', TMessageType.CALL, self._seqid)
    args = getPromotionById_args()
    args.promotionId = promotionId
    args.write(self._oprot)
    self._oprot.writeMessageEnd()
    self._oprot.trans.flush()

  def recv_getPromotionById(self, ):
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
    if mtype == TMessageType.EXCEPTION:
      x = TApplicationException()
      x.read(self._iprot)
      self._iprot.readMessageEnd()
      raise x
    result = getPromotionById_result()
    result.read(self._iprot)
    self._iprot.readMessageEnd()
    if result.success != None:
      return result.success
    if result.pex != None:
      raise result.pex
    raise TApplicationException(TApplicationException.MISSING_RESULT, "getPromotionById failed: unknown result");

  def generateCouponsForPromotion(self, promotionId, couponCode):
    """
    Parameters:
     - promotionId
     - couponCode
    """
    self.send_generateCouponsForPromotion(promotionId, couponCode)
    self.recv_generateCouponsForPromotion()

  def send_generateCouponsForPromotion(self, promotionId, couponCode):
    self._oprot.writeMessageBegin('generateCouponsForPromotion', TMessageType.CALL, self._seqid)
    args = generateCouponsForPromotion_args()
    args.promotionId = promotionId
    args.couponCode = couponCode
    args.write(self._oprot)
    self._oprot.writeMessageEnd()
    self._oprot.trans.flush()

  def recv_generateCouponsForPromotion(self, ):
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
    if mtype == TMessageType.EXCEPTION:
      x = TApplicationException()
      x.read(self._iprot)
      self._iprot.readMessageEnd()
      raise x
    result = generateCouponsForPromotion_result()
    result.read(self._iprot)
    self._iprot.readMessageEnd()
    if result.pex != None:
      raise result.pex
    return

  def applyCoupon(self, couponCode, cartId):
    """
    Parameters:
     - couponCode
     - cartId
    """
    self.send_applyCoupon(couponCode, cartId)
    return self.recv_applyCoupon()

  def send_applyCoupon(self, couponCode, cartId):
    self._oprot.writeMessageBegin('applyCoupon', TMessageType.CALL, self._seqid)
    args = applyCoupon_args()
    args.couponCode = couponCode
    args.cartId = cartId
    args.write(self._oprot)
    self._oprot.writeMessageEnd()
    self._oprot.trans.flush()

  def recv_applyCoupon(self, ):
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
    if mtype == TMessageType.EXCEPTION:
      x = TApplicationException()
      x.read(self._iprot)
      self._iprot.readMessageEnd()
      raise x
    result = applyCoupon_result()
    result.read(self._iprot)
    self._iprot.readMessageEnd()
    if result.success != None:
      return result.success
    if result.pex != None:
      raise result.pex
    raise TApplicationException(TApplicationException.MISSING_RESULT, "applyCoupon failed: unknown result");

  def trackCouponUsage(self, couponCode, transactionId, userId):
    """
    Parameters:
     - couponCode
     - transactionId
     - userId
    """
    self.send_trackCouponUsage(couponCode, transactionId, userId)
    self.recv_trackCouponUsage()

  def send_trackCouponUsage(self, couponCode, transactionId, userId):
    self._oprot.writeMessageBegin('trackCouponUsage', TMessageType.CALL, self._seqid)
    args = trackCouponUsage_args()
    args.couponCode = couponCode
    args.transactionId = transactionId
    args.userId = userId
    args.write(self._oprot)
    self._oprot.writeMessageEnd()
    self._oprot.trans.flush()

  def recv_trackCouponUsage(self, ):
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
    if mtype == TMessageType.EXCEPTION:
      x = TApplicationException()
      x.read(self._iprot)
      self._iprot.readMessageEnd()
      raise x
    result = trackCouponUsage_result()
    result.read(self._iprot)
    self._iprot.readMessageEnd()
    if result.pex != None:
      raise result.pex
    return

  def getCouponUsageCountByUser(self, couponCode, userId):
    """
    Parameters:
     - couponCode
     - userId
    """
    self.send_getCouponUsageCountByUser(couponCode, userId)
    return self.recv_getCouponUsageCountByUser()

  def send_getCouponUsageCountByUser(self, couponCode, userId):
    self._oprot.writeMessageBegin('getCouponUsageCountByUser', TMessageType.CALL, self._seqid)
    args = getCouponUsageCountByUser_args()
    args.couponCode = couponCode
    args.userId = userId
    args.write(self._oprot)
    self._oprot.writeMessageEnd()
    self._oprot.trans.flush()

  def recv_getCouponUsageCountByUser(self, ):
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
    if mtype == TMessageType.EXCEPTION:
      x = TApplicationException()
      x.read(self._iprot)
      self._iprot.readMessageEnd()
      raise x
    result = getCouponUsageCountByUser_result()
    result.read(self._iprot)
    self._iprot.readMessageEnd()
    if result.success != None:
      return result.success
    if result.pex != None:
      raise result.pex
    raise TApplicationException(TApplicationException.MISSING_RESULT, "getCouponUsageCountByUser failed: unknown result");


class Processor(shop2020.thriftpy.generic.GenericService.Processor, Iface, TProcessor):
  def __init__(self, handler):
    shop2020.thriftpy.generic.GenericService.Processor.__init__(self, handler)
    self._processMap["closeSession"] = Processor.process_closeSession
    self._processMap["createPromotion"] = Processor.process_createPromotion
    self._processMap["getAllPromotions"] = Processor.process_getAllPromotions
    self._processMap["getPromotionById"] = Processor.process_getPromotionById
    self._processMap["generateCouponsForPromotion"] = Processor.process_generateCouponsForPromotion
    self._processMap["applyCoupon"] = Processor.process_applyCoupon
    self._processMap["trackCouponUsage"] = Processor.process_trackCouponUsage
    self._processMap["getCouponUsageCountByUser"] = Processor.process_getCouponUsageCountByUser

  def process(self, iprot, oprot):
    (name, type, seqid) = iprot.readMessageBegin()
    if name not in self._processMap:
      iprot.skip(TType.STRUCT)
      iprot.readMessageEnd()
      x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name))
      oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid)
      x.write(oprot)
      oprot.writeMessageEnd()
      oprot.trans.flush()
      return
    else:
      self._processMap[name](self, seqid, iprot, oprot)
    return True

  def process_closeSession(self, seqid, iprot, oprot):
    args = closeSession_args()
    args.read(iprot)
    iprot.readMessageEnd()
    result = closeSession_result()
    self._handler.closeSession()
    oprot.writeMessageBegin("closeSession", TMessageType.REPLY, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()

  def process_createPromotion(self, seqid, iprot, oprot):
    args = createPromotion_args()
    args.read(iprot)
    iprot.readMessageEnd()
    result = createPromotion_result()
    try:
      self._handler.createPromotion(args.name, args.ruleExecutionSrc, args.startOn, args.endOn)
    except PromotionException, pex:
      result.pex = pex
    oprot.writeMessageBegin("createPromotion", TMessageType.REPLY, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()

  def process_getAllPromotions(self, seqid, iprot, oprot):
    args = getAllPromotions_args()
    args.read(iprot)
    iprot.readMessageEnd()
    result = getAllPromotions_result()
    try:
      result.success = self._handler.getAllPromotions()
    except PromotionException, pex:
      result.pex = pex
    oprot.writeMessageBegin("getAllPromotions", TMessageType.REPLY, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()

  def process_getPromotionById(self, seqid, iprot, oprot):
    args = getPromotionById_args()
    args.read(iprot)
    iprot.readMessageEnd()
    result = getPromotionById_result()
    try:
      result.success = self._handler.getPromotionById(args.promotionId)
    except PromotionException, pex:
      result.pex = pex
    oprot.writeMessageBegin("getPromotionById", TMessageType.REPLY, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()

  def process_generateCouponsForPromotion(self, seqid, iprot, oprot):
    args = generateCouponsForPromotion_args()
    args.read(iprot)
    iprot.readMessageEnd()
    result = generateCouponsForPromotion_result()
    try:
      self._handler.generateCouponsForPromotion(args.promotionId, args.couponCode)
    except PromotionException, pex:
      result.pex = pex
    oprot.writeMessageBegin("generateCouponsForPromotion", TMessageType.REPLY, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()

  def process_applyCoupon(self, seqid, iprot, oprot):
    args = applyCoupon_args()
    args.read(iprot)
    iprot.readMessageEnd()
    result = applyCoupon_result()
    try:
      result.success = self._handler.applyCoupon(args.couponCode, args.cartId)
    except PromotionException, pex:
      result.pex = pex
    oprot.writeMessageBegin("applyCoupon", TMessageType.REPLY, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()

  def process_trackCouponUsage(self, seqid, iprot, oprot):
    args = trackCouponUsage_args()
    args.read(iprot)
    iprot.readMessageEnd()
    result = trackCouponUsage_result()
    try:
      self._handler.trackCouponUsage(args.couponCode, args.transactionId, args.userId)
    except PromotionException, pex:
      result.pex = pex
    oprot.writeMessageBegin("trackCouponUsage", TMessageType.REPLY, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()

  def process_getCouponUsageCountByUser(self, seqid, iprot, oprot):
    args = getCouponUsageCountByUser_args()
    args.read(iprot)
    iprot.readMessageEnd()
    result = getCouponUsageCountByUser_result()
    try:
      result.success = self._handler.getCouponUsageCountByUser(args.couponCode, args.userId)
    except PromotionException, pex:
      result.pex = pex
    oprot.writeMessageBegin("getCouponUsageCountByUser", TMessageType.REPLY, seqid)
    result.write(oprot)
    oprot.writeMessageEnd()
    oprot.trans.flush()


# HELPER FUNCTIONS AND STRUCTURES

class closeSession_args:

  thrift_spec = (
  )

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('closeSession_args')
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class closeSession_result:

  thrift_spec = (
  )

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('closeSession_result')
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class createPromotion_args:
  """
  Attributes:
   - name
   - ruleExecutionSrc
   - startOn
   - endOn
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRING, 'name', None, None, ), # 1
    (2, TType.STRING, 'ruleExecutionSrc', None, None, ), # 2
    (3, TType.I64, 'startOn', None, None, ), # 3
    (4, TType.I64, 'endOn', None, None, ), # 4
  )

  def __init__(self, name=None, ruleExecutionSrc=None, startOn=None, endOn=None,):
    self.name = name
    self.ruleExecutionSrc = ruleExecutionSrc
    self.startOn = startOn
    self.endOn = endOn

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRING:
          self.name = iprot.readString();
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.STRING:
          self.ruleExecutionSrc = iprot.readString();
        else:
          iprot.skip(ftype)
      elif fid == 3:
        if ftype == TType.I64:
          self.startOn = iprot.readI64();
        else:
          iprot.skip(ftype)
      elif fid == 4:
        if ftype == TType.I64:
          self.endOn = iprot.readI64();
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('createPromotion_args')
    if self.name != None:
      oprot.writeFieldBegin('name', TType.STRING, 1)
      oprot.writeString(self.name)
      oprot.writeFieldEnd()
    if self.ruleExecutionSrc != None:
      oprot.writeFieldBegin('ruleExecutionSrc', TType.STRING, 2)
      oprot.writeString(self.ruleExecutionSrc)
      oprot.writeFieldEnd()
    if self.startOn != None:
      oprot.writeFieldBegin('startOn', TType.I64, 3)
      oprot.writeI64(self.startOn)
      oprot.writeFieldEnd()
    if self.endOn != None:
      oprot.writeFieldBegin('endOn', TType.I64, 4)
      oprot.writeI64(self.endOn)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class createPromotion_result:
  """
  Attributes:
   - pex
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRUCT, 'pex', (PromotionException, PromotionException.thrift_spec), None, ), # 1
  )

  def __init__(self, pex=None,):
    self.pex = pex

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRUCT:
          self.pex = PromotionException()
          self.pex.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('createPromotion_result')
    if self.pex != None:
      oprot.writeFieldBegin('pex', TType.STRUCT, 1)
      self.pex.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class getAllPromotions_args:

  thrift_spec = (
  )

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('getAllPromotions_args')
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class getAllPromotions_result:
  """
  Attributes:
   - success
   - pex
  """

  thrift_spec = (
    (0, TType.LIST, 'success', (TType.STRUCT,(Promotion, Promotion.thrift_spec)), None, ), # 0
    (1, TType.STRUCT, 'pex', (PromotionException, PromotionException.thrift_spec), None, ), # 1
  )

  def __init__(self, success=None, pex=None,):
    self.success = success
    self.pex = pex

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 0:
        if ftype == TType.LIST:
          self.success = []
          (_etype24, _size21) = iprot.readListBegin()
          for _i25 in xrange(_size21):
            _elem26 = Promotion()
            _elem26.read(iprot)
            self.success.append(_elem26)
          iprot.readListEnd()
        else:
          iprot.skip(ftype)
      elif fid == 1:
        if ftype == TType.STRUCT:
          self.pex = PromotionException()
          self.pex.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('getAllPromotions_result')
    if self.success != None:
      oprot.writeFieldBegin('success', TType.LIST, 0)
      oprot.writeListBegin(TType.STRUCT, len(self.success))
      for iter27 in self.success:
        iter27.write(oprot)
      oprot.writeListEnd()
      oprot.writeFieldEnd()
    if self.pex != None:
      oprot.writeFieldBegin('pex', TType.STRUCT, 1)
      self.pex.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class getPromotionById_args:
  """
  Attributes:
   - promotionId
  """

  thrift_spec = (
    None, # 0
    (1, TType.I64, 'promotionId', None, None, ), # 1
  )

  def __init__(self, promotionId=None,):
    self.promotionId = promotionId

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.I64:
          self.promotionId = iprot.readI64();
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('getPromotionById_args')
    if self.promotionId != None:
      oprot.writeFieldBegin('promotionId', TType.I64, 1)
      oprot.writeI64(self.promotionId)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class getPromotionById_result:
  """
  Attributes:
   - success
   - pex
  """

  thrift_spec = (
    (0, TType.STRUCT, 'success', (Promotion, Promotion.thrift_spec), None, ), # 0
    (1, TType.STRUCT, 'pex', (PromotionException, PromotionException.thrift_spec), None, ), # 1
  )

  def __init__(self, success=None, pex=None,):
    self.success = success
    self.pex = pex

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 0:
        if ftype == TType.STRUCT:
          self.success = Promotion()
          self.success.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 1:
        if ftype == TType.STRUCT:
          self.pex = PromotionException()
          self.pex.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('getPromotionById_result')
    if self.success != None:
      oprot.writeFieldBegin('success', TType.STRUCT, 0)
      self.success.write(oprot)
      oprot.writeFieldEnd()
    if self.pex != None:
      oprot.writeFieldBegin('pex', TType.STRUCT, 1)
      self.pex.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class generateCouponsForPromotion_args:
  """
  Attributes:
   - promotionId
   - couponCode
  """

  thrift_spec = (
    None, # 0
    (1, TType.I64, 'promotionId', None, None, ), # 1
    (2, TType.STRING, 'couponCode', None, None, ), # 2
  )

  def __init__(self, promotionId=None, couponCode=None,):
    self.promotionId = promotionId
    self.couponCode = couponCode

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.I64:
          self.promotionId = iprot.readI64();
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.STRING:
          self.couponCode = iprot.readString();
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('generateCouponsForPromotion_args')
    if self.promotionId != None:
      oprot.writeFieldBegin('promotionId', TType.I64, 1)
      oprot.writeI64(self.promotionId)
      oprot.writeFieldEnd()
    if self.couponCode != None:
      oprot.writeFieldBegin('couponCode', TType.STRING, 2)
      oprot.writeString(self.couponCode)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class generateCouponsForPromotion_result:
  """
  Attributes:
   - pex
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRUCT, 'pex', (PromotionException, PromotionException.thrift_spec), None, ), # 1
  )

  def __init__(self, pex=None,):
    self.pex = pex

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRUCT:
          self.pex = PromotionException()
          self.pex.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('generateCouponsForPromotion_result')
    if self.pex != None:
      oprot.writeFieldBegin('pex', TType.STRUCT, 1)
      self.pex.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class applyCoupon_args:
  """
  Attributes:
   - couponCode
   - cartId
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRING, 'couponCode', None, None, ), # 1
    (2, TType.I64, 'cartId', None, None, ), # 2
  )

  def __init__(self, couponCode=None, cartId=None,):
    self.couponCode = couponCode
    self.cartId = cartId

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRING:
          self.couponCode = iprot.readString();
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.I64:
          self.cartId = iprot.readI64();
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('applyCoupon_args')
    if self.couponCode != None:
      oprot.writeFieldBegin('couponCode', TType.STRING, 1)
      oprot.writeString(self.couponCode)
      oprot.writeFieldEnd()
    if self.cartId != None:
      oprot.writeFieldBegin('cartId', TType.I64, 2)
      oprot.writeI64(self.cartId)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class applyCoupon_result:
  """
  Attributes:
   - success
   - pex
  """

  thrift_spec = (
    (0, TType.STRUCT, 'success', (Cart, Cart.thrift_spec), None, ), # 0
    (1, TType.STRUCT, 'pex', (PromotionException, PromotionException.thrift_spec), None, ), # 1
  )

  def __init__(self, success=None, pex=None,):
    self.success = success
    self.pex = pex

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 0:
        if ftype == TType.STRUCT:
          self.success = Cart()
          self.success.read(iprot)
        else:
          iprot.skip(ftype)
      elif fid == 1:
        if ftype == TType.STRUCT:
          self.pex = PromotionException()
          self.pex.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('applyCoupon_result')
    if self.success != None:
      oprot.writeFieldBegin('success', TType.STRUCT, 0)
      self.success.write(oprot)
      oprot.writeFieldEnd()
    if self.pex != None:
      oprot.writeFieldBegin('pex', TType.STRUCT, 1)
      self.pex.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class trackCouponUsage_args:
  """
  Attributes:
   - couponCode
   - transactionId
   - userId
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRING, 'couponCode', None, None, ), # 1
    (2, TType.I64, 'transactionId', None, None, ), # 2
    (3, TType.I64, 'userId', None, None, ), # 3
  )

  def __init__(self, couponCode=None, transactionId=None, userId=None,):
    self.couponCode = couponCode
    self.transactionId = transactionId
    self.userId = userId

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRING:
          self.couponCode = iprot.readString();
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.I64:
          self.transactionId = iprot.readI64();
        else:
          iprot.skip(ftype)
      elif fid == 3:
        if ftype == TType.I64:
          self.userId = iprot.readI64();
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('trackCouponUsage_args')
    if self.couponCode != None:
      oprot.writeFieldBegin('couponCode', TType.STRING, 1)
      oprot.writeString(self.couponCode)
      oprot.writeFieldEnd()
    if self.transactionId != None:
      oprot.writeFieldBegin('transactionId', TType.I64, 2)
      oprot.writeI64(self.transactionId)
      oprot.writeFieldEnd()
    if self.userId != None:
      oprot.writeFieldBegin('userId', TType.I64, 3)
      oprot.writeI64(self.userId)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class trackCouponUsage_result:
  """
  Attributes:
   - pex
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRUCT, 'pex', (PromotionException, PromotionException.thrift_spec), None, ), # 1
  )

  def __init__(self, pex=None,):
    self.pex = pex

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRUCT:
          self.pex = PromotionException()
          self.pex.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('trackCouponUsage_result')
    if self.pex != None:
      oprot.writeFieldBegin('pex', TType.STRUCT, 1)
      self.pex.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class getCouponUsageCountByUser_args:
  """
  Attributes:
   - couponCode
   - userId
  """

  thrift_spec = (
    None, # 0
    (1, TType.STRING, 'couponCode', None, None, ), # 1
    (2, TType.I64, 'userId', None, None, ), # 2
  )

  def __init__(self, couponCode=None, userId=None,):
    self.couponCode = couponCode
    self.userId = userId

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 1:
        if ftype == TType.STRING:
          self.couponCode = iprot.readString();
        else:
          iprot.skip(ftype)
      elif fid == 2:
        if ftype == TType.I64:
          self.userId = iprot.readI64();
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('getCouponUsageCountByUser_args')
    if self.couponCode != None:
      oprot.writeFieldBegin('couponCode', TType.STRING, 1)
      oprot.writeString(self.couponCode)
      oprot.writeFieldEnd()
    if self.userId != None:
      oprot.writeFieldBegin('userId', TType.I64, 2)
      oprot.writeI64(self.userId)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)

class getCouponUsageCountByUser_result:
  """
  Attributes:
   - success
   - pex
  """

  thrift_spec = (
    (0, TType.I64, 'success', None, None, ), # 0
    (1, TType.STRUCT, 'pex', (PromotionException, PromotionException.thrift_spec), None, ), # 1
  )

  def __init__(self, success=None, pex=None,):
    self.success = success
    self.pex = pex

  def read(self, iprot):
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
      return
    iprot.readStructBegin()
    while True:
      (fname, ftype, fid) = iprot.readFieldBegin()
      if ftype == TType.STOP:
        break
      if fid == 0:
        if ftype == TType.I64:
          self.success = iprot.readI64();
        else:
          iprot.skip(ftype)
      elif fid == 1:
        if ftype == TType.STRUCT:
          self.pex = PromotionException()
          self.pex.read(iprot)
        else:
          iprot.skip(ftype)
      else:
        iprot.skip(ftype)
      iprot.readFieldEnd()
    iprot.readStructEnd()

  def write(self, oprot):
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
      return
    oprot.writeStructBegin('getCouponUsageCountByUser_result')
    if self.success != None:
      oprot.writeFieldBegin('success', TType.I64, 0)
      oprot.writeI64(self.success)
      oprot.writeFieldEnd()
    if self.pex != None:
      oprot.writeFieldBegin('pex', TType.STRUCT, 1)
      self.pex.write(oprot)
      oprot.writeFieldEnd()
    oprot.writeFieldStop()
    oprot.writeStructEnd()

  def __repr__(self):
    L = ['%s=%r' % (key, value)
      for key, value in self.__dict__.iteritems()]
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

  def __eq__(self, other):
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

  def __ne__(self, other):
    return not (self == other)