remixr-prashanth 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,172 @@
1
+ {
2
+ "totalPages": 4,
3
+ "currentPage": 1,
4
+ "queryTime": "0.008",
5
+ "from": 1,
6
+ "total": 31,
7
+ "to": 10,
8
+ "stores": [
9
+ {
10
+ "fullPostalCode": "76205",
11
+ "city": "Denton",
12
+ "longName": "Best Buy - Denton",
13
+ "name": "Denton",
14
+ "region": "TX",
15
+ "country": "US",
16
+ "lng": -97.10067,
17
+ "postalCode": "76205",
18
+ "phone": "940-384-9581",
19
+ "hours": "Mon: 10-9; Tue: 10-9; Wed: 10-9; Thurs: 10-9; Fri: 10-10; Sat: 10-10; Sun: 11-8",
20
+ "lat": 33.192524,
21
+ "address": "1800 S Loop 288, Ste 102 Bldg 1 ",
22
+ "distance": 9.79,
23
+ "storeId": 827
24
+ },
25
+ {
26
+ "fullPostalCode": "75034",
27
+ "city": "Frisco",
28
+ "longName": "Best Buy - Frisco",
29
+ "name": "Frisco",
30
+ "region": "TX",
31
+ "country": "US",
32
+ "lng": -96.83974,
33
+ "postalCode": "75034",
34
+ "phone": "214-872-2079",
35
+ "hours": "Mon: 10-9; Tue: 10-9; Wed: 10-9; Thurs: 10-9; Fri: 10-10; Sat: 10-10; Sun: 10-8",
36
+ "lat": 33.17477,
37
+ "address": "5299 Eldorado Pkwy",
38
+ "distance": 10.79,
39
+ "storeId": 1773
40
+ },
41
+ {
42
+ "fullPostalCode": "75034",
43
+ "city": "Frisco",
44
+ "longName": "Best Buy - Frisco",
45
+ "name": "Frisco",
46
+ "region": "TX",
47
+ "country": "US",
48
+ "lng": -96.807182,
49
+ "postalCode": "75034",
50
+ "phone": "972-712-3939",
51
+ "hours": "Mon: 10-9; Tue: 10-9; Wed: 10-9; Thurs: 10-9; Fri: 10-10; Sat: 10-10; Sun: 11-8",
52
+ "lat": 33.108253,
53
+ "address": "3333 Preston Rd #200",
54
+ "distance": 15.49,
55
+ "storeId": 180
56
+ },
57
+ {
58
+ "fullPostalCode": "75056",
59
+ "city": "Lewisville",
60
+ "longName": "Best Buy - The Colony",
61
+ "name": "The Colony",
62
+ "region": "TX",
63
+ "country": "US",
64
+ "lng": -96.88915,
65
+ "postalCode": "75056",
66
+ "phone": "214-469-2979",
67
+ "hours": "Mon: 10-9; Tue: 10-9; Wed: 10-9; Thurs: 10-9; Fri: 10-10; Sat: 10-10; Sun: 11-8",
68
+ "lat": 33.06501,
69
+ "address": "4800 State Hwy 121 ",
70
+ "distance": 15.93,
71
+ "storeId": 1796
72
+ },
73
+ {
74
+ "fullPostalCode": "75022",
75
+ "city": "Flower Mound",
76
+ "longName": "Best Buy - Flower Mound",
77
+ "name": "Flower Mound",
78
+ "region": "TX",
79
+ "country": "US",
80
+ "lng": -97.080109,
81
+ "postalCode": "75022",
82
+ "phone": "972-874-0965",
83
+ "hours": "Mon: 10-9; Tue: 10-9; Wed: 10-9; Thurs: 10-9; Fri: 10-9; Sat: 9-9; Sun: 10-8",
84
+ "lat": 33.06926,
85
+ "address": "6060 Long Prairie Rd",
86
+ "distance": 16.15,
87
+ "storeId": 1038
88
+ },
89
+ {
90
+ "fullPostalCode": "75070",
91
+ "city": "Mckinney",
92
+ "longName": "Best Buy - SW Mckinney",
93
+ "name": "SW Mckinney",
94
+ "region": "TX",
95
+ "country": "US",
96
+ "lng": -96.72936,
97
+ "postalCode": "75070",
98
+ "phone": "214-250-5939",
99
+ "hours": "Mon: 10-9; Tue: 10-9; Wed: 10-9; Thurs: 10-9; Fri: 10-9; Sat: 10-9; Sun: 10-7",
100
+ "lat": 33.13148,
101
+ "address": "8720 State Hwy 121 Ste 112",
102
+ "distance": 17.59,
103
+ "storeId": 1775
104
+ },
105
+ {
106
+ "fullPostalCode": "75067",
107
+ "city": "Lewisville",
108
+ "longName": "Best Buy - Lewisville",
109
+ "name": "Lewisville",
110
+ "region": "TX",
111
+ "country": "US",
112
+ "lng": -96.963219,
113
+ "postalCode": "75067",
114
+ "phone": "214-488-8624",
115
+ "hours": "Mon: 10-9; Tue: 10-9; Wed: 10-9; Thurs: 10-9; Fri: 10-10; Sat: 10-10; Sun: 10-8",
116
+ "lat": 32.999397,
117
+ "address": "2601 S Stemmons Fwy",
118
+ "distance": 19.73,
119
+ "storeId": 258
120
+ },
121
+ {
122
+ "fullPostalCode": "75070",
123
+ "city": "Mckinney",
124
+ "longName": "Best Buy - Mckinney",
125
+ "name": "Mckinney",
126
+ "region": "TX",
127
+ "country": "US",
128
+ "lng": -96.639603,
129
+ "postalCode": "75070",
130
+ "phone": "972-542-8305",
131
+ "hours": "Mon: 10-9; Tue: 10-9; Wed: 10-9; Thurs: 10-9; Fri: 10-10; Sat: 10-10; Sun: 10-7",
132
+ "lat": 33.213333,
133
+ "address": "1751 N Central Expy Ste C",
134
+ "distance": 19.86,
135
+ "storeId": 196
136
+ },
137
+ {
138
+ "fullPostalCode": "75002",
139
+ "city": "Allen",
140
+ "longName": "Best Buy - Allen",
141
+ "name": "Allen",
142
+ "region": "TX",
143
+ "country": "US",
144
+ "lng": -96.65549,
145
+ "postalCode": "75002",
146
+ "phone": "469-675-8924",
147
+ "hours": "Mon: 10-9; Tue: 10-9; Wed: 10-9; Thurs: 10-9; Fri: 10-10; Sat: 10-10; Sun: 10-8",
148
+ "lat": 33.1267,
149
+ "address": "190 E Stacy Rd Bldg 3000",
150
+ "distance": 21.33,
151
+ "storeId": 1780
152
+ },
153
+ {
154
+ "fullPostalCode": "75074",
155
+ "city": "Plano",
156
+ "longName": "Best Buy - Plano ",
157
+ "name": "Plano ",
158
+ "region": "TX",
159
+ "country": "US",
160
+ "lng": -96.702805,
161
+ "postalCode": "75074",
162
+ "phone": "972-578-8000",
163
+ "hours": "Mon: 10-9:00; Tue: 10-9:00; Wed: 10-9:00; Thurs: 10-9:00; Fri: 10-10; Sat: 10-10; Sun: 10-8",
164
+ "lat": 33.035957,
165
+ "address": "2800 N Central Expy",
166
+ "distance": 23.21,
167
+ "storeId": 202
168
+ }
169
+ ],
170
+ "canonicalUrl": "\/v1\/stores(area(\"76227\",50))?format=json&apiKey=OU812",
171
+ "totalTime": "0.023"
172
+ }
@@ -0,0 +1,143 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ClientTest < Test::Unit::TestCase
4
+ include Remixr
5
+
6
+ context "Searching for stores" do
7
+ setup { @client = Remixr::Client.new('OU812') }
8
+
9
+ should "find all stores" do
10
+ stub_get '/stores?apiKey=OU812&format=json', 'stores.json'
11
+ stores = @client.stores.fetch.stores
12
+ stores.size.should == 10
13
+ stores.first.name.should == 'Caguas'
14
+ end
15
+
16
+ should "find stores by postal code as option" do
17
+ stub_get '/stores(postalCode=02184)?apiKey=OU812&format=json', 'stores_by_zip_02184.json'
18
+
19
+ stores = @client.stores({'postalCode' => '02184'}).fetch.stores
20
+ stores.size.should == 1
21
+ stores.first.name.should == 'Braintree'
22
+ end
23
+
24
+ should "find stores in zip" do
25
+ stub_get '/stores(postalCode=02184)?apiKey=OU812&format=json', 'stores_by_zip_02184.json'
26
+
27
+ stores = @client.stores.in_zip('02184').fetch.stores
28
+ stores.size.should == 1
29
+ stores.first.name.should == 'Braintree'
30
+ end
31
+
32
+ should "find stores starting with zip" do
33
+ stub_get '/stores(postalCode=021*)?apiKey=OU812&format=json', 'stores_starting_with_zip_021.json'
34
+
35
+ stores = @client.stores.in_zip('021*').fetch.stores
36
+ stores.size.should == 5
37
+ stores.first.name.should == 'Back Bay'
38
+ end
39
+
40
+ should "find stores in a region" do
41
+ stub_get '/stores(region=TX)?apiKey=OU812&format=json', 'stores_in_texas.json'
42
+
43
+ stores = @client.stores.in_region('TX').fetch.stores
44
+ stores.size.should == 10
45
+ stores.first.name.should == 'Lake Charles'
46
+ end
47
+
48
+ should "find stores within a radius of a postal code" do
49
+ stub_get '/stores(area(76227,50))?apiKey=OU812&format=json', 'stores_within_50_of_76227.json'
50
+
51
+ stores = @client.stores({'area' => [76227,50]}).fetch.stores
52
+ stores.size.should == 10
53
+ stores.first.name.should == 'Denton'
54
+ end
55
+
56
+ should "find stores matching a given list of store IDs" do
57
+ stub_get '/stores(storeId%20in(307,281,612))?apiKey=OU812&format=json', 'stores_in_list.json'
58
+
59
+ stores = @client.stores({'storeId' => {'$in' => [307,281,612]}}).fetch.stores
60
+ stores.size.should == 3
61
+ stores.first.name.should == 'Richfield'
62
+ end
63
+
64
+ end
65
+
66
+ context "Searching for products" do
67
+ setup { @client = Remixr::Client.new('OU812') }
68
+
69
+ should "find all products" do
70
+ stub_get '/products?apiKey=OU812&format=json', 'products.json'
71
+ products = @client.products.fetch.products
72
+ products.size.should == 10
73
+ products.first.sku.should == 7000032
74
+ end
75
+
76
+
77
+ should "find all products with sale price greater than twenty dollars" do
78
+ stub_get '/products(salePrice%3E20)?apiKey=OU812&format=json', 'products_over_20_bucks.json'
79
+ products = @client.products({'salePrice' => {'$gt' => 20}}).fetch.products
80
+ products.size.should == 10
81
+ products.first.sku.should == 16306454
82
+ end
83
+
84
+ should "find all products with based on search string" do
85
+ stub_get '/products(search=digital%20photo%20printer)?apiKey=OU812&format=json', 'product_search_digital_photo_printer.json'
86
+ products = @client.products({'search' => "digital photo printer"}).fetch.products
87
+ products.size.should == 2
88
+ products.first.sku.should == 4660432
89
+ end
90
+
91
+ end
92
+
93
+ context "When chaining product and store searches" do
94
+ setup { @client = Remixr::Client.new('OU812') }
95
+
96
+ should "return a products with nested stores" do
97
+ stub_get '/products(salePrice%3E3000)+stores(area(76227,50))?apiKey=OU812&format=json', 'products_over_3k_within_50_miles.json'
98
+ results = @client.products({'salePrice' => {'$gt' => 3000}}).stores({'area' => ['76227', 50]}).fetch
99
+ results.should_respond_to(:products)
100
+ results.should_not_respond_to(:stores)
101
+ results.products.first.sku.should == 9234198
102
+ end
103
+ end
104
+
105
+ context "When chaining store and product searches" do
106
+ setup { @client = Remixr::Client.new('OU812') }
107
+
108
+ should "return a products with nested stores" do
109
+ stub_get '/stores(area(76227,50))+products(salePrice%3E3000)?apiKey=OU812&format=json', 'stores_within_50_miles_products_over_3k.json'
110
+ results = @client.stores({'area' => ['76227', 50]}).products({'salePrice' => {'$gt' => 3000}}).fetch
111
+ results.stores.first.name.should == 'Denton'
112
+ results.stores.first.products.first.sku.should == 9234198
113
+ end
114
+ end
115
+
116
+ context "When using the API" do
117
+
118
+ setup { @client = Remixr::Client.new('OU812') }
119
+
120
+ should "support paging" do
121
+ stub_get '/stores?apiKey=OU812&format=json&page=20', 'stores_page_20.json'
122
+ stores = @client.stores.fetch({:page => 20}).stores
123
+ stores.size.should == 10
124
+ stores.first.storeId.should == 282
125
+ end
126
+
127
+ should "support sorting" do
128
+ stub_get '/stores?apiKey=OU812&format=json&page=20&sort=storeId.desc', 'stores_page_20_sort_by_store_id_desc.json'
129
+ stores = @client.stores.fetch({:page => 20, :sort => {'storeId' => 'desc'}}).stores
130
+ stores.size.should == 10
131
+ stores.first.storeId.should == 1159
132
+ end
133
+
134
+ should "support limiting return fields" do
135
+ stub_get '/products?apiKey=OU812&format=json&show=sku', 'products_skus_only.json'
136
+ products = @client.products.fetch({:show => 'sku'}).products
137
+ products.size.should == 10
138
+ products.first.sku.should == 7000032
139
+ products.first.format.should == nil
140
+ end
141
+
142
+ end
143
+ end
@@ -0,0 +1,36 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'matchy'
5
+ require 'mocha'
6
+ require 'fakeweb'
7
+
8
+ FakeWeb.allow_net_connect = false
9
+
10
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
11
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
12
+ require 'remixr'
13
+
14
+ class Test::Unit::TestCase
15
+ end
16
+
17
+ def fixture_file(filename)
18
+ return '' if filename == ''
19
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
20
+ File.read(file_path)
21
+ end
22
+
23
+ def remix_url(url)
24
+ url =~ /^http/ ? url : "http://api.remix.bestbuy.com:80/v1#{url}"
25
+ end
26
+
27
+ def stub_get(url, filename, status=nil)
28
+ options = {:body => fixture_file(filename)}
29
+ options.merge!({:status => status}) unless status.nil?
30
+
31
+ FakeWeb.register_uri(:get, remix_url(url), options)
32
+ end
33
+
34
+ def stub_post(url, filename)
35
+ FakeWeb.register_uri(:post, remix_url(url), :body => fixture_file(filename))
36
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: remixr-prashanth
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Wynn Netherland
8
+ - Jim Mulholland
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2009-08-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: hashie
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '2.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '2.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: httparty
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '0.13'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0.13'
42
+ - !ruby/object:Gem::Dependency
43
+ name: activesupport
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '4.0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '4.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: thoughtbot-shoulda
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: mocha
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: fakeweb
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ description: wrapper for the BestBuy Remix api
99
+ email: prashanth.rajagopal@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files:
103
+ - README.markdown
104
+ files:
105
+ - History
106
+ - License
107
+ - Notes
108
+ - README.markdown
109
+ - Rakefile
110
+ - VERSION.yml
111
+ - examples/chaining.rb
112
+ - examples/find_products.rb
113
+ - examples/find_stores.rb
114
+ - lib/remixr.rb
115
+ - lib/remixr/client.rb
116
+ - test/fixtures/product_search_digital_photo_printer.json
117
+ - test/fixtures/products.json
118
+ - test/fixtures/products_over_20_bucks.json
119
+ - test/fixtures/products_over_3k_within_50_miles.json
120
+ - test/fixtures/products_skus_only.json
121
+ - test/fixtures/stores.json
122
+ - test/fixtures/stores_by_zip_02184.json
123
+ - test/fixtures/stores_in_list.json
124
+ - test/fixtures/stores_in_texas.json
125
+ - test/fixtures/stores_page_20.json
126
+ - test/fixtures/stores_page_20_sort_by_store_id_desc.json
127
+ - test/fixtures/stores_starting_with_zip_021.json
128
+ - test/fixtures/stores_within_50_miles_products_over_3k.json
129
+ - test/fixtures/stores_within_50_of_76227.json
130
+ - test/remixr/client_test.rb
131
+ - test/test_helper.rb
132
+ homepage: http://github.com/squeejee/remixr
133
+ licenses: []
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options:
137
+ - "--charset=UTF-8"
138
+ require_paths:
139
+ - lib
140
+ required_ruby_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ requirements: []
151
+ rubyforge_project: remixr
152
+ rubygems_version: 2.2.2
153
+ signing_key:
154
+ specification_version: 3
155
+ summary: wrapper for the BestBuy Remix api
156
+ test_files:
157
+ - test/remixr/client_test.rb
158
+ - test/test_helper.rb
159
+ - examples/chaining.rb
160
+ - examples/find_products.rb
161
+ - examples/find_stores.rb
162
+ has_rdoc: