class IcobenchClient
Constants
- BASE_URL
- SSL
Public Class Methods
new(private_key = nil, public_key = nil, params = {})
click to toggle source
# File lib/icobench/icobench_client.rb, line 11 def initialize(private_key = nil, public_key = nil, params = {}) @private_key = private_key @public_key = public_key end
Public Instance Methods
get_data(url)
click to toggle source
# File lib/icobench/icobench_client.rb, line 66 def get_data(url) uri = URI.parse(url) https = Net::HTTP.new(uri.host, uri.port) if SSL https.use_ssl = true https.verify_mode = OpenSSL::SSL::VERIFY_NONE end req = Net::HTTP::Post.new(uri.request_uri) req['X-ICObench-Key'] = @public_key req['X-ICObench-Sig'] = Base64.strict_encode64(OpenSSL::HMAC.digest('sha384', @private_key, '')).force_encoding("utf-8") https.set_debug_output $stderr res = https.request(req) JSON.parse(res.body) end
icos()
click to toggle source
# File lib/icobench/icobench_client.rb, line 16 def icos url = "#{BASE_URL}icos/all" get_data(url) end
icos_filters()
click to toggle source
# File lib/icobench/icobench_client.rb, line 21 def icos_filters url = "#{BASE_URL}icos/filters" get_data(url) end
people_all()
click to toggle source
# File lib/icobench/icobench_client.rb, line 51 def people_all url = "#{BASE_URL}people/all" get_data(url) end
people_expert()
click to toggle source
# File lib/icobench/icobench_client.rb, line 56 def people_expert url = "#{BASE_URL}people/expert" get_data(url) end
people_registered()
click to toggle source
# File lib/icobench/icobench_client.rb, line 61 def people_registered url = "#{BASE_URL}people/registered" get_data(url) end
profile(params)
click to toggle source
# File lib/icobench/icobench_client.rb, line 36 def profile(params) if params[:id] url = "#{BASE_URL}ico/#{params[:id]}" get_data(url) elsif params[:url] url = "#{BASE_URL}ico/#{params[:url]}" end get_data(url) end
ratings()
click to toggle source
# File lib/icobench/icobench_client.rb, line 31 def ratings url = "#{BASE_URL}icos/ratings" get_data(url) end
stats()
click to toggle source
# File lib/icobench/icobench_client.rb, line 46 def stats url = "#{BASE_URL}other/stats" get_data(url) end
trending()
click to toggle source
# File lib/icobench/icobench_client.rb, line 26 def trending url = "#{BASE_URL}icos/trending" get_data(url) end