diff --git a/README.md b/README.md index 9ed827f..fffa84a 100644 --- a/README.md +++ b/README.md @@ -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)` @@ -489,6 +489,7 @@ default. - `locationsForMove(id)` - `move(id, locationId)` - `releaseHold(id)` + - `reschedule(id, deadline)` - `setFulfillmentOrdersDeadline(params)` - fulfillmentRequest - `accept(fulfillmentOrderId[, message])` diff --git a/resources/fulfillment-order.js b/resources/fulfillment-order.js index 878609e..cd187a3 100644 --- a/resources/fulfillment-order.js +++ b/resources/fulfillment-order.js @@ -159,4 +159,22 @@ FulfillmentOrder.prototype.releaseHold = function releaseHold(id) { .then((body) => body[this.key]); }; +/** + * Reschedules a scheduled fulfillment order. Updates the value of the + * `fulfill_at field` on a scheduled fulfillment order. The fulfillment order + * will be marked as ready for fulfillment at this date and time. + * + * @param {Number} id Fulfillment Order ID + * @param {String} deadline The new fulfillment deadline of the fulfillment + * order + * @return {Promise} Promise that resolves with the result + * @public + */ +FulfillmentOrder.prototype.reschedule = function reschedule(id, deadline) { + const url = this.buildUrl(`${id}/reschedule`); + return this.shopify.request(url, 'POST', this.key, { + new_fulfill_at: deadline + }); +}; + module.exports = FulfillmentOrder; diff --git a/test/fixtures/fulfillment-order/req/index.js b/test/fixtures/fulfillment-order/req/index.js index 6ed476d..50acf82 100644 --- a/test/fixtures/fulfillment-order/req/index.js +++ b/test/fixtures/fulfillment-order/req/index.js @@ -4,4 +4,5 @@ exports.cancel = require('./cancel'); exports.close = require('./close'); exports.hold = require('./hold'); exports.move = require('./move'); +exports.reschedule = require('./reschedule'); exports.setFulfillmentOrdersDeadline = require('./set-fulfillment-orders-deadline'); diff --git a/test/fixtures/fulfillment-order/req/reschedule.json b/test/fixtures/fulfillment-order/req/reschedule.json new file mode 100644 index 0000000..cced9fc --- /dev/null +++ b/test/fixtures/fulfillment-order/req/reschedule.json @@ -0,0 +1 @@ +{ "fulfillment_order": { "new_fulfill_at": "2025-08-24 10:26 UTC" } } diff --git a/test/fixtures/fulfillment-order/res/index.js b/test/fixtures/fulfillment-order/res/index.js index 621092d..b2cc035 100644 --- a/test/fixtures/fulfillment-order/res/index.js +++ b/test/fixtures/fulfillment-order/res/index.js @@ -9,3 +9,4 @@ exports.list = require('./list'); exports.locationsForMove = require('./locations-for-move'); exports.move = require('./move'); exports.releaseHold = require('./release-hold'); +exports.reschedule = require('./reschedule'); diff --git a/test/fixtures/fulfillment-order/res/reschedule.json b/test/fixtures/fulfillment-order/res/reschedule.json new file mode 100644 index 0000000..b67c40a --- /dev/null +++ b/test/fixtures/fulfillment-order/res/reschedule.json @@ -0,0 +1,56 @@ +{ + "fulfillment_order": { + "id": 1046000788, + "shop_id": 548380009, + "order_id": 450789469, + "assigned_location_id": 24826418, + "request_status": "unsubmitted", + "status": "scheduled", + "fulfill_at": "2025-08-24T06:26:00-04:00", + "supported_actions": ["mark_as_open"], + "destination": { + "id": 1046000788, + "address1": "Chestnut Street 92", + "address2": "", + "city": "Louisville", + "company": null, + "country": "United States", + "email": "bob.norman@mail.example.com", + "first_name": "Bob", + "last_name": "Norman", + "phone": "+1(502)-459-2181", + "province": "Kentucky", + "zip": "40202" + }, + "line_items": [ + { + "id": 1058737492, + "shop_id": 548380009, + "fulfillment_order_id": 1046000788, + "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:30-04:00", + "updated_at": "2024-07-24T06:26:32-04:00", + "delivery_method": null, + "assigned_location": { + "address1": null, + "address2": null, + "city": null, + "country_code": "DE", + "location_id": 24826418, + "name": "Apple Api Shipwire", + "phone": null, + "province": null, + "zip": null + }, + "merchant_requests": [] + } +} diff --git a/test/fulfillment-order.test.js b/test/fulfillment-order.test.js index f53d7d2..d38d37d 100644 --- a/test/fulfillment-order.test.js +++ b/test/fulfillment-order.test.js @@ -161,4 +161,19 @@ describe('Shopify#fulfillmentOrder', () => { expect(data).to.deep.equal(output.fulfillment_order); }); }); + + it('reschedules the fulfill_at time of a scheduled fulfillment order', () => { + const input = fixtures.req.reschedule; + const output = fixtures.res.reschedule; + + scope + .post('/admin/fulfillment_orders/1046000788/reschedule.json', input) + .reply(200, output); + + return shopify.fulfillmentOrder + .reschedule(1046000788, '2025-08-24 10:26 UTC') + .then((data) => { + expect(data).to.deep.equal(output.fulfillment_order); + }); + }); }); diff --git a/types/index.d.ts b/types/index.d.ts index 8078b22..0d3f77d 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -391,6 +391,10 @@ declare class Shopify { locationId: number ) => Promise; releaseHold: (id: number) => Promise; + reschedule: ( + id: number, + deadline: string + ) => Promise; setFulfillmentOrdersDeadline: ( params: Shopify.ISetFulfillmentOrdersDeadline ) => Promise;