Skip to content

Commit

Permalink
Merge pull request #669 from Shopify/location_to_move
Browse files Browse the repository at this point in the history
Add locations_for_move API
  • Loading branch information
linzhao125 authored Jan 20, 2020
2 parents 7a81d00 + daca0cf commit ac09df1
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/shopify_api/resources/fulfillment_order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ def fulfillments(options = {})
fulfillment_hashes.map { |fulfillment_hash| Fulfillment.new(fulfillment_hash) }
end

def locations_for_move
locations_for_move_hashes = get(:locations_for_move, {})

locations_for_move_hashes.map do |locations_for_move_hash|
FulfillmentOrderLocationsForMove.new(locations_for_move_hash)
end
end

def move(new_location_id:)
body = {
fulfillment_order: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ShopifyAPI
class FulfillmentOrderLocationsForMove < Base
end
end
18 changes: 18 additions & 0 deletions test/fixtures/fulfillment_order_locations_for_move.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"location": {
"id": 1059367776,
"name": "Alpha Location"
},
"message": "Current location.",
"movable": false
},
{
"location": {
"id": 1059367777,
"name": "Bravo Location"
},
"message": "No items are stocked at this location.",
"movable": false
}
]
18 changes: 18 additions & 0 deletions test/fulfillment_order_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ def setup
end
end

context "#locations_for_move" do
should "be able to list locations for a fulfillment order" do
fulfillment_order = ShopifyAPI::FulfillmentOrder.find(519788021)
fake "fulfillment_orders/#{fulfillment_order.id}/locations_for_move", method: :get,
body: load_fixture('fulfillment_order_locations_for_move')

locations_for_move = fulfillment_order.locations_for_move

assert_equal 2, locations_for_move.count
location_for_move = locations_for_move.first
assert location_for_move.is_a?(ShopifyAPI::FulfillmentOrderLocationsForMove)

location = location_for_move.location
assert location.is_a?(ShopifyAPI::Location)
assert_equal 1059367776,location.id
end
end

context "#move" do
should "move a fulfillment order to a new_location_id" do
fulfillment_order = ShopifyAPI::FulfillmentOrder.find(519788021)
Expand Down

0 comments on commit ac09df1

Please sign in to comment.