@@ -312,16 +312,18 @@ class BunqResponse(object):
312
312
"""
313
313
:type _value: T
314
314
:type _headers: dict[str, str]
315
+ :type _pagination: Pagination
315
316
"""
316
317
317
- def __init__ (self , value , headers ):
318
+ def __init__ (self , value , headers , pagination = None ):
318
319
"""
319
320
:type value: T
320
321
:type headers: dict[str, str]
321
322
"""
322
323
323
324
self ._value = value
324
325
self ._headers = headers
326
+ self ._pagination = pagination
325
327
326
328
@property
327
329
def value (self ):
@@ -339,6 +341,14 @@ def headers(self):
339
341
340
342
return self ._headers
341
343
344
+ @property
345
+ def pagination (self ):
346
+ """
347
+ :rtype: Pagination
348
+ """
349
+
350
+ return self ._pagination
351
+
342
352
343
353
class Pagination (object ):
344
354
"""
@@ -348,8 +358,67 @@ class Pagination(object):
348
358
:type _count: int|None
349
359
"""
350
360
361
+ # Field constants
362
+ _FIELD_OLDER_ID = 'older_id'
363
+ _FIELD_NEWER_ID = 'newer_id'
364
+ _FIELD_COUNT = 'count'
365
+
351
366
def __init__ (self ):
352
367
self ._older_id = None
353
368
self ._newer_id = None
354
369
self ._future_id = None
355
370
self ._count = None
371
+
372
+ @property
373
+ def url_params_previous (self ):
374
+ """
375
+ :rtype: dict
376
+ """
377
+
378
+ params = {
379
+ self ._FIELD_OLDER_ID : self ._older_id ,
380
+ }
381
+ self ._add_count_to_params_if_needed (params )
382
+
383
+ return params
384
+
385
+ def _add_count_to_params_if_needed (self , params ):
386
+ """
387
+ :type params: dict
388
+
389
+ :rtype: None
390
+ """
391
+
392
+ if self ._count is not None :
393
+ params [self ._FIELD_COUNT ] = self ._count
394
+
395
+ @property
396
+ def _next_id (self ):
397
+ """
398
+ :rtype: int
399
+ """
400
+
401
+ if self .has_next_item_assured ():
402
+ return self ._newer_id
403
+
404
+ return self ._future_id
405
+
406
+ def has_next_item_assured (self ):
407
+ """
408
+ :rtype: bool
409
+ """
410
+
411
+ return self ._newer_id is not None
412
+
413
+ @property
414
+ def url_params_next (self ):
415
+ """
416
+ :rtype: dict
417
+ """
418
+
419
+ params = {
420
+ self ._FIELD_NEWER_ID : self ._next_id ,
421
+ }
422
+ self ._add_count_to_params_if_needed (params )
423
+
424
+ return params
0 commit comments