Subversion Repositories SmartDukaan

Rev

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

Rev 5469 Rev 6250
Line 77... Line 77...
77
    """
77
    """
78
    Returns a list of active coupons
78
    Returns a list of active coupons
79
    """
79
    """
80
    pass
80
    pass
81
 
81
 
-
 
82
  def createCoupon(self, promotionId, endOn, email, amount, usage):
-
 
83
    """
-
 
84
    Creates a coupon and returns couponcode if successfully created
-
 
85
 
-
 
86
    Parameters:
-
 
87
     - promotionId
-
 
88
     - endOn
-
 
89
     - email
-
 
90
     - amount
-
 
91
     - usage
-
 
92
    """
-
 
93
    pass
-
 
94
 
82
  def getSuccessfulPaymentCountForCoupon(self, couponCode):
95
  def getSuccessfulPaymentCountForCoupon(self, couponCode):
83
    """
96
    """
84
    Returns the count of successful payments done using a given coupon
97
    Returns the count of successful payments done using a given coupon
85
 
98
 
86
    Parameters:
99
    Parameters:
Line 401... Line 414...
401
      return result.success
414
      return result.success
402
    if result.pex is not None:
415
    if result.pex is not None:
403
      raise result.pex
416
      raise result.pex
404
    raise TApplicationException(TApplicationException.MISSING_RESULT, "getActiveCoupons failed: unknown result");
417
    raise TApplicationException(TApplicationException.MISSING_RESULT, "getActiveCoupons failed: unknown result");
405
 
418
 
-
 
419
  def createCoupon(self, promotionId, endOn, email, amount, usage):
-
 
420
    """
-
 
421
    Creates a coupon and returns couponcode if successfully created
-
 
422
 
-
 
423
    Parameters:
-
 
424
     - promotionId
-
 
425
     - endOn
-
 
426
     - email
-
 
427
     - amount
-
 
428
     - usage
-
 
429
    """
-
 
430
    self.send_createCoupon(promotionId, endOn, email, amount, usage)
-
 
431
    return self.recv_createCoupon()
-
 
432
 
-
 
433
  def send_createCoupon(self, promotionId, endOn, email, amount, usage):
-
 
434
    self._oprot.writeMessageBegin('createCoupon', TMessageType.CALL, self._seqid)
-
 
435
    args = createCoupon_args()
-
 
436
    args.promotionId = promotionId
-
 
437
    args.endOn = endOn
-
 
438
    args.email = email
-
 
439
    args.amount = amount
-
 
440
    args.usage = usage
-
 
441
    args.write(self._oprot)
-
 
442
    self._oprot.writeMessageEnd()
-
 
443
    self._oprot.trans.flush()
-
 
444
 
-
 
445
  def recv_createCoupon(self, ):
-
 
446
    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
-
 
447
    if mtype == TMessageType.EXCEPTION:
-
 
448
      x = TApplicationException()
-
 
449
      x.read(self._iprot)
-
 
450
      self._iprot.readMessageEnd()
-
 
451
      raise x
-
 
452
    result = createCoupon_result()
-
 
453
    result.read(self._iprot)
-
 
454
    self._iprot.readMessageEnd()
-
 
455
    if result.success is not None:
-
 
456
      return result.success
-
 
457
    if result.pex is not None:
-
 
458
      raise result.pex
-
 
459
    raise TApplicationException(TApplicationException.MISSING_RESULT, "createCoupon failed: unknown result");
-
 
460
 
406
  def getSuccessfulPaymentCountForCoupon(self, couponCode):
461
  def getSuccessfulPaymentCountForCoupon(self, couponCode):
407
    """
462
    """
408
    Returns the count of successful payments done using a given coupon
463
    Returns the count of successful payments done using a given coupon
409
 
464
 
410
    Parameters:
465
    Parameters:
Line 637... Line 692...
637
    self._processMap["generateCouponsForPromotion"] = Processor.process_generateCouponsForPromotion
692
    self._processMap["generateCouponsForPromotion"] = Processor.process_generateCouponsForPromotion
638
    self._processMap["applyCoupon"] = Processor.process_applyCoupon
693
    self._processMap["applyCoupon"] = Processor.process_applyCoupon
639
    self._processMap["trackCouponUsage"] = Processor.process_trackCouponUsage
694
    self._processMap["trackCouponUsage"] = Processor.process_trackCouponUsage
640
    self._processMap["getCouponUsageCountByUser"] = Processor.process_getCouponUsageCountByUser
695
    self._processMap["getCouponUsageCountByUser"] = Processor.process_getCouponUsageCountByUser
641
    self._processMap["getActiveCoupons"] = Processor.process_getActiveCoupons
696
    self._processMap["getActiveCoupons"] = Processor.process_getActiveCoupons
-
 
697
    self._processMap["createCoupon"] = Processor.process_createCoupon
642
    self._processMap["getSuccessfulPaymentCountForCoupon"] = Processor.process_getSuccessfulPaymentCountForCoupon
698
    self._processMap["getSuccessfulPaymentCountForCoupon"] = Processor.process_getSuccessfulPaymentCountForCoupon
643
    self._processMap["getRuleDocString"] = Processor.process_getRuleDocString
699
    self._processMap["getRuleDocString"] = Processor.process_getRuleDocString
644
    self._processMap["getItemDiscountMap"] = Processor.process_getItemDiscountMap
700
    self._processMap["getItemDiscountMap"] = Processor.process_getItemDiscountMap
645
    self._processMap["getDiscountsForEntity"] = Processor.process_getDiscountsForEntity
701
    self._processMap["getDiscountsForEntity"] = Processor.process_getDiscountsForEntity
646
    self._processMap["addVoucher"] = Processor.process_addVoucher
702
    self._processMap["addVoucher"] = Processor.process_addVoucher
Line 772... Line 828...
772
    oprot.writeMessageBegin("getActiveCoupons", TMessageType.REPLY, seqid)
828
    oprot.writeMessageBegin("getActiveCoupons", TMessageType.REPLY, seqid)
773
    result.write(oprot)
829
    result.write(oprot)
774
    oprot.writeMessageEnd()
830
    oprot.writeMessageEnd()
775
    oprot.trans.flush()
831
    oprot.trans.flush()
776
 
832
 
-
 
833
  def process_createCoupon(self, seqid, iprot, oprot):
-
 
834
    args = createCoupon_args()
-
 
835
    args.read(iprot)
-
 
836
    iprot.readMessageEnd()
-
 
837
    result = createCoupon_result()
-
 
838
    try:
-
 
839
      result.success = self._handler.createCoupon(args.promotionId, args.endOn, args.email, args.amount, args.usage)
-
 
840
    except PromotionException, pex:
-
 
841
      result.pex = pex
-
 
842
    oprot.writeMessageBegin("createCoupon", TMessageType.REPLY, seqid)
-
 
843
    result.write(oprot)
-
 
844
    oprot.writeMessageEnd()
-
 
845
    oprot.trans.flush()
-
 
846
 
777
  def process_getSuccessfulPaymentCountForCoupon(self, seqid, iprot, oprot):
847
  def process_getSuccessfulPaymentCountForCoupon(self, seqid, iprot, oprot):
778
    args = getSuccessfulPaymentCountForCoupon_args()
848
    args = getSuccessfulPaymentCountForCoupon_args()
779
    args.read(iprot)
849
    args.read(iprot)
780
    iprot.readMessageEnd()
850
    iprot.readMessageEnd()
781
    result = getSuccessfulPaymentCountForCoupon_result()
851
    result = getSuccessfulPaymentCountForCoupon_result()
Line 1943... Line 2013...
1943
      oprot.writeFieldEnd()
2013
      oprot.writeFieldEnd()
1944
    if self.pex is not None:
2014
    if self.pex is not None:
1945
      oprot.writeFieldBegin('pex', TType.STRUCT, 1)
2015
      oprot.writeFieldBegin('pex', TType.STRUCT, 1)
1946
      self.pex.write(oprot)
2016
      self.pex.write(oprot)
1947
      oprot.writeFieldEnd()
2017
      oprot.writeFieldEnd()
-
 
2018
    oprot.writeFieldStop()
-
 
2019
    oprot.writeStructEnd()
-
 
2020
 
-
 
2021
  def validate(self):
-
 
2022
    return
-
 
2023
 
-
 
2024
 
-
 
2025
  def __repr__(self):
-
 
2026
    L = ['%s=%r' % (key, value)
-
 
2027
      for key, value in self.__dict__.iteritems()]
-
 
2028
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
-
 
2029
 
-
 
2030
  def __eq__(self, other):
-
 
2031
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
-
 
2032
 
-
 
2033
  def __ne__(self, other):
-
 
2034
    return not (self == other)
-
 
2035
 
-
 
2036
class createCoupon_args:
-
 
2037
  """
-
 
2038
  Attributes:
-
 
2039
   - promotionId
-
 
2040
   - endOn
-
 
2041
   - email
-
 
2042
   - amount
-
 
2043
   - usage
-
 
2044
  """
-
 
2045
 
-
 
2046
  thrift_spec = (
-
 
2047
    None, # 0
-
 
2048
    (1, TType.I64, 'promotionId', None, None, ), # 1
-
 
2049
    (2, TType.I64, 'endOn', None, None, ), # 2
-
 
2050
    (3, TType.STRING, 'email', None, None, ), # 3
-
 
2051
    (4, TType.I64, 'amount', None, None, ), # 4
-
 
2052
    (5, TType.I64, 'usage', None, None, ), # 5
-
 
2053
  )
-
 
2054
 
-
 
2055
  def __init__(self, promotionId=None, endOn=None, email=None, amount=None, usage=None,):
-
 
2056
    self.promotionId = promotionId
-
 
2057
    self.endOn = endOn
-
 
2058
    self.email = email
-
 
2059
    self.amount = amount
-
 
2060
    self.usage = usage
-
 
2061
 
-
 
2062
  def read(self, iprot):
-
 
2063
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
-
 
2064
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
-
 
2065
      return
-
 
2066
    iprot.readStructBegin()
-
 
2067
    while True:
-
 
2068
      (fname, ftype, fid) = iprot.readFieldBegin()
-
 
2069
      if ftype == TType.STOP:
-
 
2070
        break
-
 
2071
      if fid == 1:
-
 
2072
        if ftype == TType.I64:
-
 
2073
          self.promotionId = iprot.readI64();
-
 
2074
        else:
-
 
2075
          iprot.skip(ftype)
-
 
2076
      elif fid == 2:
-
 
2077
        if ftype == TType.I64:
-
 
2078
          self.endOn = iprot.readI64();
-
 
2079
        else:
-
 
2080
          iprot.skip(ftype)
-
 
2081
      elif fid == 3:
-
 
2082
        if ftype == TType.STRING:
-
 
2083
          self.email = iprot.readString();
-
 
2084
        else:
-
 
2085
          iprot.skip(ftype)
-
 
2086
      elif fid == 4:
-
 
2087
        if ftype == TType.I64:
-
 
2088
          self.amount = iprot.readI64();
-
 
2089
        else:
-
 
2090
          iprot.skip(ftype)
-
 
2091
      elif fid == 5:
-
 
2092
        if ftype == TType.I64:
-
 
2093
          self.usage = iprot.readI64();
-
 
2094
        else:
-
 
2095
          iprot.skip(ftype)
-
 
2096
      else:
-
 
2097
        iprot.skip(ftype)
-
 
2098
      iprot.readFieldEnd()
-
 
2099
    iprot.readStructEnd()
-
 
2100
 
-
 
2101
  def write(self, oprot):
-
 
2102
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
-
 
2103
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
-
 
2104
      return
-
 
2105
    oprot.writeStructBegin('createCoupon_args')
-
 
2106
    if self.promotionId is not None:
-
 
2107
      oprot.writeFieldBegin('promotionId', TType.I64, 1)
-
 
2108
      oprot.writeI64(self.promotionId)
-
 
2109
      oprot.writeFieldEnd()
-
 
2110
    if self.endOn is not None:
-
 
2111
      oprot.writeFieldBegin('endOn', TType.I64, 2)
-
 
2112
      oprot.writeI64(self.endOn)
-
 
2113
      oprot.writeFieldEnd()
-
 
2114
    if self.email is not None:
-
 
2115
      oprot.writeFieldBegin('email', TType.STRING, 3)
-
 
2116
      oprot.writeString(self.email)
-
 
2117
      oprot.writeFieldEnd()
-
 
2118
    if self.amount is not None:
-
 
2119
      oprot.writeFieldBegin('amount', TType.I64, 4)
-
 
2120
      oprot.writeI64(self.amount)
-
 
2121
      oprot.writeFieldEnd()
-
 
2122
    if self.usage is not None:
-
 
2123
      oprot.writeFieldBegin('usage', TType.I64, 5)
-
 
2124
      oprot.writeI64(self.usage)
-
 
2125
      oprot.writeFieldEnd()
-
 
2126
    oprot.writeFieldStop()
-
 
2127
    oprot.writeStructEnd()
-
 
2128
 
-
 
2129
  def validate(self):
-
 
2130
    return
-
 
2131
 
-
 
2132
 
-
 
2133
  def __repr__(self):
-
 
2134
    L = ['%s=%r' % (key, value)
-
 
2135
      for key, value in self.__dict__.iteritems()]
-
 
2136
    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
-
 
2137
 
-
 
2138
  def __eq__(self, other):
-
 
2139
    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
-
 
2140
 
-
 
2141
  def __ne__(self, other):
-
 
2142
    return not (self == other)
-
 
2143
 
-
 
2144
class createCoupon_result:
-
 
2145
  """
-
 
2146
  Attributes:
-
 
2147
   - success
-
 
2148
   - pex
-
 
2149
  """
-
 
2150
 
-
 
2151
  thrift_spec = (
-
 
2152
    (0, TType.STRING, 'success', None, None, ), # 0
-
 
2153
    (1, TType.STRUCT, 'pex', (PromotionException, PromotionException.thrift_spec), None, ), # 1
-
 
2154
  )
-
 
2155
 
-
 
2156
  def __init__(self, success=None, pex=None,):
-
 
2157
    self.success = success
-
 
2158
    self.pex = pex
-
 
2159
 
-
 
2160
  def read(self, iprot):
-
 
2161
    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
-
 
2162
      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
-
 
2163
      return
-
 
2164
    iprot.readStructBegin()
-
 
2165
    while True:
-
 
2166
      (fname, ftype, fid) = iprot.readFieldBegin()
-
 
2167
      if ftype == TType.STOP:
-
 
2168
        break
-
 
2169
      if fid == 0:
-
 
2170
        if ftype == TType.STRING:
-
 
2171
          self.success = iprot.readString();
-
 
2172
        else:
-
 
2173
          iprot.skip(ftype)
-
 
2174
      elif fid == 1:
-
 
2175
        if ftype == TType.STRUCT:
-
 
2176
          self.pex = PromotionException()
-
 
2177
          self.pex.read(iprot)
-
 
2178
        else:
-
 
2179
          iprot.skip(ftype)
-
 
2180
      else:
-
 
2181
        iprot.skip(ftype)
-
 
2182
      iprot.readFieldEnd()
-
 
2183
    iprot.readStructEnd()
-
 
2184
 
-
 
2185
  def write(self, oprot):
-
 
2186
    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
-
 
2187
      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
-
 
2188
      return
-
 
2189
    oprot.writeStructBegin('createCoupon_result')
-
 
2190
    if self.success is not None:
-
 
2191
      oprot.writeFieldBegin('success', TType.STRING, 0)
-
 
2192
      oprot.writeString(self.success)
-
 
2193
      oprot.writeFieldEnd()
-
 
2194
    if self.pex is not None:
-
 
2195
      oprot.writeFieldBegin('pex', TType.STRUCT, 1)
-
 
2196
      self.pex.write(oprot)
-
 
2197
      oprot.writeFieldEnd()
1948
    oprot.writeFieldStop()
2198
    oprot.writeFieldStop()
1949
    oprot.writeStructEnd()
2199
    oprot.writeStructEnd()
1950
 
2200
 
1951
  def validate(self):
2201
  def validate(self):
1952
    return
2202
    return