From d46e337d6ac39443e94a03ac64f09d4235ee9879 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Mon, 30 Nov 2026 09:22:46 -0700 Subject: [PATCH 1/3] fix: keep report date filters when paginating --- CHANGELOG.md | 4 ++++ lib/easypost/services/report.rb | 4 +++- spec/report_spec.rb | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb9cf870..504523f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## Next Release + +- Fixes `report.get_next_page` dropping the `start_datetime` and `end_datetime` filters of the original `all` call + ## v7.8.1 (2026-11-09) - Fixes response hooks raising `NameError` when an HTTP body is not JSON diff --git a/lib/easypost/services/report.rb b/lib/easypost/services/report.rb index 4fcd0e52..ab90c653 100644 --- a/lib/easypost/services/report.rb +++ b/lib/easypost/services/report.rb @@ -33,7 +33,9 @@ def all(params = {}) filters = { key: 'reports', type: type, - } + start_datetime: params[:start_datetime], + end_datetime: params[:end_datetime], + }.compact url = "reports/#{type}" response = get_all_helper(url, MODEL_CLASS, params, filters) response.define_singleton_method(:type) { type } diff --git a/spec/report_spec.rb b/spec/report_spec.rb index 6913f5b2..871126a9 100644 --- a/spec/report_spec.rb +++ b/spec/report_spec.rb @@ -101,5 +101,25 @@ expect(e.message).to eq(EasyPost::Constants::NO_MORE_PAGES) end end + + it 'keeps the date filters of the original call' do + allow(client).to receive(:make_request).and_return( + { 'reports' => [{ 'id' => 'shprep_123', 'object' => 'Report' }], 'has_more' => true }, + ) + + first_page = client.report.all( + type: 'shipment', + start_datetime: '2026-01-01', + end_datetime: '2026-01-31', + ) + client.report.get_next_page(first_page) + + expect(client).to have_received(:make_request).with( + :get, + 'reports/shipment', + hash_including(before_id: 'shprep_123', start_datetime: '2026-01-01', end_datetime: '2026-01-31'), + anything, + ) + end end end From cad0ae4af41897a8c74fce0717201851d310f9ee Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Mon, 30 Nov 2026 09:31:53 -0700 Subject: [PATCH 2/3] fix: keep date filters when paginating other list results --- CHANGELOG.md | 2 +- lib/easypost/services/address.rb | 3 ++- lib/easypost/services/claim.rb | 3 ++- lib/easypost/services/event.rb | 3 ++- lib/easypost/services/insurance.rb | 3 ++- lib/easypost/services/pickup.rb | 3 ++- lib/easypost/services/referral_customer.rb | 3 ++- lib/easypost/services/refund.rb | 3 ++- lib/easypost/services/report.rb | 4 +--- lib/easypost/services/scan_form.rb | 3 ++- lib/easypost/services/shipment.rb | 2 +- lib/easypost/services/tracker.rb | 2 +- lib/easypost/services/user.rb | 3 ++- 13 files changed, 22 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 504523f3..be0681bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Next Release -- Fixes `report.get_next_page` dropping the `start_datetime` and `end_datetime` filters of the original `all` call +- Fixes `get_next_page` (addresses, claims, events, insurances, pickups, referral customers, refunds, reports, scan forms, shipments and trackers) and `get_next_page_of_children` dropping the `start_datetime` and `end_datetime` filters of the original list call ## v7.8.1 (2026-11-09) diff --git a/lib/easypost/services/address.rb b/lib/easypost/services/address.rb index fa394b98..9025baa0 100644 --- a/lib/easypost/services/address.rb +++ b/lib/easypost/services/address.rb @@ -57,7 +57,7 @@ def retrieve(id) # Retrieve all Addresses. def all(params = {}) - filters = { key: 'addresses' } + filters = { key: 'addresses' }.merge(params.slice(:start_datetime, :end_datetime)) get_all_helper('addresses', MODEL_CLASS, params, filters) end @@ -68,6 +68,7 @@ def get_next_page(collection, page_size = nil) params = { before_id: collection.addresses.last.id } params[:page_size] = page_size unless page_size.nil? + params.merge!(collection[EasyPost::InternalUtilities::Constants::FILTERS_KEY]).delete(:key) all(params) end diff --git a/lib/easypost/services/claim.rb b/lib/easypost/services/claim.rb index 4d0d6e54..7f5147e2 100644 --- a/lib/easypost/services/claim.rb +++ b/lib/easypost/services/claim.rb @@ -19,7 +19,7 @@ def retrieve(id) # Retrieve all Claim objects def all(params = {}) - filters = { key: 'claims' } + filters = { key: 'claims' }.merge(params.slice(:start_datetime, :end_datetime)) get_all_helper('claims', MODEL_CLASS, params, filters) end @@ -30,6 +30,7 @@ def get_next_page(collection, page_size = nil) params = { before_id: collection.claims.last.id } params[:page_size] = page_size unless page_size.nil? + params.merge!(collection[EasyPost::InternalUtilities::Constants::FILTERS_KEY]).delete(:key) all(params) end diff --git a/lib/easypost/services/event.rb b/lib/easypost/services/event.rb index fc58f9ee..2d7a8fb8 100644 --- a/lib/easypost/services/event.rb +++ b/lib/easypost/services/event.rb @@ -14,7 +14,7 @@ def retrieve(id) # Retrieve all Event objects def all(params = {}) - filters = { key: 'events' } + filters = { key: 'events' }.merge(params.slice(:start_datetime, :end_datetime)) get_all_helper('events', MODEL_CLASS, params, filters) end @@ -39,6 +39,7 @@ def get_next_page(collection, page_size = nil) params = { before_id: collection.events.last.id } params[:page_size] = page_size unless page_size.nil? + params.merge!(collection[EasyPost::InternalUtilities::Constants::FILTERS_KEY]).delete(:key) all(params) end diff --git a/lib/easypost/services/insurance.rb b/lib/easypost/services/insurance.rb index 1a7ebc2d..66e92b07 100644 --- a/lib/easypost/services/insurance.rb +++ b/lib/easypost/services/insurance.rb @@ -20,7 +20,7 @@ def retrieve(id) # Retrieve all Insurance objects def all(params = {}) - filters = { key: 'insurances' } + filters = { key: 'insurances' }.merge(params.slice(:start_datetime, :end_datetime)) get_all_helper('insurances', MODEL_CLASS, params, filters) end @@ -31,6 +31,7 @@ def get_next_page(collection, page_size = nil) params = { before_id: collection.insurances.last.id } params[:page_size] = page_size unless page_size.nil? + params.merge!(collection[EasyPost::InternalUtilities::Constants::FILTERS_KEY]).delete(:key) all(params) end diff --git a/lib/easypost/services/pickup.rb b/lib/easypost/services/pickup.rb index ecccfc03..3e783b26 100644 --- a/lib/easypost/services/pickup.rb +++ b/lib/easypost/services/pickup.rb @@ -20,7 +20,7 @@ def retrieve(id) # Retrieve all Pickup objects def all(params = {}) - filters = { key: 'pickups' } + filters = { key: 'pickups' }.merge(params.slice(:start_datetime, :end_datetime)) get_all_helper('pickups', MODEL_CLASS, params, filters) end @@ -49,6 +49,7 @@ def get_next_page(collection, page_size = nil) params = { before_id: collection.pickups.last.id } params[:page_size] = page_size unless page_size.nil? + params.merge!(collection[EasyPost::InternalUtilities::Constants::FILTERS_KEY]).delete(:key) all(params) end diff --git a/lib/easypost/services/referral_customer.rb b/lib/easypost/services/referral_customer.rb index 507d1367..22d709de 100644 --- a/lib/easypost/services/referral_customer.rb +++ b/lib/easypost/services/referral_customer.rb @@ -25,7 +25,7 @@ def update_email(user_id, email) # Retrieve a list of referral customers. This function requires the Partner User's API key. def all(params = {}) - filters = { key: 'referral_customers' } + filters = { key: 'referral_customers' }.merge(params.slice(:start_datetime, :end_datetime)) get_all_helper('referral_customers', MODEL_CLASS, params, filters) end @@ -36,6 +36,7 @@ def get_next_page(collection, page_size = nil) params = { before_id: collection.referral_customers.last.id } params[:page_size] = page_size unless page_size.nil? + params.merge!(collection[EasyPost::InternalUtilities::Constants::FILTERS_KEY]).delete(:key) all(params) end diff --git a/lib/easypost/services/refund.rb b/lib/easypost/services/refund.rb index 9d929bec..553ff637 100644 --- a/lib/easypost/services/refund.rb +++ b/lib/easypost/services/refund.rb @@ -20,7 +20,7 @@ def retrieve(id) # Retrieve all Refund objects def all(params = {}) - filters = { key: 'refunds' } + filters = { key: 'refunds' }.merge(params.slice(:start_datetime, :end_datetime)) get_all_helper('refunds', MODEL_CLASS, params, filters) end @@ -31,6 +31,7 @@ def get_next_page(collection, page_size = nil) params = { before_id: collection.refunds.last.id } params[:page_size] = page_size unless page_size.nil? + params.merge!(collection[EasyPost::InternalUtilities::Constants::FILTERS_KEY]).delete(:key) all(params) end diff --git a/lib/easypost/services/report.rb b/lib/easypost/services/report.rb index ab90c653..e166a207 100644 --- a/lib/easypost/services/report.rb +++ b/lib/easypost/services/report.rb @@ -33,9 +33,7 @@ def all(params = {}) filters = { key: 'reports', type: type, - start_datetime: params[:start_datetime], - end_datetime: params[:end_datetime], - }.compact + }.merge(params.slice(:start_datetime, :end_datetime)) url = "reports/#{type}" response = get_all_helper(url, MODEL_CLASS, params, filters) response.define_singleton_method(:type) { type } diff --git a/lib/easypost/services/scan_form.rb b/lib/easypost/services/scan_form.rb index 8dc26f9c..d1ccfbd0 100644 --- a/lib/easypost/services/scan_form.rb +++ b/lib/easypost/services/scan_form.rb @@ -19,7 +19,7 @@ def retrieve(id) # Retrieve a list of ScanForms def all(params = {}) - filters = { key: 'scan_forms' } + filters = { key: 'scan_forms' }.merge(params.slice(:start_datetime, :end_datetime)) get_all_helper('scan_forms', MODEL_CLASS, params, filters) end @@ -30,6 +30,7 @@ def get_next_page(collection, page_size = nil) params = { before_id: collection.scan_forms.last.id } params[:page_size] = page_size unless page_size.nil? + params.merge!(collection[EasyPost::InternalUtilities::Constants::FILTERS_KEY]).delete(:key) all(params) end diff --git a/lib/easypost/services/shipment.rb b/lib/easypost/services/shipment.rb index 59727e0e..2c803a50 100644 --- a/lib/easypost/services/shipment.rb +++ b/lib/easypost/services/shipment.rb @@ -26,7 +26,7 @@ def all(params = {}) key: 'shipments', purchased: params[:purchased], include_children: params[:include_children], - } + }.merge(params.slice(:start_datetime, :end_datetime)) get_all_helper('shipments', MODEL_CLASS, params, filters) end diff --git a/lib/easypost/services/tracker.rb b/lib/easypost/services/tracker.rb index 4e43fe18..2867d179 100644 --- a/lib/easypost/services/tracker.rb +++ b/lib/easypost/services/tracker.rb @@ -24,7 +24,7 @@ def all(params = {}) key: 'trackers', tracking_code: params[:tracking_code], carrier: params[:carrier], - } + }.merge(params.slice(:start_datetime, :end_datetime)) get_all_helper('trackers', MODEL_CLASS, params, filters) end diff --git a/lib/easypost/services/user.rb b/lib/easypost/services/user.rb index 9a850053..46225f81 100644 --- a/lib/easypost/services/user.rb +++ b/lib/easypost/services/user.rb @@ -49,7 +49,7 @@ def update_brand(id, params = {}) # Retrieve all child Users. def all_children(params = {}) - filters = { key: 'children' } + filters = { key: 'children' }.merge(params.slice(:start_datetime, :end_datetime)) get_all_helper('users/children', EasyPost::Models::User, params, filters) end @@ -60,6 +60,7 @@ def get_next_page_of_children(collection, page_size = nil) params = { after_id: collection.children.last.id } params[:page_size] = page_size unless page_size.nil? + params.merge!(collection[EasyPost::InternalUtilities::Constants::FILTERS_KEY]).delete(:key) all_children(params) end From 6dbb1a7967cf6ffc4eff564560004a9c16995242 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Mon, 30 Nov 2026 09:47:09 -0700 Subject: [PATCH 3/3] fix: only keep filters the API applies on next pages --- CHANGELOG.md | 3 ++- lib/easypost/services/address.rb | 3 +-- lib/easypost/services/claim.rb | 2 +- lib/easypost/services/referral_customer.rb | 3 +-- lib/easypost/services/report.rb | 2 +- lib/easypost/services/tracker.rb | 2 +- lib/easypost/services/user.rb | 3 +-- spec/claim_spec.rb | 16 ++++++++++++++++ spec/report_spec.rb | 20 -------------------- spec/tracker_spec.rb | 16 ++++++++++++++++ 10 files changed, 40 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be0681bb..fd6b79f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ## Next Release -- Fixes `get_next_page` (addresses, claims, events, insurances, pickups, referral customers, refunds, reports, scan forms, shipments and trackers) and `get_next_page_of_children` dropping the `start_datetime` and `end_datetime` filters of the original list call +- Fixes `get_next_page` (claims, events, insurances, pickups, refunds, scan forms, shipments and trackers) dropping the `start_datetime` and `end_datetime` filters of the original `all` call +- Fixes `claim.get_next_page` dropping the `type` and `status` filters, and `tracker.get_next_page` dropping the `tracking_codes` filter, of the original `all` call ## v7.8.1 (2026-11-09) diff --git a/lib/easypost/services/address.rb b/lib/easypost/services/address.rb index 9025baa0..fa394b98 100644 --- a/lib/easypost/services/address.rb +++ b/lib/easypost/services/address.rb @@ -57,7 +57,7 @@ def retrieve(id) # Retrieve all Addresses. def all(params = {}) - filters = { key: 'addresses' }.merge(params.slice(:start_datetime, :end_datetime)) + filters = { key: 'addresses' } get_all_helper('addresses', MODEL_CLASS, params, filters) end @@ -68,7 +68,6 @@ def get_next_page(collection, page_size = nil) params = { before_id: collection.addresses.last.id } params[:page_size] = page_size unless page_size.nil? - params.merge!(collection[EasyPost::InternalUtilities::Constants::FILTERS_KEY]).delete(:key) all(params) end diff --git a/lib/easypost/services/claim.rb b/lib/easypost/services/claim.rb index 7f5147e2..9e30acff 100644 --- a/lib/easypost/services/claim.rb +++ b/lib/easypost/services/claim.rb @@ -19,7 +19,7 @@ def retrieve(id) # Retrieve all Claim objects def all(params = {}) - filters = { key: 'claims' }.merge(params.slice(:start_datetime, :end_datetime)) + filters = { key: 'claims' }.merge(params.slice(:type, :status, :start_datetime, :end_datetime)) get_all_helper('claims', MODEL_CLASS, params, filters) end diff --git a/lib/easypost/services/referral_customer.rb b/lib/easypost/services/referral_customer.rb index 22d709de..507d1367 100644 --- a/lib/easypost/services/referral_customer.rb +++ b/lib/easypost/services/referral_customer.rb @@ -25,7 +25,7 @@ def update_email(user_id, email) # Retrieve a list of referral customers. This function requires the Partner User's API key. def all(params = {}) - filters = { key: 'referral_customers' }.merge(params.slice(:start_datetime, :end_datetime)) + filters = { key: 'referral_customers' } get_all_helper('referral_customers', MODEL_CLASS, params, filters) end @@ -36,7 +36,6 @@ def get_next_page(collection, page_size = nil) params = { before_id: collection.referral_customers.last.id } params[:page_size] = page_size unless page_size.nil? - params.merge!(collection[EasyPost::InternalUtilities::Constants::FILTERS_KEY]).delete(:key) all(params) end diff --git a/lib/easypost/services/report.rb b/lib/easypost/services/report.rb index e166a207..4fcd0e52 100644 --- a/lib/easypost/services/report.rb +++ b/lib/easypost/services/report.rb @@ -33,7 +33,7 @@ def all(params = {}) filters = { key: 'reports', type: type, - }.merge(params.slice(:start_datetime, :end_datetime)) + } url = "reports/#{type}" response = get_all_helper(url, MODEL_CLASS, params, filters) response.define_singleton_method(:type) { type } diff --git a/lib/easypost/services/tracker.rb b/lib/easypost/services/tracker.rb index 2867d179..92c84926 100644 --- a/lib/easypost/services/tracker.rb +++ b/lib/easypost/services/tracker.rb @@ -24,7 +24,7 @@ def all(params = {}) key: 'trackers', tracking_code: params[:tracking_code], carrier: params[:carrier], - }.merge(params.slice(:start_datetime, :end_datetime)) + }.merge(params.slice(:tracking_codes, :start_datetime, :end_datetime)) get_all_helper('trackers', MODEL_CLASS, params, filters) end diff --git a/lib/easypost/services/user.rb b/lib/easypost/services/user.rb index 46225f81..9a850053 100644 --- a/lib/easypost/services/user.rb +++ b/lib/easypost/services/user.rb @@ -49,7 +49,7 @@ def update_brand(id, params = {}) # Retrieve all child Users. def all_children(params = {}) - filters = { key: 'children' }.merge(params.slice(:start_datetime, :end_datetime)) + filters = { key: 'children' } get_all_helper('users/children', EasyPost::Models::User, params, filters) end @@ -60,7 +60,6 @@ def get_next_page_of_children(collection, page_size = nil) params = { after_id: collection.children.last.id } params[:page_size] = page_size unless page_size.nil? - params.merge!(collection[EasyPost::InternalUtilities::Constants::FILTERS_KEY]).delete(:key) all_children(params) end diff --git a/spec/claim_spec.rb b/spec/claim_spec.rb index ea369c53..19c67bfc 100644 --- a/spec/claim_spec.rb +++ b/spec/claim_spec.rb @@ -71,6 +71,22 @@ expect(e.message).to eq(EasyPost::Constants::NO_MORE_PAGES) end end + + it 'keeps the type and status filters of the original call' do + allow(client).to receive(:make_request).and_return( + { 'claims' => [{ 'id' => 'clm_123', 'object' => 'Claim' }], 'has_more' => true }, + ) + + first_page = client.claim.all(type: 'damage', status: 'submitted') + client.claim.get_next_page(first_page) + + expect(client).to have_received(:make_request).with( + :get, + 'claims', + hash_including(before_id: 'clm_123', type: 'damage', status: 'submitted'), + anything, + ) + end end describe '.cancel' do diff --git a/spec/report_spec.rb b/spec/report_spec.rb index 871126a9..6913f5b2 100644 --- a/spec/report_spec.rb +++ b/spec/report_spec.rb @@ -101,25 +101,5 @@ expect(e.message).to eq(EasyPost::Constants::NO_MORE_PAGES) end end - - it 'keeps the date filters of the original call' do - allow(client).to receive(:make_request).and_return( - { 'reports' => [{ 'id' => 'shprep_123', 'object' => 'Report' }], 'has_more' => true }, - ) - - first_page = client.report.all( - type: 'shipment', - start_datetime: '2026-01-01', - end_datetime: '2026-01-31', - ) - client.report.get_next_page(first_page) - - expect(client).to have_received(:make_request).with( - :get, - 'reports/shipment', - hash_including(before_id: 'shprep_123', start_datetime: '2026-01-01', end_datetime: '2026-01-31'), - anything, - ) - end end end diff --git a/spec/tracker_spec.rb b/spec/tracker_spec.rb index 9b83e7ec..b74f1ece 100644 --- a/spec/tracker_spec.rb +++ b/spec/tracker_spec.rb @@ -96,6 +96,22 @@ expect(e.message).to eq(EasyPost::Constants::NO_MORE_PAGES) end end + + it 'keeps the tracking codes filter of the original call' do + allow(client).to receive(:make_request).and_return( + { 'trackers' => [{ 'id' => 'trk_123', 'object' => 'Tracker' }], 'has_more' => true }, + ) + + first_page = client.tracker.all(tracking_codes: ['EZ1000000001']) + client.tracker.get_next_page(first_page) + + expect(client).to have_received(:make_request).with( + :get, + 'trackers', + hash_including(before_id: 'trk_123', tracking_codes: ['EZ1000000001']), + anything, + ) + end end describe '.delete' do