Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add locations_for_move API #669

Merged
merged 1 commit into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space after comma

end
end

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