Sha256: a3b78ac5a8583bcf00ec9ba7981c252242e7dc7e4465184712bf7d49807d80e1
Contents?: true
Size: 748 Bytes
Versions: 1
Compression:
Stored size: 748 Bytes
Contents
require 'net/http' require 'uri' require 'rubygems' require 'json' class Eotb def self.configure(api_key, host = '127.0.0.1', port = '3000') @@uri = URI.parse('http://' + host + ':' + port + '/apps/' + api_key + '/events') @@http = Net::HTTP::Post.new(@@uri.path) @@api_key = api_key end def self.register_event(actor, action, subject) to_post = { "event[app_id]" => @@api_key, "event[actor][type]" => actor, "event[action]" => action } subject.each do |key, value| to_post["event[subject][#{key.to_s}]"] = value.to_s end @@http.set_form_data(to_post) Net::HTTP.new(@@uri.host, @@uri.port).start { |http| http.request(@@http) } end def to_json(array) JSON.generate(array) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eotb-0.1.4 | lib/eotb.rb |