Skip to content

Commit

Permalink
feat: Add function in retrieve all pickups (#238)
Browse files Browse the repository at this point in the history
- Add (enable) function to retrieve all pickups
- Add (enable) unit test to test retrieving all pickups
  • Loading branch information
nwithan8 authored Jan 17, 2023
1 parent 93a1750 commit 2b752fb
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

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

## v4.10.0 (2023-01-11)
Expand Down
5 changes: 0 additions & 5 deletions lib/easypost/pickup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ def cancel(params = {})
self
end

# Retrieve a list of all Pickup objects.
def self.all(_filters = {}, _api_key = nil)
raise NotImplementedError.new('Pickup.all not implemented.')
end

# Get the lowest rate of a Pickup (can exclude by having `'!'` as the first element of your optional filter lists).
def lowest_rate(carriers = [], services = [])
EasyPost::Util.get_lowest_object_rate(self, carriers, services, 'pickup_rates')
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions spec/pickup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,16 @@
end

describe '.all' do
it 'raises not implemented error' do
expect { described_class.all }.to raise_error(NotImplementedError)
it 'retrieves all pickups' do
pickups = described_class.all(
page_size: Fixture.page_size,
)

pickups_array = pickups.pickups

expect(pickups_array.count).to be <= Fixture.page_size
expect(pickups.has_more).not_to be_nil
expect(pickups_array).to all(be_an_instance_of(described_class))
end
end

Expand Down

0 comments on commit 2b752fb

Please sign in to comment.