Skip to content

Commit

Permalink
[api] Add releaseHold action to FulfillmentOrder resource
Browse files Browse the repository at this point in the history
  • Loading branch information
lpinca committed Aug 20, 2024
1 parent 7803fa1 commit dadedd2
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ default.
- `list([params])`
- `locationsForMove(id)`
- `move(id, locationId)`
- `releaseHold(id)`
- `setFulfillmentOrdersDeadline(params)`
- fulfillmentRequest
- `accept(fulfillmentOrderId[, message])`
Expand Down
15 changes: 15 additions & 0 deletions resources/fulfillment-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,19 @@ FulfillmentOrder.prototype.hold = function hold(id, params) {
.then((body) => body[this.key]);
};

/**
* Release the fulfillment hold on a fulfillment order and changes the status of
* the fulfillment order to `OPEN` or `SCHEDULED`.
*
* @param {Number} id Fulfillment Order ID
* @return {Promise} Promise that resolves with the result
* @public
*/
FulfillmentOrder.prototype.releaseHold = function releaseHold(id) {
const url = this.buildUrl(`${id}/release_hold`);
return this.shopify
.request(url, 'POST', undefined, {})
.then((body) => body[this.key]);
};

module.exports = FulfillmentOrder;
9 changes: 5 additions & 4 deletions test/fixtures/fulfillment-order/res/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use strict';

exports.locationsForMove = require('./locations-for-move');
exports.fulfillments = require('./fulfillments');
exports.cancel = require('./cancel');
exports.close = require('./close');
exports.list = require('./list');
exports.move = require('./move');
exports.fulfillments = require('./fulfillments');
exports.get = require('./get');
exports.hold = require('./hold');
exports.list = require('./list');
exports.locationsForMove = require('./locations-for-move');
exports.move = require('./move');
exports.releaseHold = require('./release-hold');
56 changes: 56 additions & 0 deletions test/fixtures/fulfillment-order/res/release-hold.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"fulfillment_order": {
"id": 1046000790,
"shop_id": 548380009,
"order_id": 450789469,
"assigned_location_id": 24826418,
"request_status": "submitted",
"status": "open",
"fulfill_at": null,
"supported_actions": ["cancel_fulfillment_order"],
"destination": {
"id": 1046000790,
"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"
},
"origin": {
"address1": null,
"address2": null,
"city": null,
"country_code": "DE",
"location_id": 24826418,
"name": "Apple Api Shipwire",
"phone": null,
"province": null,
"zip": null
},
"line_items": [
{
"id": 1058737494,
"shop_id": 548380009,
"fulfillment_order_id": 1046000790,
"quantity": 1,
"line_item_id": 518995019,
"inventory_item_id": 49148385,
"fulfillable_quantity": 1,
"variant_id": 49148385
}
],
"outgoing_requests": [],
"international_duties": null,
"fulfillment_holds": [],
"fulfill_by": null,
"created_at": "2024-07-24T06:26:33-04:00",
"updated_at": "2024-07-24T06:26:34-04:00",
"delivery_method": null
}
}
12 changes: 12 additions & 0 deletions test/fulfillment-order.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,16 @@ describe('Shopify#fulfillmentOrder', () => {
expect(data).to.deep.equal(output.fulfillment_order);
});
});

it('releases the fulfillment hold on a fulfillment order', () => {
const output = fixtures.res.releaseHold;

scope
.post('/admin/fulfillment_orders/1046000790/release_hold.json', {})
.reply(200, output);

return shopify.fulfillmentOrder.releaseHold(1046000790).then((data) => {
expect(data).to.deep.equal(output.fulfillment_order);
});
});
});
15 changes: 8 additions & 7 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,23 +376,24 @@ declare class Shopify {
params: Shopify.IFulfillmentOrder
) => Promise<Shopify.IFulfillmentOrder>;
close: (id: number, message?: string) => Promise<Shopify.IFulfillmentOrder>;
fulfillments: (
id: number
) => Promise<Shopify.IPaginatedResult<Shopify.IFulfillment>>;
get: (id: number) => Promise<Shopify.IFulfillmentOrder>;
hold: (
id: number,
params: Shopify.IFulfillmentHold
) => Promise<Shopify.IFulfillmentOrder>;
list: (params?: any) => Promise<Shopify.IFulfillmentOrder[]>;
locationsForMove: (id: number) => Promise<Shopify.ILocationForMove[]>;
move: (
id: number,
locationId: number
) => Promise<Shopify.IFulfillmentOrder>;
releaseHold: (id: number) => Promise<Shopify.IFulfillmentOrder>;
setFulfillmentOrdersDeadline: (
params: Shopify.ISetFulfillmentOrdersDeadline
) => Promise<void>;
fulfillments: (
id: number
) => Promise<Shopify.IPaginatedResult<Shopify.IFulfillment>>;
hold: (
id: number,
params: Shopify.IFulfillmentHold
) => Promise<Shopify.IFulfillmentOrder>;
};
fulfillmentRequest: {
accept: (
Expand Down

0 comments on commit dadedd2

Please sign in to comment.