Module: Hubspot::Helpers::GetAllHelper

Constant Summary collapse

MAX_PAGE_SIZE =
100

Instance Method Summary collapse

Instance Method Details

#get_all(opts = {}) ⇒ Object

List Read all contacts. Control what is returned via the ‘properties` query param.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :properties (Array<String>)

    A comma separated list of the properties to be returned in the response. If any of the specified properties are not present on the requested object(s), they will be ignored.

  • :associations (Array<String>)

    A comma separated list of object types to retrieve associated IDs for. If any of the specified associations do not exist, they will be ignored.

  • :archived (Boolean)

    Whether to return only results that have been archived. (default to false)

Returns:

  • Array



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/hubspot/helpers/get_all_helper.rb', line 12

def get_all(opts = {})
  after = nil
  objects = []
  loop do
    page_opts = opts.merge(limit: MAX_PAGE_SIZE, after: after)
    page = get_page(page_opts)
    objects.concat(page.results)
    break objects if page.paging.nil?

    after = page.paging._next.after
  end

end