From 201d18f5eabe477a7d659486bff92372b6278bc4 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Tue, 20 Aug 2024 14:11:23 +0200 Subject: [PATCH] [api] Remove the params argument from FulfillmentOrder#cancel() --- resources/fulfillment-order.js | 7 +- .../fulfillment-order/req/cancel.json | 50 -------------- test/fixtures/fulfillment-order/req/index.js | 1 - .../fulfillment-order/res/cancel.json | 65 ++++++++++--------- test/fulfillment-order.test.js | 5 +- types/index.d.ts | 5 +- 6 files changed, 40 insertions(+), 93 deletions(-) delete mode 100644 test/fixtures/fulfillment-order/req/cancel.json diff --git a/resources/fulfillment-order.js b/resources/fulfillment-order.js index cd187a3e..730f620e 100644 --- a/resources/fulfillment-order.js +++ b/resources/fulfillment-order.js @@ -41,13 +41,14 @@ FulfillmentOrder.prototype.list = function list(params) { * Marks a fulfillment order as cancelled. * * @param {Number} id Fulfillment order ID - * @param {Object} params Fulfillment order properties * @return {Promise} Promise that resolves with the result * @public */ -FulfillmentOrder.prototype.cancel = function cancel(id, params) { +FulfillmentOrder.prototype.cancel = function cancel(id) { const url = this.buildUrl(`${id}/cancel`); - return this.shopify.request(url, 'POST', this.key, params); + return this.shopify + .request(url, 'POST', undefined, {}) + .then((body) => body[this.key]); }; /** diff --git a/test/fixtures/fulfillment-order/req/cancel.json b/test/fixtures/fulfillment-order/req/cancel.json deleted file mode 100644 index 25931b7a..00000000 --- a/test/fixtures/fulfillment-order/req/cancel.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "fulfillment_order": { - "id": 1025578640, - "shop_id": 690933842, - "order_id": 450789469, - "assigned_location_id": 48752903, - "fulfillment_service_handle": "mars-fulfillment", - "request_status": "submitted", - "status": "open", - "supported_actions": ["cancel_fulfillment_order"], - "destination": { - "id": 1025578634, - "address1": "Chestnut Street 92", - "address2": "", - "city": "Louisville", - "company": null, - "country": "United States", - "email": "bob.norman@hostmail.com", - "first_name": "Bob", - "last_name": "Norman", - "phone": "555-625-1199", - "province": "Kentucky", - "zip": "40202" - }, - "line_items": [ - { - "id": 1025578653, - "shop_id": 690933842, - "fulfillment_order_id": 1025578640, - "quantity": 1, - "line_item_id": 518995019, - "inventory_item_id": 49148385, - "fulfillable_quantity": 1, - "variant_id": 49148385 - } - ], - "assigned_location": { - "address1": null, - "address2": null, - "city": null, - "country_code": "DE", - "location_id": 48752903, - "name": "Apple Api Shipwire", - "phone": null, - "province": null, - "zip": null - }, - "merchant_requests": [] - } -} diff --git a/test/fixtures/fulfillment-order/req/index.js b/test/fixtures/fulfillment-order/req/index.js index 50acf82c..6dc7beab 100644 --- a/test/fixtures/fulfillment-order/req/index.js +++ b/test/fixtures/fulfillment-order/req/index.js @@ -1,6 +1,5 @@ 'use strict'; -exports.cancel = require('./cancel'); exports.close = require('./close'); exports.hold = require('./hold'); exports.move = require('./move'); diff --git a/test/fixtures/fulfillment-order/res/cancel.json b/test/fixtures/fulfillment-order/res/cancel.json index bf0a2aa4..2175ede0 100644 --- a/test/fixtures/fulfillment-order/res/cancel.json +++ b/test/fixtures/fulfillment-order/res/cancel.json @@ -1,45 +1,40 @@ { "fulfillment_order": { - "id": 1025578640, - "shop_id": 690933842, + "id": 1046000791, + "shop_id": 548380009, "order_id": 450789469, - "assigned_location_id": 48752903, - "fulfillment_service_handle": "mars-fulfillment", + "assigned_location_id": 24826418, "request_status": "submitted", "status": "closed", + "fulfill_at": null, "supported_actions": [], "destination": { - "id": 1025578634, + "id": 1046000791, "address1": "Chestnut Street 92", "address2": "", "city": "Louisville", "company": null, "country": "United States", - "email": "bob.norman@hostmail.com", + "email": "bob.norman@mail.example.com", "first_name": "Bob", "last_name": "Norman", - "phone": "555-625-1199", + "phone": "+1(502)-459-2181", "province": "Kentucky", "zip": "40202" }, - "line_items": [ - { - "id": 1025578653, - "shop_id": 690933842, - "fulfillment_order_id": 1025578640, - "quantity": 1, - "line_item_id": 518995019, - "inventory_item_id": 49148385, - "fulfillable_quantity": 1, - "variant_id": 49148385 - } - ], + "line_items": [], + "international_duties": null, + "fulfillment_holds": [], + "fulfill_by": null, + "created_at": "2024-07-24T06:26:35-04:00", + "updated_at": "2024-07-24T06:26:36-04:00", + "delivery_method": null, "assigned_location": { "address1": null, "address2": null, "city": null, "country_code": "DE", - "location_id": 48752903, + "location_id": 24826418, "name": "Apple Api Shipwire", "phone": null, "province": null, @@ -48,33 +43,33 @@ "merchant_requests": [] }, "replacement_fulfillment_order": { - "id": 1025578641, - "shop_id": 690933842, + "id": 1046000792, + "shop_id": 548380009, "order_id": 450789469, - "assigned_location_id": 48752903, - "fulfillment_service_handle": "mars-fulfillment", + "assigned_location_id": 24826418, "request_status": "unsubmitted", "status": "open", - "supported_actions": ["request_fulfillment", "create_fulfillment"], + "fulfill_at": null, + "supported_actions": ["request_fulfillment", "hold"], "destination": { - "id": 1025578635, + "id": 1046000792, "address1": "Chestnut Street 92", "address2": "", "city": "Louisville", "company": null, "country": "United States", - "email": "bob.norman@hostmail.com", + "email": "bob.norman@mail.example.com", "first_name": "Bob", "last_name": "Norman", - "phone": "555-625-1199", + "phone": "+1(502)-459-2181", "province": "Kentucky", "zip": "40202" }, "line_items": [ { - "id": 1025578654, - "shop_id": 690933842, - "fulfillment_order_id": 1025578641, + "id": 1058737495, + "shop_id": 548380009, + "fulfillment_order_id": 1046000792, "quantity": 1, "line_item_id": 518995019, "inventory_item_id": 49148385, @@ -82,12 +77,18 @@ "variant_id": 49148385 } ], + "international_duties": null, + "fulfillment_holds": [], + "fulfill_by": null, + "created_at": "2024-07-24T06:26:36-04:00", + "updated_at": "2024-07-24T06:26:36-04:00", + "delivery_method": null, "assigned_location": { "address1": null, "address2": null, "city": null, "country_code": "DE", - "location_id": 48752903, + "location_id": 24826418, "name": "Apple Api Shipwire", "phone": null, "province": null, diff --git a/test/fulfillment-order.test.js b/test/fulfillment-order.test.js index d38d37db..f376f807 100644 --- a/test/fulfillment-order.test.js +++ b/test/fulfillment-order.test.js @@ -40,15 +40,14 @@ describe('Shopify#fulfillmentOrder', () => { }); it('cancels a fulfillment order', () => { - const input = fixtures.req.cancel; const output = fixtures.res.cancel; scope - .post('/admin/fulfillment_orders/1025578640/cancel.json', input) + .post('/admin/fulfillment_orders/1046000791/cancel.json', {}) .reply(200, output); return shopify.fulfillmentOrder - .cancel(1025578640, input.fulfillment_order) + .cancel(1046000791) .then((data) => expect(data).to.deep.equal(output.fulfillment_order)); }); diff --git a/types/index.d.ts b/types/index.d.ts index 0d3f77d4..f1f54dff 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -371,10 +371,7 @@ declare class Shopify { ) => Promise; }; fulfillmentOrder: { - cancel: ( - id: number, - params: Shopify.IFulfillmentOrder - ) => Promise; + cancel: (id: number) => Promise; close: (id: number, message?: string) => Promise; fulfillments: ( id: number