lib/sunlight_api.rb in sunlight_api-1.0.1 vs lib/sunlight_api.rb in sunlight_api-1.1.0
- old
+ new
@@ -1,8 +1,10 @@
require "sunlight_api/version"
require "rquest"
require "json"
+# Fix ruby's DNS lookup issues
+require "resolv-replace.rb"
module SunlightApi
class Client
def initialize( public_key, private_key )
@public_key = public_key
@@ -32,13 +34,20 @@
def product_info( id )
request("part/#{id}")
end
+ def product_price_breaks( id )
+ request("pricebreak/#{id}")
+ end
+
def each_product( &block )
array_of_product_ids.each do |product_id|
product = product_info( product_id )
next unless product
+ price_breaks = product_price_breaks(product_id)
+ price_breaks ||= []
+ product["PriceBreaks"] = price_breaks
yield product
end
end
end
class UriGenerator