lib/easypost/report.rb in easypost-4.12.0 vs lib/easypost/report.rb in easypost-4.13.0

- old
+ new

@@ -16,8 +16,29 @@ # Retrieve a list of Report objects. def self.all(filters = {}, api_key = nil) url = "#{self.url}/#{filters[:type]}" response = EasyPost.make_request(:get, url, api_key, filters) - EasyPost::Util.convert_to_easypost_object(response, api_key) + collection = EasyPost::Util.convert_to_easypost_object(response, api_key) + + # Store the filters used to retrieve the collection. + collection.refresh_from({ type: filters[:type] }, api_key) + + collection + end + + # Get the next page of addresses. + def self.get_next_page(collection, page_size = nil) + get_next_page_exec(method(:all), collection, collection.reports, page_size) + end + + # Build the next page parameters. + def self.build_next_page_params(collection, current_page_items, page_size = nil) + params = {} + params[:before_id] = current_page_items.last.id + unless page_size.nil? + params[:page_size] = page_size + end + params[:type] = collection.type + params end end