mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-21 00:02:41 -04:00
When additional filters were provided for pagination like an expansion or a predicate, they would not propagate to any call after the first. This patch addresses that issue by storing all filters and moving them to any new page objects being created. Fixes #331.
30 lines
970 B
Ruby
30 lines
970 B
Ruby
module Stripe
|
|
module APIOperations
|
|
module List
|
|
def list(filters={}, opts={})
|
|
opts = Util.normalize_opts(opts)
|
|
opts = @opts.merge(opts) if @opts
|
|
|
|
response, opts = request(:get, url, filters, opts)
|
|
obj = ListObject.construct_from(response, opts)
|
|
|
|
# set filters so that we can fetch the same limit, expansions, and
|
|
# predicates when accessing the next and previous pages
|
|
#
|
|
# just for general cleanliness, remove any paging options
|
|
obj.filters = filters.dup
|
|
obj.filters.delete(:ending_before)
|
|
obj.filters.delete(:starting_after)
|
|
|
|
obj
|
|
end
|
|
|
|
# The original version of #list was given the somewhat unfortunate name of
|
|
# #all, and this alias allows us to maintain backward compatibility (the
|
|
# choice was somewhat misleading in the way that it only returned a single
|
|
# page rather than all objects).
|
|
alias :all :list
|
|
end
|
|
end
|
|
end
|