Browse Source

Removed options for location_for_move

Lin Zhao 5 years ago
parent
commit
daca0cf44c

+ 8 - 0
lib/shopify_api/resources/fulfillment_order.rb

@@ -17,6 +17,14 @@ module ShopifyAPI
       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: {

+ 4 - 0
lib/shopify_api/resources/fulfillment_order_locations_for_move.rb

@@ -0,0 +1,4 @@
+module ShopifyAPI
+  class FulfillmentOrderLocationsForMove < Base
+  end
+end

+ 18 - 0
test/fixtures/fulfillment_order_locations_for_move.json

@@ -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 - 0
test/fulfillment_order_test.rb

@@ -57,6 +57,24 @@ class FulFillmentOrderTest < Test::Unit::TestCase
       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)