6
6
class Discount (object ):
7
7
8
8
def __init__ (self ):
9
- self .discountTag = None
10
- self .discountName = None
11
- self .savingsAmount = None # type: Amount
12
- self .estimateSavingsAmount = None # type: Amount
9
+ self .__discount_tag = None
10
+ self .__discount_name = None
11
+ self .__savings_amount = None # type: Amount
12
+ self .__estimate_savings_amount = None # type: Amount
13
+ self .__promotion_code = None
13
14
14
15
@property
15
- def discountTag (self ):
16
- return self .__discountTag
16
+ def discount_tag (self ):
17
+ return self .__discount_tag
17
18
18
- @discountTag .setter
19
- def discountTag (self , value ):
20
- self .__discountTag = value
19
+ @discount_tag .setter
20
+ def discount_tag (self , value ):
21
+ self .__discount_tag = value
21
22
22
23
@property
23
- def discountName (self ):
24
- return self .__discountName
24
+ def discount_name (self ):
25
+ return self .__discount_name
25
26
26
- @discountName .setter
27
- def discountName (self , value ):
28
- self .__discountName = value
27
+ @discount_name .setter
28
+ def discount_name (self , value ):
29
+ self .__discount_name = value
30
+
31
+ @property
32
+ def savings_amount (self ):
33
+ return self .__savings_amount
34
+
35
+ @savings_amount .setter
36
+ def savings_amount (self , value ):
37
+ self .__savings_amount = value
38
+
39
+ @property
40
+ def estimate_savings_amount (self ):
41
+ return self .__estimate_savings_amount
42
+
43
+ @estimate_savings_amount .setter
44
+ def estimate_savings_amount (self , value ):
45
+ self .__estimate_savings_amount = value
46
+
47
+ @property
48
+ def promotion_code (self ):
49
+ return self .__promotion_code
50
+
51
+ @promotion_code .setter
52
+ def promotion_code (self , value ):
53
+ self .__promotion_code = value
29
54
30
55
@property
31
56
def savingsAmount (self ):
32
- return self .__savingsAmount
57
+ return self .__savings_amount
33
58
34
59
@savingsAmount .setter
35
60
def savingsAmount (self , value ):
36
- self .__savingsAmount = value
61
+ self .__savings_amount = value
37
62
38
63
@property
39
64
def estimateSavingsAmount (self ):
40
- return self .__estimateSavingsAmount
65
+ return self .__estimate_savings_amount
41
66
42
67
@estimateSavingsAmount .setter
43
68
def estimateSavingsAmount (self , value ):
44
- self .__estimateSavingsAmount = value
69
+ self .__estimate_savings_amount = value
70
+
71
+ @property
72
+ def promotionCode (self ):
73
+ return self .__promotion_code
74
+
75
+ @promotionCode .setter
76
+ def promotionCode (self , value ):
77
+ self .__promotion_code = value
45
78
46
79
def to_ams_dict (self ):
47
80
params = dict ()
48
81
if self .discountTag is not None :
49
- params ['discountTag' ] = self .discountTag
82
+ params ['discountTag' ] = self .discount_tag
50
83
if self .discountName is not None :
51
- params ['discountName' ] = self .discountName
84
+ params ['discountName' ] = self .discount_name
52
85
if self .savingsAmount is not None :
53
- params ['savingsAmount' ] = self .savingsAmount .to_ams_dict ()
86
+ params ['savingsAmount' ] = self .savings_amount .to_ams_dict ()
54
87
if self .estimateSavingsAmount is not None :
55
- params ['estimateSavingsAmount' ] = self .estimateSavingsAmount .to_ams_dict ()
88
+ params ['estimateSavingsAmount' ] = self .estimate_savings_amount .to_ams_dict ()
89
+ if self .promotionCode is not None :
90
+ params ['promotionCode' ] = self .promotion_code
56
91
return params
57
92
58
93
def parse_rsp_body (self , discount_body ):
59
94
if type (discount_body ) == str :
60
95
discount_body = json .loads (discount_body )
61
96
62
97
if 'discountTag' in discount_body :
63
- self .discountTag = discount_body ['discountTag' ]
98
+ self .discount_tag = discount_body ['discountTag' ]
64
99
65
100
if 'discountName' in discount_body :
66
- self .discountName = discount_body ['discountName' ]
101
+ self .discount_name = discount_body ['discountName' ]
67
102
68
103
if 'savingsAmount' in discount_body :
69
104
payment_amount = Amount ()
70
105
payment_amount .parse_rsp_body (discount_body ['savingsAmount' ])
71
- self .__savingsAmount = payment_amount
106
+ self .savings_amount = payment_amount
72
107
73
108
if 'estimateSavingsAmount' in discount_body :
74
109
payment_amount = Amount ()
75
110
payment_amount .parse_rsp_body (discount_body ['estimateSavingsAmount' ])
76
- self .__estimateSavingsAmount = payment_amount
111
+ self .estimate_savings_amount = payment_amount
112
+ if 'promotionCode' in discount_body :
113
+ self .promotion_code = discount_body ['promotionCode' ]
0 commit comments