Sha256: b7af5af74362b8718bd581a70c37b0e9d09d4b332a54e1e17950bbbcaafefc3e

Contents?: true

Size: 429 Bytes

Versions: 1

Compression:

Stored size: 429 Bytes

Contents

require 'net/http'
require 'rubygems'
require 'json'

class Eotb
  
  attr_reader :http
  
  def initialize(api_key, host = '127.0.0.1', port = '3000')
    @path = '/apps/' + api_key.to_s + '/events'
    @http = Net::HTTP.new(host, port)
  end
  
  def to_json(array)
    JSON.generate(array)
  end
  
  def register_event(actor, action, subject = nil)
    @http.post(@path, [actor, action, subject].compact.to_json)
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eotb-0.1.0 lib/eotb.rb