Skip to content

Commit

Permalink
[api] Remove the params argument from FulfillmentOrder#cancel()
Browse files Browse the repository at this point in the history
  • Loading branch information
lpinca committed Aug 20, 2024
1 parent 9901908 commit 715d536
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 94 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ default.
- `list(orderId, fulfillmentId[, params])`
- `update(orderId, fulfillmentId, id, params)`
- fulfillmentOrder
- `cancel(id, params)`
- `cancel(id)`
- `close(id[, message])`
- `fulfillments(id)`
- `get(id)`
Expand Down
7 changes: 4 additions & 3 deletions resources/fulfillment-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
};

/**
Expand Down
50 changes: 0 additions & 50 deletions test/fixtures/fulfillment-order/req/cancel.json

This file was deleted.

1 change: 0 additions & 1 deletion test/fixtures/fulfillment-order/req/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

exports.cancel = require('./cancel');
exports.close = require('./close');
exports.hold = require('./hold');
exports.move = require('./move');
Expand Down
65 changes: 33 additions & 32 deletions test/fixtures/fulfillment-order/res/cancel.json
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -48,46 +43,52 @@
"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,
"fulfillable_quantity": 1,
"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,
Expand Down
5 changes: 2 additions & 3 deletions test/fulfillment-order.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});

Expand Down
5 changes: 1 addition & 4 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,7 @@ declare class Shopify {
) => Promise<Shopify.IFulfillmentEvent>;
};
fulfillmentOrder: {
cancel: (
id: number,
params: Shopify.IFulfillmentOrder
) => Promise<Shopify.IFulfillmentOrder>;
cancel: (id: number) => Promise<Shopify.IFulfillmentOrder>;
close: (id: number, message?: string) => Promise<Shopify.IFulfillmentOrder>;
fulfillments: (
id: number
Expand Down

0 comments on commit 715d536

Please sign in to comment.