Skip to content

Commit 2b752fb

Browse files
authored
feat: Add function in retrieve all pickups (#238)
- Add (enable) function to retrieve all pickups - Add (enable) unit test to test retrieving all pickups
1 parent 93a1750 commit 2b752fb

File tree

4 files changed

+93
-7
lines changed

4 files changed

+93
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [Unreleased]
44

5+
- Added function to retrieve all pickups, accessible via `EasyPost::Pickup.all`
56
- Added payload functions `retrieve_all_payloads` and `retrieve_payload` to retrieve all payloads or a specific payload for an event.
67

78
## v4.10.0 (2023-01-11)

lib/easypost/pickup.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ def cancel(params = {})
2525
self
2626
end
2727

28-
# Retrieve a list of all Pickup objects.
29-
def self.all(_filters = {}, _api_key = nil)
30-
raise NotImplementedError.new('Pickup.all not implemented.')
31-
end
32-
3328
# Get the lowest rate of a Pickup (can exclude by having `'!'` as the first element of your optional filter lists).
3429
def lowest_rate(carriers = [], services = [])
3530
EasyPost::Util.get_lowest_object_rate(self, carriers, services, 'pickup_rates')

spec/cassettes/pickup/EasyPost_Pickup_all_retrieves_all_pickups.yml

Lines changed: 82 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/pickup_spec.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,16 @@
3535
end
3636

3737
describe '.all' do
38-
it 'raises not implemented error' do
39-
expect { described_class.all }.to raise_error(NotImplementedError)
38+
it 'retrieves all pickups' do
39+
pickups = described_class.all(
40+
page_size: Fixture.page_size,
41+
)
42+
43+
pickups_array = pickups.pickups
44+
45+
expect(pickups_array.count).to be <= Fixture.page_size
46+
expect(pickups.has_more).not_to be_nil
47+
expect(pickups_array).to all(be_an_instance_of(described_class))
4048
end
4149
end
4250

0 commit comments

Comments
 (0)