Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A shim for the HotUKDeals API.
Ruby
Branch: master
Failed to load latest commit information.
lib
spec Fix a spec failing pre 1.9 due to hash ordering
.gitignore
.travis.yml
Gemfile
README.md
hot_uk_deals.gemspec

README.md

HotUKDeals Build Status

This gem provides a simple Ruby interface onto the HotUKDeals API, documented at http://www.hotukdeals.com/rest-api.

Simply set your developer key and start querying the API with send_request. This returns true or false depending on whether the request was successful.

Install

gem install hot_uk_deals

Setup

require 'hot_uk_deals'

HotUKDeals.developer_key = 'your-developer-key'

Examples

# Find deals posted in the entertainment category and output their titles.
if HotUKDeals.send_request(:forum => :deals, :category => :entertainment)
  HotUKDeals.results.each { |result| puts result['title'] }
else
  puts HotUKDeals.error
end; nil

# Print the number of deals that I have personally posted.
if HotUKDeals.send_request(:username => 'cpatuzzo')
  puts HotUKDeals.total_results
else
  puts HotUKDeals.error
end; nil

# Find deals hotter than 5000, available from online retailers, ordered by submission date descending.
if HotUKDeals.send_request(:min_temp => 5000, :online_offline => :online, :order => :new)
  # Print the name of the user who posted the deal and the date that it was published.
  HotUKDeals.results.each { |result| puts "#{result['poster_name']}: #{result['submit_time']}" }
else
  raise 'Network problems, please check that you are connected to the internet!' if HotUKDeals.error =~ /network/i
  raise 'Have you forgotten to set the developer key?' if HotUKDeals.error =~ /api key/i
end; nil

# Find the 50 most recent deals containing 'holiday' and throw an exception if it fails.
HotUKDeals.send_request!(:search => 'holiday', :results_per_page => 50)
# Pull out each deal's high res image url.
holiday_images = HotUKDeals.results.map { |result| result['deal_image_highres'] }
# Generate a html document containing the images.
html_images = holiday_images.map { |url| "<img src='#{url}'/>"}
File.open('holidays.html', 'w') { |f| f.write(html_images.join("<br/>")) }
# Open the html document in your default browser.
`open holidays.html`

Contribution

Please feel free to contribute, either through pull requests or feature requests here on Github.

For news and latest updates, follow me on Twitter (@cpatuzzo).

Something went wrong with that request. Please try again.