From 67885b97e14660f644bf2a44a3716ccf61b96bfd Mon Sep 17 00:00:00 2001 From: jchen293 Date: Tue, 28 Nov 2023 17:41:49 -0500 Subject: [PATCH] remove create_and_buy from batch --- CHANGELOG.md | 1 + easypost/services/batch_service.py | 9 -- .../cassettes/test_batch_create_and_buy.yaml | 88 ------------------- tests/test_batch.py | 14 --- 4 files changed, 1 insertion(+), 111 deletions(-) delete mode 100644 tests/cassettes/test_batch_create_and_buy.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 55533e34..e89a2681 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Next major release - Removed `withCarbonOffset` parameter from `create`, `buy`, and `regenerateRates` functions of the Shipment service as EasyPost now offers Carbon Neutral shipments by default for free +- Removed the undocumented `createAndBuy` function from the `Batch` service. The proper usage is to create a batch first and buy it separately ## v8.2.1 (2023-10-30) diff --git a/easypost/services/batch_service.py b/easypost/services/batch_service.py index ee97d084..ac08efcd 100644 --- a/easypost/services/batch_service.py +++ b/easypost/services/batch_service.py @@ -34,15 +34,6 @@ def retrieve(self, id: str) -> Batch: """Retrieve a Batch.""" return self._retrieve_resource(self._model_class, id) - def create_and_buy(self, **params) -> Batch: - """Create and buy a Batch in a single call.""" - url = f"{self._class_url(self._model_class)}/create_and_buy" - wrapped_params = {self._snakecase_name(self._model_class): params} - - response = Requestor(self._client).request(method=RequestMethod.POST, url=url, params=wrapped_params) - - return convert_to_easypost_object(response=response) - def buy(self, id: str, **params) -> Batch: """Buy a Batch.""" url = f"{self._instance_url(self._model_class, id)}/buy" diff --git a/tests/cassettes/test_batch_create_and_buy.yaml b/tests/cassettes/test_batch_create_and_buy.yaml deleted file mode 100644 index 28f44639..00000000 --- a/tests/cassettes/test_batch_create_and_buy.yaml +++ /dev/null @@ -1,88 +0,0 @@ -interactions: -- request: - body: '{"batch": {"shipments": [{"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_b25657e9896e4d63ac8151ac346ac41e"], - "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_b25657e9896e4d63ac8151ac346ac41e"], - "carrier": "USPS"}]}}' - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '1194' - Content-Type: - - application/json - authorization: - - - user-agent: - - - method: POST - uri: https://api.easypost.com/v2/batches/create_and_buy - response: - body: - string: '{"id": "batch_8122884150284dbe91a723679df2f67f", "object": "Batch", - "mode": "test", "state": "creating", "num_shipments": 2, "reference": null, - "created_at": "2023-05-12T19:30:44Z", "updated_at": "2023-05-12T19:30:44Z", - "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}' - headers: - cache-control: - - private, no-cache, no-store - content-length: - - '384' - content-type: - - application/json; charset=utf-8 - etag: - - W/"5c3d65ef5c3db7c880dc9d64a3975068" - expires: - - '0' - pragma: - - no-cache - referrer-policy: - - strict-origin-when-cross-origin - strict-transport-security: - - max-age=31536000; includeSubDomains; preload - transfer-encoding: - - chunked - x-backend: - - easypost - x-content-type-options: - - nosniff - x-download-options: - - noopen - x-ep-request-uuid: - - 52975b55645e93e4e2cc317f000622cf - x-frame-options: - - SAMEORIGIN - x-node: - - bigweb2nuq - x-permitted-cross-domain-policies: - - none - x-proxied: - - intlb2nuq a29e4ad05c - - extlb2nuq 5ab12a3ed2 - x-runtime: - - '0.047490' - x-version-label: - - easypost-202305121849-b449e9bf47-master - x-xss-protection: - - 1; mode=block - status: - code: 200 - message: OK -version: 1 diff --git a/tests/test_batch.py b/tests/test_batch.py index c5eec856..c0d38b5e 100644 --- a/tests/test_batch.py +++ b/tests/test_batch.py @@ -37,20 +37,6 @@ def test_batch_all(page_size, test_client): assert all(isinstance(batch, Batch) for batch in batches_array) -@pytest.mark.vcr() -def test_batch_create_and_buy(one_call_buy_shipment, test_client): - batch = test_client.batch.create_and_buy( - shipments=[ - one_call_buy_shipment, - one_call_buy_shipment, - ], - ) - - assert isinstance(batch, Batch) - assert str.startswith(batch.id, "batch_") - assert batch.num_shipments == 2 - - @pytest.mark.vcr() def test_batch_buy(one_call_buy_shipment, test_client, synchronous_sleep_seconds): function_name = inspect.stack()[0][3]