@@ -69,18 +69,18 @@ class ItemSummary(BrowseAPIBaseContainer):
69
69
"""
70
70
71
71
def __init__ (self , item_summary : dict ):
72
- self .adultOnly = item_summary [ 'adultOnly' ]
73
- self .buyingOptions = item_summary [ 'buyingOptions' ]
74
- self .conditionId = item_summary [ 'conditionId' ]
72
+ self .adultOnly = item_summary . get ( 'adultOnly' )
73
+ self .buyingOptions = item_summary . get ( 'buyingOptions' )
74
+ self .conditionId = item_summary . get ( 'conditionId' )
75
75
self .image = Image (item_summary ['image' ])
76
- self .itemHref = item_summary [ 'itemHref' ]
77
- self .itemId = item_summary [ 'itemId' ]
76
+ self .itemHref = item_summary . get ( 'itemHref' )
77
+ self .itemId = item_summary . get ( 'itemId' )
78
78
self .itemLocation = ItemLocationImpl (item_summary ['itemLocation' ])
79
- self .itemWebUrl = item_summary [ 'itemWebUrl' ]
79
+ self .itemWebUrl = item_summary . get ( 'itemWebUrl' )
80
80
self .price = ConvertedAmount (item_summary ['price' ])
81
81
self .seller = Seller (item_summary ['seller' ])
82
82
self .shortDescription = item_summary .get ('shortDescription' )
83
- self .title = item_summary [ 'title' ]
83
+ self .title = item_summary . get ( 'title' )
84
84
self .unitPricingMeasure = item_summary .get ('unitPricingMeasure' )
85
85
86
86
for key in ('bidCount' ,
@@ -143,7 +143,7 @@ class Category(BrowseAPIBaseContainer):
143
143
"""
144
144
145
145
def __init__ (self , category : dict ):
146
- self .categoryId = category [ 'categoryId' ]
146
+ self .categoryId = category . get ( 'categoryId' )
147
147
148
148
149
149
class CompatibilityProperty (BrowseAPIBaseContainer ):
@@ -164,8 +164,8 @@ class ConvertedAmount(BrowseAPIBaseContainer):
164
164
"""
165
165
166
166
def __init__ (self , current_price : dict ):
167
- self .currency = current_price [ 'currency' ]
168
- self .value = current_price [ 'value' ]
167
+ self .currency = current_price . get ( 'currency' )
168
+ self .value = current_price . get ( 'value' )
169
169
170
170
for key in 'convertedFromCurrency' , 'convertedFromValue' :
171
171
setattr (self , key , current_price .get (key ))
@@ -189,9 +189,7 @@ class ItemLocationImpl(BrowseAPIBaseContainer):
189
189
"""
190
190
191
191
def __init__ (self , location : dict ):
192
- self .country = location ['country' ]
193
-
194
- for key in 'addressLine1' , 'addressLine2' , 'city' , 'county' , 'stateOrProvince' , 'postalCode' :
192
+ for key in 'addressLine1' , 'addressLine2' , 'city' , 'country' , 'county' , 'stateOrProvince' , 'postalCode' :
195
193
setattr (self , key , location .get (key ))
196
194
197
195
@@ -202,9 +200,7 @@ class MarketingPrice(BrowseAPIBaseContainer):
202
200
"""
203
201
204
202
def __init__ (self , price : dict ):
205
- self .discountPercentage = price .get ('discountPercentage' )
206
-
207
- for key in 'currency' , 'value' :
203
+ for key in 'discountPercentage' , 'currency' , 'value' :
208
204
setattr (self , key , price .get (key ))
209
205
210
206
if 'discountAmount' in price :
@@ -349,14 +345,15 @@ class ErrorDetailV3(BrowseAPIBaseContainer):
349
345
"""
350
346
351
347
def __init__ (self , warning : dict ):
352
- self .category = warning ['category' ]
353
- self .domain = warning ['domain' ]
354
- self .errorId = warning ['errorId' ]
355
- self .message = warning ['message' ]
356
-
357
- for key in 'inputRefIds' , 'longMessage' , 'outputRefIds' , 'subdomain' :
358
- if key in warning :
359
- setattr (self , key , warning [key ])
348
+ for key in ('category' ,
349
+ 'domain' ,
350
+ 'errorId' ,
351
+ 'message' ,
352
+ 'inputRefIds' ,
353
+ 'longMessage' ,
354
+ 'outputRefIds' ,
355
+ 'subdomain' ):
356
+ setattr (self , key , warning .get (key ))
360
357
361
358
if 'parameters' in warning :
362
359
self .parameters = [ErrorParameterV3 (parameter ) for parameter in warning ['parameters' ]]
@@ -370,5 +367,4 @@ class ErrorParameterV3(BrowseAPIBaseContainer):
370
367
371
368
def __init__ (self , parameter : dict ):
372
369
for key in 'name' , 'value' :
373
- if key in parameter :
374
- setattr (self , key , parameter [key ])
370
+ setattr (self , key , parameter .get (key ))
0 commit comments