Skip to content

Commit

Permalink
Merge pull request #321 from EasyPost/remove_create_and_buy_batch
Browse files Browse the repository at this point in the history
!chore: remove createAndBuy from Batch service
  • Loading branch information
Justintime50 authored Nov 28, 2023
2 parents 5e4c554 + d3804a5 commit 59bb044
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 126 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Removed `withCarbonOffset` parameter from `create`, `buy`, and `regenerateRates` functions of the Shipment service as EasyPost now offers Carbon Neutral shipments by default for free
- Fixes a bug where the original filtering criteria of `all` calls wasn't passed along to `getNextPage` calls. Now, these are persisted via a `_params` key on response objects locally
- Removes the undocumented `createAndBuy` function from the `Batch` service. The proper usage is to create a batch first and buy it separately

## v6.9.1 (2023-11-20)

Expand Down
31 changes: 0 additions & 31 deletions lib/EasyPost/Service/BatchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,37 +49,6 @@ public function create($params = null)
return self::createResource(self::serviceModelClassName(self::class), $params);
}

/**
* Create and buy a batch.
*
* @param mixed $params
* @return mixed
*/
public function createAndBuy($params = null)
{
if (!isset($params['batch']) || !is_array($params['batch'])) {
$clone = $params;
unset($params);

$shipments = [];

foreach ($clone as $index => $shipment) {
$shipments[$index] = $shipment;
}

$params = [
'batch' => [
'shipment' => $shipments,
],
];
}

$url = self::classUrl(self::serviceModelClassName(self::class));
$response = Requestor::request($this->client, 'post', $url . '/create_and_buy', $params);

return InternalUtil::convertToEasyPostObject($this->client, $response);
}

/**
* Buy a batch.
*
Expand Down
17 changes: 0 additions & 17 deletions test/EasyPost/BatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,6 @@ public function testAll()
$this->assertContainsOnlyInstancesOf(Batch::class, $batchesArray);
}

/**
* Test creating and buying a Batch in a single call.
*/
public function testCreateAndBuy()
{
TestUtil::setupCassette('batches/createAndBuy.yml');

$batch = self::$client->batch->createAndBuy([
Fixture::oneCallBuyShipment(),
Fixture::oneCallBuyShipment(),
]);

$this->assertInstanceOf(Batch::class, $batch);
$this->assertStringMatchesFormat('batch_%s', $batch->id);
$this->assertEquals(2, $batch->num_shipments);
}

/**
* Test buying a batch.
*/
Expand Down
78 changes: 0 additions & 78 deletions test/cassettes/batches/createAndBuy.yml

This file was deleted.

0 comments on commit 59bb044

Please sign in to comment.