@@ -358,23 +358,27 @@ def intentional_obp_request?
358358
359359 def get_resources ( path_query_link )
360360 if intentional_obp_request?
361- warn "OBP will be deprecated after Oct 2023. "
361+ warn "Offset Based Pagination will be deprecated soon "
362362 elsif @next_page . nil?
363363 @options_per_page_was = @options . delete ( "per_page" )
364+ # Default to CBP by using the page param as a map
364365 @options . page = { size : ( @options_per_page_was || DEFAULT_PAGE_SIZE ) }
365366 end
366367
367368 begin
369+ # Try CBP first, unless the user explicitly asked for OBP
368370 @response = get_response ( path_query_link )
369371 rescue ZendeskAPI ::Error ::NetworkError => e
370372 raise e if intentional_obp_request?
373+ # Fallback to OBP if CBP didn't work, using per_page param
371374 @options . per_page = @options_per_page_was
372375 @options . page = nil
373376 @response = get_response ( path_query_link )
374377 end
375378
379+ # Keep pre-existing behaviour for search/export
376380 if path_query_link == "search/export"
377- handle_cursor_search_export_response ( @response . body )
381+ handle_search_export_response ( @response . body )
378382 else
379383 handle_response ( @response . body )
380384 end
@@ -385,6 +389,7 @@ def set_page_and_count(body)
385389 @next_page , @prev_page = page_links ( body )
386390
387391 if cbp_response? ( body )
392+ # We'll delete the one we don't need in #next or #prev
388393 @options [ "page" ] [ "after" ] = body [ "meta" ] [ "after_cursor" ]
389394 @options [ "page" ] [ "before" ] = body [ "meta" ] [ "before_cursor" ]
390395 elsif @next_page =~ /page=(\d +)/
@@ -469,9 +474,10 @@ def get_response(path)
469474 end
470475 end
471476
472- def handle_cursor_search_export_response ( response_body )
477+ def handle_search_export_response ( response_body )
473478 assert_valid_response_body ( response_body )
474479
480+ # Note this doesn't happen in #handle_response
475481 response_body = get_next_page_data ( response_body ) if more_results? ( response_body )
476482
477483 body = response_body . dup
@@ -484,6 +490,7 @@ def handle_cursor_search_export_response(response_body)
484490 end
485491 end
486492
493+ # For both CBP and OBP
487494 def handle_response ( response_body )
488495 assert_valid_response_body ( response_body )
489496
0 commit comments