datafiniti 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8e1ac2f35c78466d64aebd5a9fa607b2ad181d4f
4
+ data.tar.gz: 69aaf4e315c2348a6051c04dac283622e7101977
5
+ SHA512:
6
+ metadata.gz: 15a4b70eb902da06293c70f708e892834503058aad80f8f41182c944e7f27ce7161d874813cdc498439b21d771b2cfdf0065fbc24c19e4d7ba471b164d66b0dc
7
+ data.tar.gz: f04ddf156029a0fb023031c1576605c674833833a928d2f7b35ffc627069d72eebe13ac949adae8b6c95be055a408ebf9add9ee7b46411a1203286859e2c1c13
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .env
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in datafiniti.gemspec
4
+ gemspec
5
+ gem 'pry'
6
+ gem 'cucumber'
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Nick Prokesch
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,103 @@
1
+ # Datafiniti-rb
2
+
3
+ A ruby wrapper for the Datafiniti API. This gem currently supports querying for locations (including Businesses), products, and your user information. A Datafiniti API token is required for use.
4
+
5
+ ## Installation
6
+
7
+ **Gem not available yet via rubygems**
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'datafiniti', :path => '/path/to/dir/containing/datafiniti.gemspec'
11
+
12
+ And then execute:
13
+
14
+ $ bundle update
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem build datafiniti.gemspec
19
+ $ gem install datafiniti-0.1.4.gem
20
+
21
+ ## Usage
22
+
23
+ Require the gem in your project:
24
+
25
+ require 'datafiniti'
26
+
27
+ Make sure your API token is stored in a `.env` file in your project directory. The file should look like this:
28
+
29
+ # /.env
30
+ DATAFINITI_API_KEY: aaaa111122223334455667
31
+
32
+ Access your user information:
33
+
34
+ require 'datafiniti'
35
+
36
+ user = Datafiniti::User.new
37
+ # => {"token"=>"aaaa111122223334455667", "plan"=>[{"plans"=>"100000M"}], "yearly_downloads"=>"1113983", "monthly_downloads"=>"13983", "email"=>"datafiniti@example.com", "active"=>"true", "date_registered"=>"2014-07-16T20:43:23Z"}
38
+ user.email
39
+ # => "datafiniti@example.com"
40
+
41
+ Lookup businesses in Austin, TX with at least a 3-star rating:
42
+
43
+ require 'datafiniti'
44
+
45
+ # For ActiveRecord formatted search hash, just add `build: true`
46
+ three_star_businesses = Datafiniti::Locations.new(query: {city: "Austin", province: "TX", rating: {min: 3}}, build: true)
47
+
48
+ # Or, using a SOLR string query; pass false as a second argument to disable the hash-to-solr builder
49
+ three_star_businesses = Datafiniti::Locations.new(query: "city:(Austin) AND province:(TX) AND rating:([3 TO *])")
50
+
51
+ # Get total amount of locations found
52
+ three_star_businesses.total
53
+ # => 4793
54
+
55
+ # View first record from array of locations
56
+ three_star_businesses.records.first
57
+ # => {"key"=>"us/tx/austin/301e5thst", "long"=>"-97.740593", "lat"=>"30.266224", "city"=>"Austin", "province"=>"TX", "country"=>"US", "address"=>"301 E 5th St", "name"=>"Eddie V's - 5th Street", "encoding"=>"UTF-8", "type"=>"location", "phone"=>"5124721860", "postalcode"=>"78701", "dateUpdated"=>"2014-02-07T04:43:47Z", "category"=>["Barbecues", "Restaurants", "Seafood", "Steakhouse", "Seafood Restaurant Steakhouse Wine Bar", "Seafood Restaurant", "Wine Bar", "Austin Restaurants", "Downtown", "Seafood / Steak / Mexican", "Texas (tx)", "Austin", "Coffeehouses", "Banquet Rooms", "Brew Pubs"], "source"=>"http://www.ziplocal.com/page/TX/austin/eddie-vs-restaurant/1-25028126.html", "rating"=>"4.0", "numReviews"=>254.0, "numFields"=>500.0, "description"=>"If you want seafood, the buzz in town is Eddie V's Edgewater Grille. The Gulf Coast menu features lots of seafood - oysters, gulf snapper, fresh tuna, lobster, plus great prime steaks and chops. Expect a hip and high energy dining experience. Savor classic seafood starters like oysters on the half shell, fried coldwater baby lobster tail, and famous All Lump Crab Cakes. The extensive wine list features over 150 selections.", "goodfor"=>"Romance, Bar scene, Doing business, Special occasions, Entertaining clients", "paymentType"=>["MasterCard", "Discover", "Visa", "American Express"], "image"=>"http://images1.citysearch.net/assets/imgdb/profile/95/10/11431381p1.jpg", "feature"=>["SPECIALTIES: Banquets, Parties", "SPECIALTIES: Banquets", " Parties", "Cheap Eats", "Local Favorite", "People Watching", "Family-Friendly Dining", "Lunch Spot", "Breakfast", "Open 7 Days", "Bar Scene", "Business Dining", "Date Spot", "Group Dining", "Notable Wine List", "Special Occasion Dining", "Brunch", "Happy Hour"], "sic"=>"5610", "naics"=>"722511", "numCheckins"=>0.0, "numLists"=>18.0, "numSales"=>1851.0, "hasEmployeeList"=>"true", "cuisine"=>"Seafood, Steak", "price_details"=>"USD USD ", "attire"=>"Business Casual", "parking"=>"Valet", "priceRange"=>"USD 31.00-50.00", "reservations"=>"Reservations", "review"=>[{"guid"=>"d5f9fe9b5bc92def5abe57466f5ca8b6e86df008a79f7d40adf9995a0fd9cac2", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"The snapper and Jonah crab was incredible. Fresh and tasty!", "date"=>"2011-03-14T12:00:00Z"}, {"guid"=>"b8323febd7339fdd9647d638203a190e69de1bd3a71ae692e4403fb902121a7a", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"The best tuna tartare I've ever had. Everyone should eat it and be happy.", "date"=>"2010-07-26T12:00:00Z"}, {"guid"=>"b50402b7429410454107cd18ab6f756517f79f6d1562a8b2d6d82cb5e628a0c4", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"Everybody raved about the oysters being the best they had ever had. However the steak was to die for.", "date"=>"2013-09-09T12:00:00Z"}, {"guid"=>"1bdcac06df54e4a01f2e0efc79bf4f71a7548887d95c3ddde3c20e6b8fe98fae", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"Dragonberry mojitos!", "date"=>"2012-02-03T12:26:13Z"}, {"guid"=>"9685d5fc2658b37b4c5aa46453da95c0ed5919707f941535aade57f7f4d3743d", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"Try the raw oysters (via @Foodspotting)", "date"=>"2013-09-01T12:00:00Z"}, {"guid"=>"66a1421afac668f5d0d6883768e4580ae27c892a56a8dd33193c40bdb8e3d3ac", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"Visiting Austin for a conference, my friends and I were looking for some seafood and Eddie V's was recommended. It was Monday night, lucky for us the Happy Hour menu prices were good all night! Loved the Asian take on the calamari, oysters on the half-shell for a buck each and wow...can't believe the size of that crabcake for the...", "date"=>"2013-07-23T12:00:00Z"}, {"guid"=>"14d22a4ccc40b979d95fd7881f75cf63f20d78cce1395d43fc77b1e752089ed6", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"I visited Eddie V's on a Wednesday evening accompanied by my wife. We had no reservation and the place looked very busy but despite this the very pleasant greeting staff offered us a choice of tables. A good first impression. The restaurant lighting was quite dim and our server was forthcoming with a small torch to help us navigate the..."}, {"guid"=>"8b705afeea377d233085e587550fbb90c67de90cd296071b27fab07c5c1fa55b", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"While visiting in Austin, we visited EddieV's Food was wonderful. Service was great We liked so well, we went back a second time Highly recommend", "date"=>"2013-07-08T12:00:00Z"}, {"guid"=>"8ab755a5b6538864c8c19255d5f5c10146da2819bc97bb0b6c0625825afe40fb", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"All day happy hour on Sunday and Monday. Get the calamari and the lobster bisque.", "date"=>"2013-05-01T12:00:00Z"}, {"guid"=>"8652e3badb9677fdefcbbc8db48e91009f4a517c5d6f11ab18655334a2345bbe", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"In Austin for a conference and despite all the great restaurants here, had such a fabulous meal in the lounge enjoying the fabulous food and live music, we went back the following night and sat at the bar and enjoyed our meal there! Filet was delicious as was the tuna tartar for an appetizer with a wonderful ceasar salad! Martini...", "date"=>"2013-05-19T12:00:00Z"}, {"guid"=>"77ca490d5219e8e31728f76730bfa844ad7841b25c8e268e164941704dcccdc4", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"If you feel like having an elegant white gloved experience, this is it! Great food, great service. And of course prices to match!"}, {"guid"=>"ff3818ba8806df51137a0bdafabc62521dac79f138426d7dfd5bb6d303bcd413", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "date"=>"2013-07-24T12:00:00Z"}, {"guid"=>"e1e937386a0835e206d2ba6b704faa6f8a863f637be3e18e0a04aa5b489f6b0f", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "date"=>"2013-05-25T12:00:00Z"}, {"guid"=>"91922d7dce4b40deadae7421bdd26cba110665c02122668b70876092213652e5", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"Was able to walk in and be seated without a reservation. The food was very good as we're the drinks.", "date"=>"2013-09-03T12:00:00Z"}, {"guid"=>"6716a5ca2c882f965fe0f86f2a7e1832bb3172b1c711dc2f3c761dee08682ab4", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"Try the Filet Mignon - #samsungsxsw dinner (via @Foodspotting)", "date"=>"2013-11-01T12:00:00Z"}, {"guid"=>"338f9736a0a49d2702916ea29e39965ed4f56d2a22bcb32b183e2d748f4e9b14", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"Had two couples of seasoned travelers visiting from out of state and we could have chosen any place for a Friday night dinner. Boy, did we make a good call! Arrived for early Happy Hour with no reservations but they graciously took care of our party of 7 with an early seating. Everyone LOVED their meal...and four of the party...", "date"=>"2013-06-27T12:00:00Z"}, {"guid"=>"e1ce5d3990d65e10f492a8722262a67854c25b560f2fe7d51635ed89a7d76be0", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"the calamari is great!", "date"=>"2010-02-13T12:00:00Z"}, {"guid"=>"931535e5ed6b9575180dbe0518a16d857ef67d329dad13c684f8a153c0246dd7", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"We come o Eddie V's original location every time we come to Austin. Since our son started university in Austin, we will be coming more often. First, definitely choose dining room option. Here comes my only complaint, why does management allow shorts, shirt and flip flops to this beautiful and classy restaurant, at least they should be limited to the...", "date"=>"2013-08-22T12:00:00Z"}, {"guid"=>"82f0ff3ccfa171169e398c532e4ffc3685636a66c1a27d3b11b0644b4f4787cd", "sourceURL"=>"http://www.menuism.com/restaurants/eddie-vs-austin-281876", "rating"=>"5.0", "text"=>"1/2 price apps (USD 7 or less for the calamari salad, crab cake, roasted beet and apple salad, seared ahi over soba, ahi tartare, broiled oysters with spinach artichoke) USD 1 off all drinks. Happy hour 4:30-7pm", "date"=>"2007-07-05T12:00:00Z"}, {"guid"=>"553dc729d88d19c6f5a45e58d9751e4e80cbe746e62c117124fda95ad6a94aa4", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"Pacific Ahi Tuna Steak was delish and the the Long Island Ice Tea was superb! The atmosphere is classy yet relaxed and service was no disappointment.", "date"=>"2011-12-20T12:00:00Z"}, {"guid"=>"48164735f4c1cd98933f81f4ba9a72761ac8bbbdf7af49672e4dd1dd3a1715f0", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"This was our first foray into the dining in our new neighborhood and we have decided to stay after having our dinner here. We had the filet, checked for proper temperature by the server's flashlight, which was superb. Also had the Tuna entre with some fresh snap peas on the side, they did not disappoint. In addition had wine from...", "date"=>"2013-07-05T12:00:00Z"}, {"guid"=>"419e17779e0197f4082cf641cd9c4ef40f851f8be5957bd68dcdea028f09a32c", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"4.0", "text"=>"It's a tradition for my wife and I. A nice white-linen restaurant in the Arboretum area of north Austin. The food is very good (but not great) and the prices are high, but it's a good way to have a special meal. Wine list is good. Steaks are decent. Appetizers and sides are great (especially the crab cakes and truffled...", "date"=>"2013-06-08T12:00:00Z"}, {"guid"=>"1ed6009194a213db90c3317ab0610eb85a985dfef0ec1c3a748df0f91e48e4e4", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"We ate there last night for our 40th anniversary. The staff was most courteous and professional. They had rose petals and an anniversary card waiting on our table when we arrived. The food was divine, and the service Jeff provided was exceptional. The final wonderful moment was when we ordered Bananas Foster Cake. Oh, heavenly yum! A wonderfully memorable evening.", "date"=>"2013-06-17T12:00:00Z"}, {"guid"=>"0b2d0f22824f87b91ded4100077566907c11eefbaca0f546b991cfee8e06355e", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"Always an outstanding experience. We sit in the bar on Sundays or Mondays for All night happy hour specials including the full menu. Corn and crab chowder is great. NY Strip is always perfectly done to order.", "date"=>"2013-09-03T12:00:00Z"}, {"guid"=>"a3f4e29a56fbb4185255ce98bee666dc1f979825dc24a5d27393d2a8a30c2c9c", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"We went to Eddie V's in search of a fun happy hour experience, and it did not disappoint! We sat in the lounge-and had some delightful wines as well as wonderful appetizers and salads. The crab cake was huge and filled with crab over \"filling.\" The dumplings were delicious as well! I highly recommend the wedge salad with homemade dressing...."}, {"guid"=>"5a81a43a84a26b2c26847d5397246c48d06806380c086a76cc9a49638607bb3c", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"I went with my wife to this place located in Austin's downtown area near all brand known Hotels. We didn't know what to order but the waiter guided us very well. In the end my wife had an incredibly delicious crab cake as starter, I had a Jumbo Shrimp cocktail with 3 very well prepared sauces. As main courses we...", "date"=>"2013-08-13T12:00:00Z"}, {"guid"=>"344d6d7da236439d76050aec2c722932d9078e7bed0a87e5638ca6cb2daa2647", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"Two things you must try: the crab fried rice and the banana foster cake. Delish!", "date"=>"2012-02-03T12:26:13Z"}, {"guid"=>"1836d629aab1b2a254cc16b4e4a82ec6694410aa2ae0b70097c44578be88cc85", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"I was trying to remember the name of this superb establishment so I could it the killer review it deserves. Saefood in the middle of texas.. ?? I thought.. risky perhaps.. As a seafood snob I dont like my food to have to travel far... Their oysters and seabass were the best I have ever eaten. Outstanding pros: - high...", "date"=>"2013-06-15T12:00:00Z"}, {"guid"=>"faadbc019ccd62badb80948ed6c47166d11537277cf5d9cbe3362c7ea9ae4c2e", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"4.0", "date"=>"2013-09-03T12:00:00Z"}, {"guid"=>"eb80b4f5c1b1fbfa5b8409061017c163e213c33c0de78702f0d663e756820a18", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "date"=>"2013-07-13T12:00:00Z"}, {"guid"=>"a5c6bdbf084d53a0f94a46cca29d672f3ef5ed7001ba02cc060783b63d465b6f", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"Possibly some of the best steak I've ever had in my life.", "date"=>"2010-03-14T12:00:00Z"}, {"guid"=>"5e1325d4c2c33ef5e651d1011e0e821bb092afd1313519ffaed356e976890908", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"I have been to Eddie V's many time over the years and have never been disappointed. I have had steaks, and fish and all dishes were cooked to perfection. The atmosphere is outstanding and the servie is impeccable! The lobster bisque for an appetizer is outstanding! Thanks Eddie V's for always provided a great food and great service!", "date"=>"2013-06-01T12:00:00Z"}, {"guid"=>"0872126f3732dd80171d9263ac90d30f029036798ae633d6980fee86462d95ba", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"4.0", "text"=>"A business dinner with a party of six. Seated on time. A mid-week experience, but the place was packed. The waiter was very good. He obviously was experienced. He could actually have a conversation and take orders, provide other service. Even had a sense of humor. Five steaks were ordered. And one person had fish. I ordered a shrimp cocktail...", "date"=>"2013-09-01T12:00:00Z"}, {"guid"=>"032f1123cb0e2d01a7f75116b5f3b49ce76d7a5da9ab5ba034f0f4f79115fcf4", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"Michael and Shawn excellent service.", "date"=>"2011-11-13T12:00:00Z"}, {"guid"=>"9509e94186ce4b0e2cd64c8fa06a4467f97af3c7c96cd036fa8a80268dde8747", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"This was a wonderful choice for us! Party of 8 and we had great service, great food! It was delightful!"}, {"guid"=>"8c219fa1005db1cd91d2148dbd9306ee6b3adb7374bccc5564af97dd09e14b26", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"Ice cream cookie cake!", "date"=>"2011-11-09T12:00:00Z"}, {"guid"=>"4a1b2d3074c99d38d2d04b81ae6c533085dae90c113f91a9e516b85e163d6e84", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"3.0", "text"=>"Walk in and it's dimly lighted. So dimly lighted you needed a flash light to see the menu ! We went there in reviews on the steak. It was terrible . Way too much pepper. No taste. And I had the shrimp special and the shrimp on the side had a terrible A1 sauce. I wouldn't eat there again", "date"=>"2013-07-25T12:00:00Z"}, {"guid"=>"ffcc5d67037dd0ec1c9187ffd032f419110814ab1e3f2be7941a081739c55667", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "date"=>"2011-08-13T12:00:00Z"}, {"guid"=>"dd96a5d3f82a00ee76c8608e5e969462a1c448e685f5f20ceee3d65020d09f47", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"My wife and I celebrated our 15th anniversary at Eddie V's. I made a note of the special when reserving a table and they acknowledged our anniversary throughout the evening. Started with the hostess, rose petals on the table, server that was informed and a free dessert to round it out. Only negative would be the booth - it was...", "date"=>"2013-07-23T12:00:00Z"}, {"guid"=>"8557c87c170811298793f2b9fead19b00717adf8e1aa45e3f29539c8a6f34245", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"4.0", "text"=>"Nice atmosphere and good service. Our waiter was very helpful in helping us with the specials and explaining some selections. He also helped pick a wine that complemented our meals.", "date"=>"2013-06-16T12:00:00Z"}, {"guid"=>"cfd2014522660ee88d51249734576817afc6ce559e5e29f7b071afab54cc9cca", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"Awesome seafood, great flavors!", "date"=>"2010-12-22T12:00:00Z"}, {"guid"=>"c4ed148580bf55f71c154f33d4f915b06c7d5ab1b934ca1fb9c60537652bbc0f", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"4.0", "text"=>"It started rocky with a bad table and hostess didn't seam to care. But a foh manager was made aware and we were moved to a more pleasant table. Thanks!!! Sully was our server whom has waited on us before and he just blew us away with his over the top service! Food was great and cooked as we requested....", "date"=>"2013-07-22T12:00:00Z"}, {"guid"=>"383ade77b157a7f3f8c4bbff33fdb6708c7a36b3360d546adb39aecf059170fd", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"4.0", "text"=>"the food was all great. But, Corn and bacon chowder, not so much. Lobster tacos just okay. Bananas foster was the greatest surprise - with flaming rum sauce - perfect! Service was very, very good.", "date"=>"2013-05-28T12:00:00Z"}, {"guid"=>"15553eb2ffab1880e9f1075c033b7d137bfb2baff758f2a006cec2b2f6648600", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"This is the best food! I love the crusted sole and the crab fried rice. The service is always wonderful. The wait staff anticipate your every want. Last time we went on a Saturday early evening with no reservations. Got a seat in the front where it is first come, first serve. There are several tables for 2 people. Also,...", "date"=>"2013-09-03T12:00:00Z"}, {"guid"=>"f22ce4889eab227b1e6f155c98eb6d2218373782df561d6d30da5fd4d82a25b6", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "date"=>"2013-06-04T12:00:00Z"}, {"guid"=>"abd3337fc16ff092d7071a2528523532d571506f1e76137e890284de6ec6c01b", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"Filet mignon was phenomenal", "date"=>"2011-08-13T12:00:00Z"}, {"guid"=>"5bd63393866de225b6c78b6406f98b395501500826f06d6abfebff69546f7447", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"4.0", "text"=>"Had dinner twice - once was Chilean Sea Bass, one of the best meals I've had. Cooked perfectly. Next night had the rib eye, not as good as the sea bass and overcooked. Great service and atmosphere.", "date"=>"2013-05-17T12:00:00Z"}, {"guid"=>"5737c22ccacdb4997609afd6a7b5e9defb39ac17fba95bf312d58ce2d754f1e6", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"The lounge is great. They play jazz music, but not too loud so you can't enjoy your meal. Ask for Eddie as your server, nice, polite, and extremely knowledgeable.", "date"=>"2014-01-01T12:00:00Z"}, {"guid"=>"568d7a98457ecdf70d5ab1c7dd4abfb50a939735aa2e4cf90e34bc242bff13c0", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"4.0", "text"=>"Reservations for 10, anyone? Usually, we'd ask our posse to meet us at a taco shack, but we checked the reviews - and the prices weren't damaging to any decent urbanite's pocketbook - So, we made ressies - and everyone showed up...on time..yeah! OK, that's saying a lot (especially for our group) but, seriously...This elegant, smartly decorated establishment featured EVERY..."}, {"guid"=>"2bed8b56551684c61eb3053314f26add39af3b6dc079a47e4551dd15ccb06f1d", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"Our waiter, Jason, knew every item on the menu and could describe it down to the last ingredient. My filet was cooked perfectly and the creme br?l?e was to die for! (4 of 4 petals via Fondu)", "date"=>"2012-02-03T12:26:13Z"}, {"guid"=>"272fb49fab82250ea2e6867dd6fd4a325a67e59a09f3c0d7ca38f61d0a2e669f", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"We had appetizers and drinks on Sunday evening at Eddie V's downtown. We sat at the bar and the bartenders were awesome. They were quick to respond to any need. You get Happy Hour in the bar all day Sunday. We each had a couple of drinks and a couple of appetizers apiece and the bill was 40.00. For Austin,...", "date"=>"2013-08-18T12:00:00Z"}, {"guid"=>"ef3b7cfebb332751219cd542d7a357c08ce82c6ec79ec1ac864438c661ebaac4", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "date"=>"2011-03-15T12:00:00Z"}, {"guid"=>"ac32c5aa1ffdc97ebe28d1dbaf19f622111d692d082336a3455da9959e17f967", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"The live music in the bar makes you truly appreciate being in The Live Music Capital of the World. Amazing seafood and steak, best Sunday & Monday happy hour.", "date"=>"2011-12-30T12:00:00Z"}, {"guid"=>"8840970f14e0280c6fa3b58fde235466fd2acf8f5d33664b0250f6424cb28126", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"The spinach side is really good.", "date"=>"2011-02-10T12:00:00Z"}, {"guid"=>"4f57bb47a2b4c2a94b6e0afbe37d22daf82866c68e41b99ecc440a4aac5ff232", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "text"=>"Happy Hour and 1/2 price appetizers make for the perfect dinner", "date"=>"2011-07-29T12:00:00Z"}, {"guid"=>"16a205c2930d9879effae584905b041ebadf10e25542ad0c6b8802e340aba579", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"The lobster and shrimp Bisque was sublime with small slivers of lobster meat. My hubby loved his ahi sashimi appetizer. The organic sourdough bread was too good we could've dined on that alone. My filet mignon Oscar style was perfection, happy they had the hollandaise on the side for me to dole out as desired. The twice baked potato was...", "date"=>"2013-05-17T12:00:00Z"}, {"guid"=>"ffa82789536ee33ff5b69aa98bd67a944e2a1e9b5371466faa0529fad8b5e9b6", "sourceURL"=>"https://foursquare.com/v/eddie-vs-edgewater-grill/45730176f964a520833e1fe3", "date"=>"2010-07-22T12:00:00Z"}, {"guid"=>"b158b611bb4b3dc8a17ea62257fdda70d38ce750621d6b9c39d34001f961b452", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"This place is top of the line at a modestly high price but not too bad - and its worth it. It had a free Jazz band in the Lounge on a Tuesday night and it was packed at 7:00. But it emptied out for teh most part by 8:00. Food was outstanding (seafood and steaks). You cant order wrong....", "date"=>"2013-05-22T12:00:00Z"}, {"guid"=>"3a42f73454569e1153563a2cdbc296bdeece1e92b3c526123a3332e838b3ef53", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"I make it a mission in a new city to hunt out the best restaurants they have and indulge in some local fare. Well it's fair to say that that was pretty hard to do at Eddie V's as almost everything was sourced from somewhere else (seafood, maybe the beef - couldn't tell), but hey that's my only criticism. We...", "date"=>"2013-08-06T12:00:00Z"}, {"guid"=>"2c6f50f33acf3a945b76cc98ffc0e0702b99d2c679c72f2b90ca72e4d3b0d8bd", "sourceURL"=>"http://www.tripadvisor.com/Restaurant_Review-g30196-d469572-Reviews-Eddie_V_s_Edgewater_Grille-Austin_Texas.html", "rating"=>"5.0", "text"=>"Enjoyed an evening meeting with clients while in Austin. The food and atmosphere were second to none!!! Do not miss the opportunity of experiencing this restaurant. You will have no regrets........I can assure you.", "date"=>"2013-05-28T12:00:00Z"}], "neigborhood"=>"Downtown", "hour"=>"Dinner: Monday - Saturday: 5:30pm - 11p, Sunday:5:30pm - 10pm. Happy Hour: Tuesday - Saturday 4:30pm - 7:00pm All night Happy Hour Sunday & Monday in lounge. Closed Thanksgiving and Christmas.", "overall_ambience_rating"=>"4.3", "overall_food_rating"=>"4.7"}
58
+
59
+ Select only businesses with a website
60
+
61
+ three_star_businesses.select! { |business| !business.website.nil? }
62
+
63
+ Change format for download
64
+
65
+ three_star_businesses.default_to_csv
66
+ # => "csv"
67
+ three_star_businesses.default_to_json #default format
68
+ # => "json"
69
+
70
+ Create a download job
71
+
72
+ three_star_businesses.download
73
+ # => #<DataContainer state="running", message="1.00">
74
+
75
+ Check status of download
76
+
77
+ three_star_businesses.download
78
+ # => #<DataContainer state="done", message="complete", url="http://datafiniti_customer_downloads.s3.amazonaws.com/jj4dk6jp3rejqfdo8jrzmqqyltablx0j_8hdotjajoq4hw8yr.zip?AWSAccessKeyId=AKIAIGHRUU3OOUFJZARQ&Signature=WDwkgtKR4gbYmga9awG075DFRuc%3D&Expires=1407276972">
79
+
80
+ three_star_businesses.download.state
81
+ # => "done"
82
+
83
+ View download URL
84
+
85
+ three_star_businesses.download.url
86
+ # => "http://datafiniti_customer_downloads.s3.amazonaws.com/jj4dk6jp3rejqfdo8jrzmqqyltablx0j_8hdotjajoq4hw8yr.zip?AWSAccessKeyId=AKIAIGHRUU3OOUFJZARQ&Signature=WDwkgtKR4gbYmga9awG075DFRuc%3D&Expires=1407276972"
87
+
88
+ Create new query for existing object
89
+
90
+ three_star_businesses.where(city: "Houston", province: "TX", rating: 1..3)
91
+
92
+ # Or, in SOLR string format...
93
+
94
+ three_star_businesses.solr_query("city:(Houston) AND province:(TX) AND rating:([1 TO 3])")
95
+
96
+
97
+ ## Contributing
98
+
99
+ 1. Fork it ( https://github.com/datafiniti/datafiniti-rb/fork )
100
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
101
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
102
+ 4. Push to the branch (`git push origin my-new-feature`)
103
+ 5. Create a new Pull Request
@@ -0,0 +1,13 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+ require 'dotenv'
4
+ Dotenv.load
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.test_files = FileList['spec/lib/datafiniti/*_spec.rb']
8
+ t.verbose = true
9
+ end
10
+
11
+ task :default => :test
12
+
13
+
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'datafiniti/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "datafiniti"
8
+ spec.version = Datafiniti::VERSION
9
+ spec.authors = ["Nick Prokesch"]
10
+ spec.email = ["nick@datafiniti.net"]
11
+ spec.summary = %q{A ruby wrapper for the Datafiniti API}
12
+ spec.description = %q{Allows users to interface with Datafiniti API to retrieve location and product records}
13
+ spec.homepage = "http://www.datafiniti.net"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "webmock", "~> 1.18"
20
+ spec.add_development_dependency "vcr", "~> 2.9"
21
+ spec.add_dependency "dotenv", "~> 0.11"
22
+ spec.add_dependency "faraday", "~> 0.9"
23
+ spec.add_dependency "httparty", "~> 0.13"
24
+ spec.add_dependency "solr_query", "~> 1.0"
25
+ end
@@ -0,0 +1,8 @@
1
+ Feature: Handle empty results
2
+ In order to provide accurate results for all queries
3
+ as a user
4
+ I want empty results to behave like full results
5
+
6
+ Scenario: No results
7
+ When I query for something that produces no results
8
+ Then the total for the results should be 0
@@ -0,0 +1,8 @@
1
+ Feature: Escaped Queries
2
+ In order to ensure proper results
3
+ As a gem user
4
+ I want to make sure special characters in SOLR queries are properly escaped
5
+
6
+ Scenario: The Dreaded Ampersand
7
+ When I query a product for "Apple & Computers"
8
+ Then the ampsersand should be escaped
@@ -0,0 +1,20 @@
1
+ require_relative '../../lib/datafiniti'
2
+ # require 'rspec/expectations'
3
+
4
+ When(/^I query for something that produces no results$/) do
5
+ @results = Datafiniti::Products.new(query: "name: pk123kgkgj4")
6
+ end
7
+
8
+ Then(/^the total for the results should be (\d+)$/) do |arg1|
9
+ # @results.total.should == 0
10
+ puts "total: #{@results.total}"
11
+ assert @results.total == 0
12
+ end
13
+
14
+ When(/^I query a product for "(.+)"/) do |search_term|
15
+ @query = Datafiniti::Locations.new(query: "name:#{search_term}")
16
+ end
17
+
18
+ Then(/^the ampsersand should be escaped$/) do
19
+ puts @query
20
+ end
@@ -0,0 +1,15 @@
1
+ require_relative "datafiniti/version"
2
+ require "httparty"
3
+ require 'dotenv'
4
+ require 'faraday'
5
+ require 'solr_query'
6
+
7
+ module Datafiniti
8
+
9
+ Dotenv.load
10
+
11
+ Dir[File.dirname(__FILE__) + '/datafiniti/*.rb'].each do |file|
12
+ require file
13
+ end
14
+
15
+ end
@@ -0,0 +1,141 @@
1
+ require_relative 'deep_struct'
2
+
3
+ module Datafiniti
4
+
5
+ class Api
6
+ require_relative 'inflector.rb'
7
+ attr_accessor :token
8
+ attr_accessor :format
9
+ attr_accessor :conn
10
+ attr_accessor :response
11
+ attr_reader :data_type
12
+ attr_accessor :status
13
+
14
+
15
+ def initialize(args={})
16
+ query = args[:query].gsub(/\bhttp\:\/\/\b/, '*')
17
+ @format = "json"
18
+ @conn ||= Faraday.new("https://#{ENV['DATAFINITI_API_KEY']}:@api.datafiniti.co/v2/data")
19
+ @response = solr_query(query)
20
+ end
21
+
22
+ def status
23
+ @response.status
24
+ end
25
+
26
+ def records
27
+ @response.records
28
+ end
29
+
30
+ def default_to_csv
31
+ @format = "csv"
32
+ end
33
+
34
+ def default_to_json
35
+ @format = "json"
36
+ end
37
+
38
+ def preview
39
+ @response
40
+ end
41
+
42
+ def download(force=false)
43
+ query = SolrQuery.build(@query)
44
+ force ? @dl_code = get("/v2/data/locations/download?view=location_#{@format}&q=#{query}") : @dl_code ||= get("/v2/data/locations/download?view=location_#{@format}&q=#{query}")
45
+ return download_object
46
+ end
47
+
48
+ def method_missing(name, *args, &block)
49
+ @response.to_h[name.to_s]
50
+ end
51
+
52
+ def where(query)
53
+ query = build_new_query(query)
54
+ @response = get("/v2/data/#{data_type}/preview?view=#{data_type.singularize}_#{format}&q=#{query}")
55
+ update_records
56
+ return @response
57
+ end
58
+
59
+ def solr_query(query)
60
+ query = build_new_query(query, true)
61
+ @response = get("/v2/data/#{data_type}/preview?view=#{data_type.singularize}_#{format}&q=#{query}")
62
+ update_records
63
+ return @response
64
+ end
65
+
66
+ private
67
+
68
+ def data_type
69
+ self.class.to_s.downcase.split('::').last.to_s
70
+ end
71
+
72
+ def update_records
73
+ unless @response.is_a? String
74
+ @records = @response.records rescue []
75
+ @total = @response.total rescue 0
76
+ end
77
+ end
78
+
79
+ def build_new_query(query, solr=false)
80
+ @query = escape_for_solr(query)
81
+ remove_instance_variable(:@dl_code) unless @dl_code.nil?
82
+ # query = solr ? query : SolrQuery.build(query)
83
+ return @query
84
+ end
85
+
86
+ def escape_for_solr(string)
87
+ return string
88
+ .gsub("!"){"\\!"}
89
+ .gsub("?"){"\\?"}
90
+ .gsub("%"){"\\%"}
91
+ .gsub("+"){"\\+"}
92
+ .gsub("-"){"\\-"}
93
+ end
94
+
95
+ def get(uri)
96
+ error_code = {
97
+ 401 => Datafiniti::Unauthorized,
98
+ 400 => Datafiniti::BadRequest,
99
+ 404 => Datafiniti::NotFound,
100
+ 405 => Datafiniti::MethodNotAllowed,
101
+ 415 => Datafiniti::UnsupportedMediaType,
102
+ 500 => Datafiniti::InternalServerError,
103
+ 502 => Datafiniti::APIUnavailable,
104
+ 503 => Datafiniti::APIUnavailable,
105
+ 504 => Datafiniti::APIUnavailable
106
+ }
107
+ api_response = @conn.get(uri)
108
+ if api_response.status >= 400
109
+ case api_response.status
110
+ when 401 then raise Exception.new(Datafiniti::Unauthorized, api_response.status)
111
+ when 400 then raise Exception.new(Datafiniti::BadRequest, api_response.status)
112
+ when 404 then raise Exception.new(Datafiniti::NotFound, api_response.status)
113
+ when 405 then raise Exception.new(Datafiniti::MethodNotAllowed, api_response.status)
114
+ when 415 then raise Exception.new(Datafiniti::UnsupportedMediaType, api_response.status)
115
+ when 500 then raise Exception.new(Datafiniti::InternalServerError, api_response.status)
116
+ when 502 then raise Exception.new(Datafiniti::APIUnavailable, api_response.status)
117
+ when 503 then raise Exception.new(Datafiniti::APIUnavailable, api_response.status)
118
+ when 504 then raise Exception.new(Datafiniti::APIUnavailable api_response.status)
119
+ end
120
+ else
121
+ return DataContainer.new(JSON.parse(api_response.body))
122
+ end
123
+ end
124
+
125
+ def download_object
126
+ if @dl_code.split(' ').size > 1
127
+ raise RuntimeError, @dl_code
128
+ else
129
+ get("/v2/status/#{@dl_code}")
130
+ end
131
+ end
132
+
133
+ end
134
+
135
+ end
136
+
137
+ class String
138
+ def status
139
+ return 204
140
+ end
141
+ end
@@ -0,0 +1,31 @@
1
+ require 'ostruct'
2
+ class Hash
3
+ def method_missing(name, *args, &block)
4
+ self[name.to_s]
5
+ # profile.has_key?(name.to_s) ? profile.send(name.to_sym) : super
6
+ end
7
+ end
8
+ class DataContainer < OpenStruct
9
+ def initialize(hash=nil)
10
+ @table = Hash.new(nil)
11
+ @hash_table = Hash.new(nil)
12
+
13
+ if hash
14
+ hash.each do |k,v|
15
+ @table[k.to_sym] = (v.is_a?(Hash) ? self.class.new(v) : v)
16
+ @hash_table[k.to_sym] = v
17
+
18
+ new_ostruct_member(k)
19
+ end
20
+ end
21
+ end
22
+
23
+ def to_h
24
+ @hash_table
25
+ end
26
+
27
+ def status
28
+ return 204
29
+ end
30
+
31
+ end
@@ -0,0 +1,23 @@
1
+ module Datafiniti
2
+ APIUnavailable = Class.new(StandardError)
3
+ TimeoutError = Class.new(StandardError)
4
+ ServiceUnavailableError = Class.new(StandardError)
5
+ InternalServerError = Class.new(StandardError)
6
+ InvalidRequestError = Class.new(StandardError)
7
+ ServerError = Class.new(StandardError)
8
+ Unauthorized = Class.new(StandardError)
9
+ BadRequest = Class.new(StandardError)
10
+ NotFound = Class.new(StandardError)
11
+ MethodNotAllowed = Class.new(StandardError)
12
+ UnsupportedMediaType = Class.new(StandardError)
13
+ class Exception
14
+ def initialize(obj, status)
15
+ # case status
16
+ # when 503 then reason = "API is currently unavailable"
17
+ # when 500 then reason = "A server error has occurred."
18
+ # else reason = obj.name
19
+ # end
20
+ raise obj, "Something went wrong"
21
+ end
22
+ end
23
+ end