Skip to content

Commit 152c000

Browse files
authored
Merge pull request #252 from EasyPost/all_pickups
feat: add retrieve all pickups
2 parents c377276 + 3fcf608 commit 152c000

File tree

4 files changed

+161
-2
lines changed

4 files changed

+161
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## Next Release
4+
5+
- Adds `all` function to `Pickup` to retrieve all pickups
6+
37
## v7.8.0 (2023-01-11)
48

59
- Adds new beta billing functionality for ReferralCustomer users

easypost/pickup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
RequestMethod,
55
Requestor,
66
)
7-
from easypost.resource import CreateResource
7+
from easypost.resource import (
8+
AllResource,
9+
CreateResource,
10+
)
811
from easypost.util import get_lowest_object_rate
912

1013

11-
class Pickup(CreateResource):
14+
class Pickup(CreateResource, AllResource):
1215
def buy(self, **params) -> "Pickup":
1316
"""Buy a pickup."""
1417
requestor = Requestor(local_api_key=self._api_key)

tests/cassettes/test_pickup_all.yaml

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

tests/test_pickup.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ def test_pickup_create(one_call_buy_shipment, basic_pickup):
1717
assert pickup.pickup_rates is not None
1818

1919

20+
@pytest.mark.vcr()
21+
def test_pickup_all(page_size):
22+
pickups = easypost.Pickup.all(page_size=page_size)
23+
24+
pickup_array = pickups["pickups"]
25+
26+
assert len(pickup_array) <= page_size
27+
assert pickups["has_more"] is not None
28+
assert all(isinstance(pickup, easypost.Pickup) for pickup in pickup_array)
29+
30+
2031
@pytest.mark.vcr()
2132
def test_pickup_retrieve(one_call_buy_shipment, basic_pickup):
2233
shipment = easypost.Shipment.create(**one_call_buy_shipment)

0 commit comments

Comments
 (0)