Class: Dicks::API
- Inherits:
-
Object
- Object
- Dicks::API
- Defined in:
- lib/dicks.rb
Class Method Summary collapse
Class Method Details
.get_dicks(count = 1, size = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dicks.rb', line 7 def self.get_dicks(count = 1, size = nil) uri = URI.parse("https://dicks-api.herokuapp.com/dicks/#{count}") args = {} if size != nil args[:size] = size end uri.query = URI.encode_www_form(args) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Get.new(uri.request_uri) response = http.request(request) responseHash = JSON.parse(response.body) responseHash['dicks'] || responseHash end |