Module: BitBucket::PagedRequest

Includes:
Constants, Normalizer
Included in:
PageIterator
Defined in:
lib/bitbucket_rest_api/paged_request.rb

Overview

A module that adds http get request to response pagination

Constant Summary collapse

FIRST_PAGE =

Default request page if none provided

1
NOT_FOUND =

Page parameter not present

-1 # Page parameter not present

Constants included from Constants

Constants::ACCEPT, Constants::ACCEPT_CHARSET, Constants::CACHE_CONTROL, Constants::CONTENT_LENGTH, Constants::CONTENT_TYPE, Constants::DATE, Constants::ETAG, Constants::LOCATION, Constants::META_FIRST, Constants::META_LAST, Constants::META_NEXT, Constants::META_PREV, Constants::META_REL, Constants::PARAM_PAGE, Constants::PARAM_START_PAGE, Constants::QUERY_STR_SEP, Constants::RATELIMIT_LIMIT, Constants::RATELIMIT_REMAINING, Constants::SERVER, Constants::USER_AGENT

Instance Method Summary collapse

Methods included from Normalizer

#normalize!

Instance Method Details

#default_pageObject



14
15
16
# File 'lib/bitbucket_rest_api/paged_request.rb', line 14

def default_page
  current_api.current_page ? current_api.current_page : FIRST_PAGE
end

#page_request(path, params = {}) ⇒ Object

Perform http get request with pagination parameters



20
21
22
23
24
25
26
# File 'lib/bitbucket_rest_api/paged_request.rb', line 20

def page_request(path, params={})
  if params[PARAM_PAGE] && params[PARAM_PAGE] == NOT_FOUND
    params[PARAM_PAGE] = default_page
  end

  current_api.get_request(path, ParamsHash.new(params))
end