diff --git a/CHANGELOG.md b/CHANGELOG.md index b06c5e42..91336079 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/lib/EasyPost/Service/BatchService.php b/lib/EasyPost/Service/BatchService.php index 55104f4b..5297adaa 100644 --- a/lib/EasyPost/Service/BatchService.php +++ b/lib/EasyPost/Service/BatchService.php @@ -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. * diff --git a/test/EasyPost/BatchTest.php b/test/EasyPost/BatchTest.php index 30318cc5..0e583567 100644 --- a/test/EasyPost/BatchTest.php +++ b/test/EasyPost/BatchTest.php @@ -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. */ diff --git a/test/cassettes/batches/createAndBuy.yml b/test/cassettes/batches/createAndBuy.yml deleted file mode 100644 index ce39763f..00000000 --- a/test/cassettes/batches/createAndBuy.yml +++ /dev/null @@ -1,78 +0,0 @@ - -- - request: - method: POST - url: 'https://api.easypost.com/v2/batches/create_and_buy' - headers: - Host: api.easypost.com - Expect: '' - Accept-Encoding: '' - Accept: application/json - Authorization: '' - Content-Type: application/json - User-Agent: '' - body: '{"batch":{"shipment":[{"to_address":{"name":"Jack Sparrow","street1":"388 Townsend St","street2":"Apt 20","city":"San Francisco","state":"CA","zip":"94107","country":"US","email":"test@example.com","phone":"5555555555"},"from_address":{"name":"Elizabeth Swan","street1":"179 N Harbor Dr","city":"Redondo Beach","state":"CA","zip":"90277","country":"US","email":"test@example.com","phone":"5555555555"},"parcel":{"length":"10","width":"8","height":"4","weight":"15.4"},"service":"First","carrier_accounts":["ca_8dc116debcdb49b5a66a2ddee4612600"],"carrier":"USPS"},{"to_address":{"name":"Jack Sparrow","street1":"388 Townsend St","street2":"Apt 20","city":"San Francisco","state":"CA","zip":"94107","country":"US","email":"test@example.com","phone":"5555555555"},"from_address":{"name":"Elizabeth Swan","street1":"179 N Harbor Dr","city":"Redondo Beach","state":"CA","zip":"90277","country":"US","email":"test@example.com","phone":"5555555555"},"parcel":{"length":"10","width":"8","height":"4","weight":"15.4"},"service":"First","carrier_accounts":["ca_8dc116debcdb49b5a66a2ddee4612600"],"carrier":"USPS"}]}}' - response: - status: - http_version: '1.1' - code: '200' - message: OK - headers: - x-frame-options: SAMEORIGIN - x-xss-protection: '1; mode=block' - x-content-type-options: nosniff - x-download-options: noopen - x-permitted-cross-domain-policies: none - referrer-policy: strict-origin-when-cross-origin - x-ep-request-uuid: 6c53f872655e6545e7885e0b001f488e - cache-control: 'private, no-cache, no-store' - pragma: no-cache - expires: '0' - content-type: 'application/json; charset=utf-8' - content-length: '384' - x-runtime: '0.187486' - x-node: bigweb36nuq - x-version-label: easypost-202311212221-a0f06fbc2c-master - x-backend: easypost - x-proxied: ['intlb2nuq b3de2c47ef', 'extlb1nuq 003ad9bca0'] - strict-transport-security: 'max-age=31536000; includeSubDomains; preload' - body: '{"id":"batch_8d153e82588c434e81bb8e924f2fa16f","object":"Batch","mode":"test","state":"creating","num_shipments":2,"reference":null,"created_at":"2023-11-22T20:32:06Z","updated_at":"2023-11-22T20:32:06Z","scan_form":null,"shipments":[],"status":{"created":0,"queued_for_purchase":0,"creation_failed":0,"postage_purchased":0,"postage_purchase_failed":0},"pickup":null,"label_url":null}' - curl_info: - url: 'https://api.easypost.com/v2/batches/create_and_buy' - content_type: 'application/json; charset=utf-8' - http_code: 200 - header_size: 688 - request_size: 1428 - filetime: -1 - ssl_verify_result: 0 - redirect_count: 0 - total_time: 0.387721 - namelookup_time: 0.001467 - connect_time: 0.066625 - pretransfer_time: 0.13585 - size_upload: 1106.0 - size_download: 384.0 - speed_download: 990.0 - speed_upload: 2852.0 - download_content_length: 384.0 - upload_content_length: 1106.0 - starttransfer_time: 0.387706 - redirect_time: 0.0 - redirect_url: '' - primary_ip: 169.62.110.131 - certinfo: { } - primary_port: 443 - local_ip: 10.130.6.39 - local_port: 53589 - http_version: 2 - protocol: 2 - ssl_verifyresult: 0 - scheme: HTTPS - appconnect_time_us: 135769 - connect_time_us: 66625 - namelookup_time_us: 1467 - pretransfer_time_us: 135850 - redirect_time_us: 0 - starttransfer_time_us: 387706 - total_time_us: 387721 - index: 0