Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated readme, method comments

  • Loading branch information...
commit 24588fc93fb3fbbe939ad24af04464a7222987a0 1 parent c18ee53
Wynn Netherland authored

Showing 2 changed files with 61 additions and 3 deletions. Show diff stats Hide diff stats

  1. +60 2 README.markdown
  2. +1 1  lib/remixr/client.rb
62 README.markdown
Source Rendered
@@ -2,8 +2,66 @@
2 2
3 3 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.
4 4
5   -## Some examples
6   -
  5 +## Install
  6 +
  7 + sudo gem install remixr
  8 +
  9 +## Usage
  10 +
  11 + Remixr.api_key = 'OU812' # get yours from http://remix.bestbuy.com/apps/register
  12 + client = Remixr::Client.new
  13 +
  14 +### Find stores
  15 +
  16 + # find stores within 50 miles of ZIP 76227
  17 + stores = client.stores({:area => ['76227', 50]}).fetch.stores
  18 +
  19 + stores.first
  20 +
  21 + => {"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}
  22 +
  23 +
  24 +### Find products
  25 +
  26 + # fetch first page of products on sale below 20 bucks
  27 + products = client.products({:salePrice => {'$lt' => 20.00}}).fetch.products
  28 +
  29 + # fetch only SKU and salePrice
  30 + products = client.products({:salePrice => {'$lt' => 20.00}}).fetch.products
  31 +
  32 +### Chaining
  33 +
  34 +You can also chain `stores` and `products` to return stores and nested product info or vice versa
  35 +
  36 + # find stores within 50 miles of ZIP 76227 and products over three G's
  37 +
  38 + stores = client.stores({:area => ['76227', 50]}).products({:salePrice => {'$gt' => 3000}}).fetch.stores
  39 +
  40 + stores.first.products.first.shortDescription
  41 +
  42 + #=> "ENERGY STAR Qualified 4 HDMI inputs; gray Touch of Color bezel; 16:9 aspect ratio"
  43 +
  44 +### Fetching
  45 +
  46 +All calls terminate in a call to `fetch` which takes the following options
  47 +
  48 + :page - positive integer for page number
  49 + :show - comma delimited string or array of field names to show
  50 + :sort - hash or string of sort info {'fieldname' => 'asc|desc'}
  51 +
  52 +
  53 +### Conditional operators
  54 +
  55 +We took a page out of [MongoDB's](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-ConditionalOperators%3A%3C%2C%3C%3D%2C%3E%2C%3E%3D) playbook and mapped conditional operators to text equivalents to avoid having these be keys to hashes:
  56 +
  57 + {:salePrice => {'$gte' => 300.00}}
  58 + => salePrice > 300.00
  59 +
  60 + $gte - greater than or equal to : field > value
  61 + $lte - less than or equal to : field > value
  62 + $gt - greater than : field > value
  63 + $lt - less than : field > value
  64 + $ne - not equal to : field != value
7 65
8 66 More in the examples folder:
9 67
2  lib/remixr/client.rb
@@ -66,7 +66,7 @@ def products(filters={})
66 66 # Possible options:
67 67 # :page - positive integer for page number
68 68 # :show - comma delimited string or array of field names to show
69   - # :sort - array of sort info ['fieldname', 'asc|desc']
  69 + # :sort - hash or string of sort info {'fieldname' => 'asc|desc'}
70 70 def fetch(options={})
71 71 opts = {:apiKey => @api_key, :format => 'json'}
72 72 opts.merge!(scrub_options(options))

0 comments on commit 24588fc

Please sign in to comment.
Something went wrong with that request. Please try again.