Browse Source

Get product IDs for product listings

Matt Scriven 8 years ago
parent
commit
44a572e249

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

@@ -1,5 +1,9 @@
 module ShopifyAPI
   class ProductListing < Base
     init_prefix :application
+
+    def self.product_ids(options = {})
+      get(:product_ids, options[:params])
+    end
   end
 end

+ 1 - 0
test/fixtures/product_listing_product_ids.json

@@ -0,0 +1 @@
+[2, 1]

+ 10 - 0
test/product_listing_test.rb

@@ -21,4 +21,14 @@ class ProductListingTest < Test::Unit::TestCase
 
     assert_equal 'Synergistic Silk Chair', product_listing.title
   end
+
+  def test_get_product_listing_product_ids
+    fake "applications/999/product_listings/product_ids", method: :get, status: 201, body: load_fixture('product_listing_product_ids')
+
+    product_ids = ShopifyAPI::ProductListing.product_ids(params: { application_id: 999 })
+
+    assert_equal 2, product_ids.count
+    assert_equal 2, product_ids.first
+    assert_equal 1, product_ids.last
+  end
 end