Skip to content

Commit 0f87c55

Browse files
Manuel HuezManuel Huez
authored andcommitted
Improve options parameter handling
1 parent 15aaa88 commit 0f87c55

File tree

15 files changed

+399
-162
lines changed

15 files changed

+399
-162
lines changed

processout/activity.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,13 @@ def fillWithData(self, data):
127127

128128
return self
129129

130-
def all(self, options = None):
130+
def all(self, options = {}):
131131
"""Get all the project activities.
132132
Keyword argument:
133133
134134
options -- Options for the request"""
135+
self.fillWithData(options)
136+
135137
request = Request(self._client)
136138
path = "/activities"
137139
data = {
@@ -152,13 +154,15 @@ def all(self, options = None):
152154

153155

154156

155-
return returnValues[0];
157+
return returnValues[0]
156158

157-
def find(self, activityId, options = None):
159+
def find(self, activityId, options = {}):
158160
"""Find a specific activity and fetch its data.
159161
Keyword argument:
160162
activityId -- ID of the activity
161163
options -- Options for the request"""
164+
self.fillWithData(options)
165+
162166
request = Request(self._client)
163167
path = "/activities/" + quote_plus(activityId) + ""
164168
data = {
@@ -177,6 +181,6 @@ def find(self, activityId, options = None):
177181

178182

179183

180-
return returnValues[0];
184+
return returnValues[0]
181185

182186

processout/authorizationrequest.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,13 @@ def fillWithData(self, data):
233233

234234
return self
235235

236-
def fetchCustomer(self, options = None):
236+
def fetchCustomer(self, options = {}):
237237
"""Get the customer linked to the authorization request.
238238
Keyword argument:
239239
240240
options -- Options for the request"""
241+
self.fillWithData(options)
242+
241243
request = Request(self._client)
242244
path = "/authorization-requests/" + quote_plus(self.id) + "/customers"
243245
data = {
@@ -253,13 +255,15 @@ def fetchCustomer(self, options = None):
253255
returnValues.append(customer.fillWithData(body))
254256

255257

256-
return returnValues[0];
258+
return returnValues[0]
257259

258-
def create(self, customerId, options = None):
260+
def create(self, customerId, options = {}):
259261
"""Create a new authorization request for the given customer ID.
260262
Keyword argument:
261263
customerId -- ID of the customer
262264
options -- Options for the request"""
265+
self.fillWithData(options)
266+
263267
request = Request(self._client)
264268
path = "/authorization-requests"
265269
data = {
@@ -281,13 +285,15 @@ def create(self, customerId, options = None):
281285

282286

283287

284-
return returnValues[0];
288+
return returnValues[0]
285289

286-
def find(self, authorizationRequestId, options = None):
290+
def find(self, authorizationRequestId, options = {}):
287291
"""Find an authorization request by its ID.
288292
Keyword argument:
289293
authorizationRequestId -- ID of the authorization request
290294
options -- Options for the request"""
295+
self.fillWithData(options)
296+
291297
request = Request(self._client)
292298
path = "/authorization-requests/" + quote_plus(authorizationRequestId) + ""
293299
data = {
@@ -306,6 +312,6 @@ def find(self, authorizationRequestId, options = None):
306312

307313

308314

309-
return returnValues[0];
315+
return returnValues[0]
310316

311317

processout/coupon.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,13 @@ def fillWithData(self, data):
239239

240240
return self
241241

242-
def all(self, options = None):
242+
def all(self, options = {}):
243243
"""Get all the coupons.
244244
Keyword argument:
245245
246246
options -- Options for the request"""
247+
self.fillWithData(options)
248+
247249
request = Request(self._client)
248250
path = "/coupons"
249251
data = {
@@ -264,13 +266,15 @@ def all(self, options = None):
264266

265267

266268

267-
return returnValues[0];
269+
return returnValues[0]
268270

269-
def create(self, options = None):
271+
def create(self, options = {}):
270272
"""Create a new coupon.
271273
Keyword argument:
272274
273275
options -- Options for the request"""
276+
self.fillWithData(options)
277+
274278
request = Request(self._client)
275279
path = "/coupons"
276280
data = {
@@ -295,13 +299,15 @@ def create(self, options = None):
295299

296300

297301

298-
return returnValues[0];
302+
return returnValues[0]
299303

300-
def find(self, couponId, options = None):
304+
def find(self, couponId, options = {}):
301305
"""Find a coupon by its ID.
302306
Keyword argument:
303307
couponId -- ID of the coupon
304308
options -- Options for the request"""
309+
self.fillWithData(options)
310+
305311
request = Request(self._client)
306312
path = "/coupons/" + quote_plus(couponId) + ""
307313
data = {
@@ -320,13 +326,15 @@ def find(self, couponId, options = None):
320326

321327

322328

323-
return returnValues[0];
329+
return returnValues[0]
324330

325-
def save(self, options = None):
331+
def save(self, options = {}):
326332
"""Save the updated coupon attributes.
327333
Keyword argument:
328334
329335
options -- Options for the request"""
336+
self.fillWithData(options)
337+
330338
request = Request(self._client)
331339
path = "/coupons/" + quote_plus(self.id) + ""
332340
data = {
@@ -344,13 +352,15 @@ def save(self, options = None):
344352

345353

346354

347-
return returnValues[0];
355+
return returnValues[0]
348356

349-
def delete(self, options = None):
357+
def delete(self, options = {}):
350358
"""Delete the coupon.
351359
Keyword argument:
352360
353361
options -- Options for the request"""
362+
self.fillWithData(options)
363+
354364
request = Request(self._client)
355365
path = "/coupons/" + quote_plus(self.id) + ""
356366
data = {
@@ -363,6 +373,6 @@ def delete(self, options = None):
363373
returnValues.append(response.success)
364374

365375

366-
return returnValues[0];
376+
return returnValues[0]
367377

368378

0 commit comments

Comments
 (0)