Skip to content

Commit 201d18f

Browse files
committed
[api] Remove the params argument from FulfillmentOrder#cancel()
1 parent 189cbb1 commit 201d18f

File tree

6 files changed

+40
-93
lines changed

6 files changed

+40
-93
lines changed

resources/fulfillment-order.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ FulfillmentOrder.prototype.list = function list(params) {
4141
* Marks a fulfillment order as cancelled.
4242
*
4343
* @param {Number} id Fulfillment order ID
44-
* @param {Object} params Fulfillment order properties
4544
* @return {Promise} Promise that resolves with the result
4645
* @public
4746
*/
48-
FulfillmentOrder.prototype.cancel = function cancel(id, params) {
47+
FulfillmentOrder.prototype.cancel = function cancel(id) {
4948
const url = this.buildUrl(`${id}/cancel`);
50-
return this.shopify.request(url, 'POST', this.key, params);
49+
return this.shopify
50+
.request(url, 'POST', undefined, {})
51+
.then((body) => body[this.key]);
5152
};
5253

5354
/**

test/fixtures/fulfillment-order/req/cancel.json

-50
This file was deleted.

test/fixtures/fulfillment-order/req/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
exports.cancel = require('./cancel');
43
exports.close = require('./close');
54
exports.hold = require('./hold');
65
exports.move = require('./move');

test/fixtures/fulfillment-order/res/cancel.json

+33-32
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,40 @@
11
{
22
"fulfillment_order": {
3-
"id": 1025578640,
4-
"shop_id": 690933842,
3+
"id": 1046000791,
4+
"shop_id": 548380009,
55
"order_id": 450789469,
6-
"assigned_location_id": 48752903,
7-
"fulfillment_service_handle": "mars-fulfillment",
6+
"assigned_location_id": 24826418,
87
"request_status": "submitted",
98
"status": "closed",
9+
"fulfill_at": null,
1010
"supported_actions": [],
1111
"destination": {
12-
"id": 1025578634,
12+
"id": 1046000791,
1313
"address1": "Chestnut Street 92",
1414
"address2": "",
1515
"city": "Louisville",
1616
"company": null,
1717
"country": "United States",
18-
"email": "bob.norman@hostmail.com",
18+
"email": "bob.norman@mail.example.com",
1919
"first_name": "Bob",
2020
"last_name": "Norman",
21-
"phone": "555-625-1199",
21+
"phone": "+1(502)-459-2181",
2222
"province": "Kentucky",
2323
"zip": "40202"
2424
},
25-
"line_items": [
26-
{
27-
"id": 1025578653,
28-
"shop_id": 690933842,
29-
"fulfillment_order_id": 1025578640,
30-
"quantity": 1,
31-
"line_item_id": 518995019,
32-
"inventory_item_id": 49148385,
33-
"fulfillable_quantity": 1,
34-
"variant_id": 49148385
35-
}
36-
],
25+
"line_items": [],
26+
"international_duties": null,
27+
"fulfillment_holds": [],
28+
"fulfill_by": null,
29+
"created_at": "2024-07-24T06:26:35-04:00",
30+
"updated_at": "2024-07-24T06:26:36-04:00",
31+
"delivery_method": null,
3732
"assigned_location": {
3833
"address1": null,
3934
"address2": null,
4035
"city": null,
4136
"country_code": "DE",
42-
"location_id": 48752903,
37+
"location_id": 24826418,
4338
"name": "Apple Api Shipwire",
4439
"phone": null,
4540
"province": null,
@@ -48,46 +43,52 @@
4843
"merchant_requests": []
4944
},
5045
"replacement_fulfillment_order": {
51-
"id": 1025578641,
52-
"shop_id": 690933842,
46+
"id": 1046000792,
47+
"shop_id": 548380009,
5348
"order_id": 450789469,
54-
"assigned_location_id": 48752903,
55-
"fulfillment_service_handle": "mars-fulfillment",
49+
"assigned_location_id": 24826418,
5650
"request_status": "unsubmitted",
5751
"status": "open",
58-
"supported_actions": ["request_fulfillment", "create_fulfillment"],
52+
"fulfill_at": null,
53+
"supported_actions": ["request_fulfillment", "hold"],
5954
"destination": {
60-
"id": 1025578635,
55+
"id": 1046000792,
6156
"address1": "Chestnut Street 92",
6257
"address2": "",
6358
"city": "Louisville",
6459
"company": null,
6560
"country": "United States",
66-
"email": "bob.norman@hostmail.com",
61+
"email": "bob.norman@mail.example.com",
6762
"first_name": "Bob",
6863
"last_name": "Norman",
69-
"phone": "555-625-1199",
64+
"phone": "+1(502)-459-2181",
7065
"province": "Kentucky",
7166
"zip": "40202"
7267
},
7368
"line_items": [
7469
{
75-
"id": 1025578654,
76-
"shop_id": 690933842,
77-
"fulfillment_order_id": 1025578641,
70+
"id": 1058737495,
71+
"shop_id": 548380009,
72+
"fulfillment_order_id": 1046000792,
7873
"quantity": 1,
7974
"line_item_id": 518995019,
8075
"inventory_item_id": 49148385,
8176
"fulfillable_quantity": 1,
8277
"variant_id": 49148385
8378
}
8479
],
80+
"international_duties": null,
81+
"fulfillment_holds": [],
82+
"fulfill_by": null,
83+
"created_at": "2024-07-24T06:26:36-04:00",
84+
"updated_at": "2024-07-24T06:26:36-04:00",
85+
"delivery_method": null,
8586
"assigned_location": {
8687
"address1": null,
8788
"address2": null,
8889
"city": null,
8990
"country_code": "DE",
90-
"location_id": 48752903,
91+
"location_id": 24826418,
9192
"name": "Apple Api Shipwire",
9293
"phone": null,
9394
"province": null,

test/fulfillment-order.test.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,14 @@ describe('Shopify#fulfillmentOrder', () => {
4040
});
4141

4242
it('cancels a fulfillment order', () => {
43-
const input = fixtures.req.cancel;
4443
const output = fixtures.res.cancel;
4544

4645
scope
47-
.post('/admin/fulfillment_orders/1025578640/cancel.json', input)
46+
.post('/admin/fulfillment_orders/1046000791/cancel.json', {})
4847
.reply(200, output);
4948

5049
return shopify.fulfillmentOrder
51-
.cancel(1025578640, input.fulfillment_order)
50+
.cancel(1046000791)
5251
.then((data) => expect(data).to.deep.equal(output.fulfillment_order));
5352
});
5453

types/index.d.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,7 @@ declare class Shopify {
371371
) => Promise<Shopify.IFulfillmentEvent>;
372372
};
373373
fulfillmentOrder: {
374-
cancel: (
375-
id: number,
376-
params: Shopify.IFulfillmentOrder
377-
) => Promise<Shopify.IFulfillmentOrder>;
374+
cancel: (id: number) => Promise<Shopify.IFulfillmentOrder>;
378375
close: (id: number, message?: string) => Promise<Shopify.IFulfillmentOrder>;
379376
fulfillments: (
380377
id: number

0 commit comments

Comments
 (0)