Skip to content

Commit dadedd2

Browse files
committed
[api] Add releaseHold action to FulfillmentOrder resource
1 parent 7803fa1 commit dadedd2

File tree

6 files changed

+97
-11
lines changed

6 files changed

+97
-11
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ default.
488488
- `list([params])`
489489
- `locationsForMove(id)`
490490
- `move(id, locationId)`
491+
- `releaseHold(id)`
491492
- `setFulfillmentOrdersDeadline(params)`
492493
- fulfillmentRequest
493494
- `accept(fulfillmentOrderId[, message])`

resources/fulfillment-order.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,19 @@ FulfillmentOrder.prototype.hold = function hold(id, params) {
144144
.then((body) => body[this.key]);
145145
};
146146

147+
/**
148+
* Release the fulfillment hold on a fulfillment order and changes the status of
149+
* the fulfillment order to `OPEN` or `SCHEDULED`.
150+
*
151+
* @param {Number} id Fulfillment Order ID
152+
* @return {Promise} Promise that resolves with the result
153+
* @public
154+
*/
155+
FulfillmentOrder.prototype.releaseHold = function releaseHold(id) {
156+
const url = this.buildUrl(`${id}/release_hold`);
157+
return this.shopify
158+
.request(url, 'POST', undefined, {})
159+
.then((body) => body[this.key]);
160+
};
161+
147162
module.exports = FulfillmentOrder;
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
'use strict';
22

3-
exports.locationsForMove = require('./locations-for-move');
4-
exports.fulfillments = require('./fulfillments');
53
exports.cancel = require('./cancel');
64
exports.close = require('./close');
7-
exports.list = require('./list');
8-
exports.move = require('./move');
5+
exports.fulfillments = require('./fulfillments');
96
exports.get = require('./get');
107
exports.hold = require('./hold');
8+
exports.list = require('./list');
9+
exports.locationsForMove = require('./locations-for-move');
10+
exports.move = require('./move');
11+
exports.releaseHold = require('./release-hold');
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"fulfillment_order": {
3+
"id": 1046000790,
4+
"shop_id": 548380009,
5+
"order_id": 450789469,
6+
"assigned_location_id": 24826418,
7+
"request_status": "submitted",
8+
"status": "open",
9+
"fulfill_at": null,
10+
"supported_actions": ["cancel_fulfillment_order"],
11+
"destination": {
12+
"id": 1046000790,
13+
"address1": "Chestnut Street 92",
14+
"address2": "",
15+
"city": "Louisville",
16+
"company": null,
17+
"country": "United States",
18+
"email": "bob.norman@mail.example.com",
19+
"first_name": "Bob",
20+
"last_name": "Norman",
21+
"phone": "+1(502)-459-2181",
22+
"province": "Kentucky",
23+
"zip": "40202"
24+
},
25+
"origin": {
26+
"address1": null,
27+
"address2": null,
28+
"city": null,
29+
"country_code": "DE",
30+
"location_id": 24826418,
31+
"name": "Apple Api Shipwire",
32+
"phone": null,
33+
"province": null,
34+
"zip": null
35+
},
36+
"line_items": [
37+
{
38+
"id": 1058737494,
39+
"shop_id": 548380009,
40+
"fulfillment_order_id": 1046000790,
41+
"quantity": 1,
42+
"line_item_id": 518995019,
43+
"inventory_item_id": 49148385,
44+
"fulfillable_quantity": 1,
45+
"variant_id": 49148385
46+
}
47+
],
48+
"outgoing_requests": [],
49+
"international_duties": null,
50+
"fulfillment_holds": [],
51+
"fulfill_by": null,
52+
"created_at": "2024-07-24T06:26:33-04:00",
53+
"updated_at": "2024-07-24T06:26:34-04:00",
54+
"delivery_method": null
55+
}
56+
}

test/fulfillment-order.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,16 @@ describe('Shopify#fulfillmentOrder', () => {
149149
expect(data).to.deep.equal(output.fulfillment_order);
150150
});
151151
});
152+
153+
it('releases the fulfillment hold on a fulfillment order', () => {
154+
const output = fixtures.res.releaseHold;
155+
156+
scope
157+
.post('/admin/fulfillment_orders/1046000790/release_hold.json', {})
158+
.reply(200, output);
159+
160+
return shopify.fulfillmentOrder.releaseHold(1046000790).then((data) => {
161+
expect(data).to.deep.equal(output.fulfillment_order);
162+
});
163+
});
152164
});

types/index.d.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,23 +376,24 @@ declare class Shopify {
376376
params: Shopify.IFulfillmentOrder
377377
) => Promise<Shopify.IFulfillmentOrder>;
378378
close: (id: number, message?: string) => Promise<Shopify.IFulfillmentOrder>;
379+
fulfillments: (
380+
id: number
381+
) => Promise<Shopify.IPaginatedResult<Shopify.IFulfillment>>;
379382
get: (id: number) => Promise<Shopify.IFulfillmentOrder>;
383+
hold: (
384+
id: number,
385+
params: Shopify.IFulfillmentHold
386+
) => Promise<Shopify.IFulfillmentOrder>;
380387
list: (params?: any) => Promise<Shopify.IFulfillmentOrder[]>;
381388
locationsForMove: (id: number) => Promise<Shopify.ILocationForMove[]>;
382389
move: (
383390
id: number,
384391
locationId: number
385392
) => Promise<Shopify.IFulfillmentOrder>;
393+
releaseHold: (id: number) => Promise<Shopify.IFulfillmentOrder>;
386394
setFulfillmentOrdersDeadline: (
387395
params: Shopify.ISetFulfillmentOrdersDeadline
388396
) => Promise<void>;
389-
fulfillments: (
390-
id: number
391-
) => Promise<Shopify.IPaginatedResult<Shopify.IFulfillment>>;
392-
hold: (
393-
id: number,
394-
params: Shopify.IFulfillmentHold
395-
) => Promise<Shopify.IFulfillmentOrder>;
396397
};
397398
fulfillmentRequest: {
398399
accept: (

0 commit comments

Comments
 (0)