From 676653dbf68c61b7cf93d49d167a2f21143d1299 Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Fri, 1 Dec 2023 14:51:04 -0700 Subject: [PATCH] - Remove `createAndBuy` function (#424) --- CHANGELOG.md | 1 + src/services/batch_service.js | 19 -- .../recording.har | 171 ------------------ test/services/batch.test.js | 10 - 4 files changed, 1 insertion(+), 200 deletions(-) delete mode 100644 test/cassettes/Batch-Service_3950244400/creates-and-buys-a-batch-in-a-single-call_1654959317/recording.har diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ed593a94..dbe24fc91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Remove `withCarbonOffset` parameter from shipment create and buy functions - Remove `carbon_offset` property of `Rate` object - Fixes a pagination issue by passing along additional params used when fetching first page +- Remove `createAndBuy` function from `Batch` service (deprecated endpoint server-side) ## v6.8.2 (2023-10-20) diff --git a/src/services/batch_service.js b/src/services/batch_service.js index 010d3bee9..5db04c49f 100644 --- a/src/services/batch_service.js +++ b/src/services/batch_service.js @@ -105,25 +105,6 @@ export default (easypostClient) => } } - /** - * Create and purchase a {@link Batch batch} in a single request. - * See {@link https://www.easypost.com/docs/api/node#batches EasyPost API Documentation} for more information. - * @param {Object} params - Parameters for the batch to be created and purchased. - * @returns {Batch} - The created and purchased batch. - */ - static async createAndBuy(params) { - const url = `batches/create_and_buy`; - const wrappedParams = { batch: params }; - - try { - const response = await easypostClient._post(url, wrappedParams); - - return this._convertToEasyPostObject(response.body, wrappedParams); - } catch (e) { - return Promise.reject(e); - } - } - /** * Purchase a {@link Batch batch}. * See {@link https://www.easypost.com/docs/api/node#buy-a-batch EasyPost API Documentation} for more information. diff --git a/test/cassettes/Batch-Service_3950244400/creates-and-buys-a-batch-in-a-single-call_1654959317/recording.har b/test/cassettes/Batch-Service_3950244400/creates-and-buys-a-batch-in-a-single-call_1654959317/recording.har deleted file mode 100644 index 9b79eee38..000000000 --- a/test/cassettes/Batch-Service_3950244400/creates-and-buys-a-batch-in-a-single-call_1654959317/recording.har +++ /dev/null @@ -1,171 +0,0 @@ -{ - "log": { - "_recordingName": "Batch Service/creates and buys a batch in a single call", - "creator": { - "comment": "persister:fs", - "name": "Polly.JS", - "version": "6.0.5" - }, - "entries": [ - { - "_id": "409fdbc7fb780af596ae10df047a212b", - "_order": 0, - "cache": {}, - "request": { - "bodySize": 1091, - "cookies": [], - "headers": [ - { - "name": "accept-encoding", - "value": "gzip, deflate" - }, - { - "name": "accept", - "value": "application/json" - }, - { - "name": "content-type", - "value": "application/json" - }, - { - "name": "content-length", - "value": 1091 - }, - { - "name": "host", - "value": "api.easypost.com" - } - ], - "headersSize": 404, - "httpVersion": "HTTP/1.1", - "method": "POST", - "postData": { - "mimeType": "application/json", - "params": [], - "text": "{\"batch\":{\"shipments\":[{\"to_address\":{\"name\":\"Elizabeth Swan\",\"street1\":\"179 N Harbor Dr\",\"city\":\"Redondo Beach\",\"state\":\"CA\",\"zip\":\"90277\",\"country\":\"US\",\"email\":\"test@example.com\",\"phone\":\"5555555555\"},\"from_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\"},\"parcel\":{\"length\":10,\"width\":8,\"height\":4,\"weight\":15.4},\"service\":\"First\",\"carrier_accounts\":[\"ca_5ba7ca3632c54adeb17ad4bcac13c890\"],\"carrier\":\"USPS\"},{\"to_address\":{\"name\":\"Elizabeth Swan\",\"street1\":\"179 N Harbor Dr\",\"city\":\"Redondo Beach\",\"state\":\"CA\",\"zip\":\"90277\",\"country\":\"US\",\"email\":\"test@example.com\",\"phone\":\"5555555555\"},\"from_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\"},\"parcel\":{\"length\":10,\"width\":8,\"height\":4,\"weight\":15.4},\"service\":\"First\",\"carrier_accounts\":[\"ca_5ba7ca3632c54adeb17ad4bcac13c890\"],\"carrier\":\"USPS\"}]}}" - }, - "queryString": [], - "url": "https://api.easypost.com/v2/batches/create_and_buy" - }, - "response": { - "bodySize": 339, - "content": { - "encoding": "base64", - "mimeType": "application/json; charset=utf-8", - "size": 339, - "text": "{\"id\":\"batch_152f12e958674281b3e514af42b9b512\",\"object\":\"Batch\",\"mode\":\"test\",\"state\":\"creating\",\"num_shipments\":2,\"reference\":null,\"created_at\":\"2023-09-06T17:44:31Z\",\"updated_at\":\"2023-09-06T17:44:31Z\",\"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}" - }, - "cookies": [], - "headers": [ - { - "name": "x-frame-options", - "value": "SAMEORIGIN" - }, - { - "name": "x-xss-protection", - "value": "1; mode=block" - }, - { - "name": "x-content-type-options", - "value": "nosniff" - }, - { - "name": "x-download-options", - "value": "noopen" - }, - { - "name": "x-permitted-cross-domain-policies", - "value": "none" - }, - { - "name": "referrer-policy", - "value": "strict-origin-when-cross-origin" - }, - { - "name": "x-ep-request-uuid", - "value": "b9d2c49764f8ba7fe79afe8b001cc3c8" - }, - { - "name": "cache-control", - "value": "private, no-cache, no-store" - }, - { - "name": "pragma", - "value": "no-cache" - }, - { - "name": "expires", - "value": "0" - }, - { - "name": "content-type", - "value": "application/json; charset=utf-8" - }, - { - "name": "etag", - "value": "W/\"016088e65ddb7379f505dd29bb450ced\"" - }, - { - "name": "x-runtime", - "value": "0.042282" - }, - { - "name": "content-encoding", - "value": "gzip" - }, - { - "name": "transfer-encoding", - "value": "chunked" - }, - { - "name": "x-node", - "value": "bigweb43nuq" - }, - { - "name": "x-version-label", - "value": "easypost-202309052324-fe928dc813-master" - }, - { - "name": "x-backend", - "value": "easypost" - }, - { - "name": "x-canary", - "value": "direct" - }, - { - "name": "x-proxied", - "value": "intlb1nuq 2bcb349163, extlb2nuq 003ad9bca0" - }, - { - "name": "strict-transport-security", - "value": "max-age=31536000; includeSubDomains; preload" - }, - { - "name": "connection", - "value": "close" - } - ], - "headersSize": 772, - "httpVersion": "HTTP/1.1", - "redirectURL": "", - "status": 200, - "statusText": "OK" - }, - "startedDateTime": "2023-09-06T17:44:30.607Z", - "time": 658, - "timings": { - "blocked": -1, - "connect": -1, - "dns": -1, - "receive": 0, - "send": 0, - "ssl": -1, - "wait": 658 - } - } - ], - "pages": [], - "version": "1.2" - } -} diff --git a/test/services/batch.test.js b/test/services/batch.test.js index 0b0f26d15..954fa4c04 100644 --- a/test/services/batch.test.js +++ b/test/services/batch.test.js @@ -53,16 +53,6 @@ describe('Batch Service', function () { }); }); - it('creates and buys a batch in a single call', async function () { - const batch = await this.client.Batch.createAndBuy({ - shipments: [Fixture.oneCallBuyShipment(), Fixture.oneCallBuyShipment()], - }); - - expect(batch).to.be.an.instanceOf(Batch); - expect(batch.id).to.match(/^batch_/); - expect(batch.num_shipments).to.equal(2); - }); - it('buys a batch', async function () { const batch = await this.client.Batch.create({ shipments: [Fixture.oneCallBuyShipment()],