Permalink
Browse files

Added examples folder

  • Loading branch information...
1 parent 36c59a3 commit c18ee531d7f405f416112edb441f99315c4c48a5 Wynn Netherland committed Aug 4, 2009
View
@@ -1,16 +1,17 @@
# remixr
-The Ruby BestBuy Remix API gem.
+The Ruby BestBuy [Remix API](http://remix.bestbuy.com/docs) gem. Remix is an API that gives you access to BestBuy.com's product catalog data and more.
-## examples
+## Some examples
-See the examples directory.
-http://github.com/squeejee/remixr/tree/master/examples
+More in the examples folder:
-### docs
+[http://github.com/squeejee/remixr/tree/master/examples](http://github.com/squeejee/remixr/tree/master/examples)
-http://rdoc.info/projects/squeejee/remixr
+### Documentation
+
+[http://rdoc.info/projects/squeejee/remixr](http://rdoc.info/projects/squeejee/remixr)
#### Copyright
View
@@ -68,7 +68,7 @@ begin
namespace :rubyforge do
desc "Release gem and RDoc documentation to RubyForge"
- task :release => ["rubyforge:release:gem", "rubyforge:release:website", "rubyforge:release:docs"]
+ task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
namespace :release do
desc "Publish RDoc to RubyForge."
@@ -84,17 +84,17 @@ begin
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
end
- task :website do
- config = YAML.load(
- File.read(File.expand_path('~/.rubyforge/user-config.yml'))
- )
-
- host = "#{config['username']}@rubyforge.org"
- remote_dir = "/var/www/gforge-projects/remixr/"
- local_dir = 'website'
-
- Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
- end
+ # task :website do
+ # config = YAML.load(
+ # File.read(File.expand_path('~/.rubyforge/user-config.yml'))
+ # )
+ #
+ # host = "#{config['username']}@rubyforge.org"
+ # remote_dir = "/var/www/gforge-projects/remixr/"
+ # local_dir = 'website'
+ #
+ # Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
+ # end
end
end
rescue LoadError
View
@@ -0,0 +1,7 @@
+Remixr.api_key = 'OU812' # get yours from http://remix.bestbuy.com/apps/register
+client = Remixr::Client.new
+
+# find stores within 50 miles of ZIP 76227 and products over three G's
+stores = client.stores({:area => ['76227', 50]}).products({:salePrice => {'$gt' => 3000}}).fetch.stores
+stores.first.products.first.shortDescription
+#=> "ENERGY STAR Qualified 4 HDMI inputs; gray Touch of Color bezel; 16:9 aspect ratio"
View
@@ -0,0 +1,13 @@
+Remixr.api_key = 'OU812' # get yours from http://remix.bestbuy.com/apps/register
+client = Remixr::Client.new
+
+# fetch first page of products on sale below 20 bucks
+products = client.products({:salePrice => {'$lt' => 20.00}}).fetch.products
+
+products.first
+# => {"url"=>"http://www.bestbuy.com/site/olspage.jsp?skuId=7524468&type=product&id=1494684&cmp=RMX&ky=1uYnAnk1pohGgQVwEClo8PHv4SN4C5MeL", "inStoreAvailability"=>true, "albumLabel"=>nil, "genre"=>nil, "sku"=>7524468, "affiliateUrl"=>nil, "cjAffiliateAddToCartUrl"=>nil, "salesRankLongTerm"=>2451, "addToCartUrl"=>"http://www.bestbuy.com/site/olspage.jsp?id=pcmcat152200050035&type=category&cmp=RMX&ky=1uYnAnk1pohGgQVwEClo8PHv4SN4C5MeL&qvsids=7524468", "remoteControlImage"=>nil, "affiliateAddToCartUrl"=>nil, "largeImage"=>nil, "new"=>false, "salePrice"=>15.99, "artistId"=>"BYPart1061717", "inStoreAvailabilityUpdateDate"=>"2007-07-27T20:20:50", "largeFrontImage"=>nil, "department"=>"VIDEO/COMPACT DISC", "artistName"=>"Purple City", "accessoriesImage"=>nil, "format"=>"CD", "customerReviewCount"=>nil, "regularPrice"=>15.99, "amgId"=>nil, "freeShipping"=>false, "salesRankShortTerm"=>250, "shortDescription"=>nil, "specialOrder"=>false, "nationalFeatured"=>false, "manufacturer"=>nil, "salesRankMediumTerm"=>570, "energyGuideImage"=>nil, "inStoreAvailabilityText"=>"Store Pickup: Limited Availability", "alternateViewsImage"=>nil, "mobileUrl"=>"http://m.bestbuy.com/r/1494684/7524468/", "subclass"=>"RAP", "name"=>"\"Paris to Purple City\"", "cjAffiliateUrl"=>nil, "image"=>"http://images.bestbuy.com/BestBuy_US/images/products/7524/7524468.jpg", "shippingCost"=>1.59, "subclassId"=>1009, "upc"=>"823979901426", "onlineAvailabilityText"=>"Shipping: Usually leaves our warehouse in 1 business day", "onlineAvailabilityUpdateDate"=>"2007-07-27T20:20:50", "topViewImage"=>nil, "class"=>"COMPACT DISC", "active"=>true, "classId"=>77, "parentalAdvisory"=>false, "thumbnailImage"=>"http://images.bestbuy.com/BestBuy_US/images/products/7524/7524468s.jpg", "leftViewImage"=>nil, "rightViewImage"=>nil, "productId"=>1494684, "source"=>"bestbuy", "customerReviewAverage"=>nil, "activeUpdateDate"=>"2007-07-27T20:20:50", "mediumImage"=>nil, "startDate"=>#<Date: 4906945/2,0,2299161>, "departmentId"=>8, "angleImage"=>nil, "albumVersion"=>nil, "spin360Url"=>nil, "priceUpdateDate"=>"2008-02-09T00:10:37", "categoryPath"=>[<Mash id="cat00000" name="Best Buy">, <Mash id="abcat0600000" name="Music & Movies">, <Mash id="cat02001" name="Music">, <Mash id="cat02012" name="Rap & Hip-Hop">, <Mash id="cat02719" name="Rap">], "printOnly"=>false, "releaseDate"=>#<Date: 4907365/2,0,2299161>, "search"=>nil, "copyright"=>nil, "onSale"=>false, "itemUpdateDate"=>"2009-02-03T03:50:13", "albumTitle"=>"\"Paris to Purple City\"", "type"=>"Music", "originalReleaseDat
+
+
+# fetch only SKU and salePrice
+products = client.products({:salePrice => {'$lt' => 20.00}}).fetch.products
+# => [{"salePrice"=>10.99, "sku"=>7000032}, {"salePrice"=>10.99, "sku"=>11467058}, {"salePrice"=>13.99, "sku"=>7873884}, {"salePrice"=>11.99, "sku"=>15444798}, {"salePrice"=>13.99, "sku"=>9113256}, {"salePrice"=>13.99, "sku"=>5797649}, {"salePrice"=>13.99, "sku"=>8890961}, {"salePrice"=>14.99, "sku"=>17338506}, {"salePrice"=>11.99, "sku"=>9242642}, {"salePrice"=>13.99, "sku"=>9171353}]
View
@@ -0,0 +1,11 @@
+Remixr.api_key = 'OU812' # get yours from http://remix.bestbuy.com/apps/register
+client = Remixr::Client.new
+
+# find stores within 50 miles of ZIP 76227
+stores = client.stores({:area => ['76227', 50]}).fetch.stores
+
+stores.first
+# => {"city"=>"Denton", "longName"=>"Best Buy - Denton", "name"=>"Denton", "region"=>"TX", "address"=>"1800 S Loop 288, Ste 102 Bldg 1 ", "country"=>"US", "lng"=>-97.10067, "postalCode"=>"76205", "phone"=>"940-384-9581", "hours"=>"Mon: 10-9; Tue: 10-9; Wed: 10-9; Thurs: 10-9; Fri: 10-10; Sat: 10-10; Sun: 11-8", "storeId"=>827, "fullPostalCode"=>"76205", "lat"=>33.192524, "distance"=>9.79}
+
+
+
View
@@ -11,6 +11,7 @@ class APIKeyNotSet < StandardError; end
module Remixr
+ # Get your API key from http://remix.bestbuy.com/apps/register
def self.api_key
raise APIKeyNotSet if @api_key.nil?
View
@@ -61,6 +61,12 @@ def products(filters={})
self
end
+
+ # Executes the search
+ # Possible options:
+ # :page - positive integer for page number
+ # :show - comma delimited string or array of field names to show
+ # :sort - array of sort info ['fieldname', 'asc|desc']
def fetch(options={})
opts = {:apiKey => @api_key, :format => 'json'}
opts.merge!(scrub_options(options))
@@ -128,6 +134,14 @@ def filter_params_string(filters)
def scrub_options(options)
options = Mash.new(options.to_hash)
+ show = options.delete('show')
+ unless show.blank?
+ if show.is_a?(String)
+ options['show'] = show
+ elsif show.is_a?(Array)
+ options['show'] = show.join(',')
+ end
+ end
sort = options.delete('sort')
unless sort.blank?
if sort.is_a?(Hash)
@@ -211,6 +211,6 @@
],
"total": 2,
"to": 2,
- "canonicalUrl": "\/v1\/products(|)?format=json&apiKey=5b4tk8akphtrpt8ahecqc4yk",
+ "canonicalUrl": "\/v1\/products(|)?format=json&apiKey=OU812",
"totalTime": "0.351"
}
@@ -943,6 +943,6 @@
],
"total": 453500,
"to": 10,
- "canonicalUrl": "\/v1\/products?format=json&apiKey=5b4tk8akphtrpt8ahecqc4yk",
+ "canonicalUrl": "\/v1\/products?format=json&apiKey=OU812",
"totalTime": "0.268"
}
@@ -899,6 +899,6 @@
],
"total": 104150,
"to": 10,
- "canonicalUrl": "\/v1\/products(salePrice>20)?format=json&apiKey=5b4tk8akphtrpt8ahecqc4yk",
+ "canonicalUrl": "\/v1\/products(salePrice>20)?format=json&apiKey=OU812",
"totalTime": "0.232"
}
@@ -771,6 +771,6 @@
],
"total": 3,
"to": 3,
- "canonicalUrl": "\/v1\/products(salePrice>3000)+stores(area(\"76227\",50))?format=json&apiKey=5b4tk8akphtrpt8ahecqc4yk",
+ "canonicalUrl": "\/v1\/products(salePrice>3000)+stores(area(\"76227\",50))?format=json&apiKey=OU812",
"totalTime": "0.075"
}
@@ -37,6 +37,6 @@
],
"total": 453500,
"to": 10,
- "canonicalUrl": "\/v1\/products?show=sku&format=json&apiKey=5b4tk8akphtrpt8ahecqc4yk",
+ "canonicalUrl": "\/v1\/products?show=sku&format=json&apiKey=OU812",
"totalTime": "0.163"
}
@@ -157,6 +157,6 @@
"storeId": 532
}
],
- "canonicalUrl": "\/v1\/stores?format=json&apiKey=5b4tk8akphtrpt8ahecqc4yk",
+ "canonicalUrl": "\/v1\/stores?format=json&apiKey=OU812",
"totalTime": "0.007"
}
@@ -22,6 +22,6 @@
"storeId": 530
}
],
- "canonicalUrl": "\/v1\/stores(postalCode=\"02184\")?format=json&apiKey=5b4tk8akphtrpt8ahecqc4yk",
+ "canonicalUrl": "\/v1\/stores(postalCode=\"02184\")?format=json&apiKey=OU812",
"totalTime": "0.005"
}
@@ -52,6 +52,6 @@
"storeId": 612
}
],
- "canonicalUrl": "\/v1\/stores(storeId in(307,281,612))?format=json&apiKey=5b4tk8akphtrpt8ahecqc4yk",
+ "canonicalUrl": "\/v1\/stores(storeId in(307,281,612))?format=json&apiKey=OU812",
"totalTime": "0.004"
}
@@ -157,6 +157,6 @@
"storeId": 258
}
],
- "canonicalUrl": "\/v1\/stores(region=\"TX\")?format=json&apiKey=5b4tk8akphtrpt8ahecqc4yk",
+ "canonicalUrl": "\/v1\/stores(region=\"TX\")?format=json&apiKey=OU812",
"totalTime": "0.109"
}
@@ -157,6 +157,6 @@
"storeId": 273
}
],
- "canonicalUrl": "\/v1\/stores?page=20&format=json&apiKey=5b4tk8akphtrpt8ahecqc4yk",
+ "canonicalUrl": "\/v1\/stores?page=20&format=json&apiKey=OU812",
"totalTime": "0.018"
}
@@ -157,6 +157,6 @@
"storeId": 1150
}
],
- "canonicalUrl": "\/v1\/stores?sort=storeId.desc&page=20&format=json&apiKey=5b4tk8akphtrpt8ahecqc4yk",
+ "canonicalUrl": "\/v1\/stores?sort=storeId.desc&page=20&format=json&apiKey=OU812",
"totalTime": "0.048"
}
@@ -82,6 +82,6 @@
"storeId": 530
}
],
- "canonicalUrl": "\/v1\/stores(postalCode=\"021*\")?format=json&apiKey=5b4tk8akphtrpt8ahecqc4yk",
+ "canonicalUrl": "\/v1\/stores(postalCode=\"021*\")?format=json&apiKey=OU812",
"totalTime": "0.051"
}
@@ -4429,6 +4429,6 @@
"storeId": 148
}
],
- "canonicalUrl": "\/v1\/stores(area(\"76227\",50))+products(salePrice>3000)?format=json&apiKey=5b4tk8akphtrpt8ahecqc4yk",
+ "canonicalUrl": "\/v1\/stores(area(\"76227\",50))+products(salePrice>3000)?format=json&apiKey=OU812",
"totalTime": "0.067"
}
@@ -167,6 +167,6 @@
"storeId": 202
}
],
- "canonicalUrl": "\/v1\/stores(area(\"76227\",50))?format=json&apiKey=5b4tk8akphtrpt8ahecqc4yk",
+ "canonicalUrl": "\/v1\/stores(area(\"76227\",50))?format=json&apiKey=OU812",
"totalTime": "0.023"
}

0 comments on commit c18ee53

Please sign in to comment.