Skip to content

Commit a631ce9

Browse files
authored
Merge pull request #341 from EasyPost/fix_pickup_buy_rate
fix: buying a pickup when providing a rate
2 parents dac0266 + e5b4212 commit a631ce9

File tree

10 files changed

+196
-201
lines changed

10 files changed

+196
-201
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Next Release
44

5+
- Fixes how params are passed to the API when buying a pickup and providing a pickup rate (closes #340)
6+
- Removes the unusable buy a pickup overload where no params are specified as `carrier` and `service` are required paramaters when buying a pickup
57
- Removes the deprecated `create_list` tracker endpoint function as it is no longer available via API
68

79
## v7.4.3 (2024-09-16)

src/main/java/com/easypost/service/PickupService.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,6 @@ public Pickup retrieve(final String id) throws EasyPostException {
9595
return Requestor.request(RequestMethod.GET, endpoint, null, Pickup.class, client);
9696
}
9797

98-
/**
99-
* Buy this Pickup.
100-
*
101-
* @param id The ID of pickup.
102-
* @return Pickup object.
103-
* @throws EasyPostException when the request fails.
104-
*/
105-
public Pickup buy(final String id) throws EasyPostException {
106-
// Pass in empty map to avoid method ambiguous.
107-
return this.buy(id, new HashMap<String, Object>());
108-
}
109-
11098
/**
11199
* Buy this Pickup.
112100
*
@@ -131,7 +119,8 @@ public Pickup buy(final String id, final Map<String, Object> params) throws Easy
131119
*/
132120
public Pickup buy(final String id, final PickupRate pickupRate) throws EasyPostException {
133121
Map<String, Object> params = new HashMap<String, Object>();
134-
params.put("rate", pickupRate);
122+
params.put("carrier", pickupRate.getCarrier());
123+
params.put("service", pickupRate.getService());
135124

136125
return this.buy(id, params);
137126
}

src/test/cassettes/pickup/buy.json

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

src/test/cassettes/pickup/buy_with_rate.json

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

src/test/cassettes/pickup/cancel.json

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

src/test/cassettes/pickup/create.json

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

src/test/cassettes/pickup/lowest_rate.json

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

src/test/cassettes/pickup/retrieve.json

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

src/test/java/com/easypost/Fixtures.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public static HashMap<String, Object> basicPickup() {
223223
* If you need to re-record cassettes, increment the date below and ensure it is one day in the future,
224224
* USPS only does "next-day" pickups including Saturday but not Sunday or Holidays.
225225
*/
226-
String pickupDate = "2024-08-18";
226+
String pickupDate = "2025-01-03";
227227

228228
fixture.put("min_datetime", pickupDate);
229229
fixture.put("max_datetime", pickupDate);

src/test/java/com/easypost/PickupTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ public void testBuy() throws EasyPostException, InterruptedException {
145145

146146
Pickup pickup = createBasicPickup();
147147

148-
Pickup boughtPickup = vcr.client.pickup.buy(pickup.getId());
148+
Map<String, Object> params = new HashMap<String, Object>();
149+
params.put("carrier", Fixtures.usps());
150+
params.put("service", Fixtures.pickupService());
151+
152+
Pickup boughtPickup = vcr.client.pickup.buy(pickup.getId(), params);
149153

150154
assertInstanceOf(Pickup.class, boughtPickup);
151155
assertTrue(boughtPickup.getId().startsWith("pickup_"));
@@ -154,7 +158,7 @@ public void testBuy() throws EasyPostException, InterruptedException {
154158
}
155159

156160
/**
157-
* Test buying a pickup with lowest rate.
161+
* Test buying a pickup by specifying a pickup rate.
158162
*
159163
* @throws EasyPostException when the request fails.
160164
*/

0 commit comments

Comments
 (0)