Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## Next Release

- 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)

- Fixes response hooks raising `NameError` when an HTTP body is not JSON
Expand Down
3 changes: 2 additions & 1 deletion lib/easypost/services/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def retrieve(id)

# Retrieve all Claim objects
def all(params = {})
filters = { key: 'claims' }
filters = { key: 'claims' }.merge(params.slice(:type, :status, :start_datetime, :end_datetime))

get_all_helper('claims', MODEL_CLASS, params, filters)
end
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/easypost/services/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/easypost/services/insurance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/easypost/services/pickup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/easypost/services/refund.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/easypost/services/scan_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/easypost/services/shipment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/easypost/services/tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def all(params = {})
key: 'trackers',
tracking_code: params[:tracking_code],
carrier: params[:carrier],
}
}.merge(params.slice(:tracking_codes, :start_datetime, :end_datetime))

get_all_helper('trackers', MODEL_CLASS, params, filters)
end
Expand Down
16 changes: 16 additions & 0 deletions spec/claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions spec/tracker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading