Skip to content

Commit 61cac8c

Browse files
committed
Add locations_to_move API
1 parent 2818c3b commit 61cac8c

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

lib/shopify_api/resources/fulfillment_order.rb

+9
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ def close(message: nil)
4343
load_attributes_from_response(post(:close, {}, body.to_json))
4444
end
4545

46+
def locations_for_move(options = {})
47+
location_hashes = get(:locations_for_move, options)
48+
49+
location_hashes.map do |location_hash|
50+
param = location_hash["location"].merge(location_hash.except("location"))
51+
Location.new(param)
52+
end
53+
end
54+
4655
def request_fulfillment(fulfillment_order_line_items: nil, message: nil)
4756
body = {
4857
fulfillment_request: {

test/fixtures/locations.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[
2+
{
3+
"location": {
4+
"id": 1059367776,
5+
"name": "Alpha Location"
6+
},
7+
"message": "Current location.",
8+
"movable": false
9+
},
10+
{
11+
"location": {
12+
"id": 1059367777,
13+
"name": "Bravo Location"
14+
},
15+
"message": "No items are stocked at this location.",
16+
"movable": false
17+
}
18+
]

test/fulfillment_order_test.rb

+15
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,21 @@ def setup
5757
end
5858
end
5959

60+
context "#locations_for_move" do
61+
should "be able to list locations for a fulfillment order" do
62+
fulfillment_order = ShopifyAPI::FulfillmentOrder.find(519788021)
63+
fake "fulfillment_orders/#{fulfillment_order.id}/locations_for_move", method: :get,
64+
body: load_fixture('locations')
65+
66+
locations = fulfillment_order.locations_for_move
67+
68+
assert_equal 2, locations.count
69+
location = locations.first
70+
assert location.is_a?(ShopifyAPI::Location)
71+
assert_equal 1059367776, location.id
72+
end
73+
end
74+
6075
context "#move" do
6176
should "move a fulfillment order to a new_location_id" do
6277
fulfillment_order = ShopifyAPI::FulfillmentOrder.find(519788021)

0 commit comments

Comments
 (0)