Sha256: 53ce9679f534ee4a1feb718a87991f5d907a8e930f3b1cfce6b1a7c8ed228f49
Contents?: true
Size: 858 Bytes
Versions: 1
Compression:
Stored size: 858 Bytes
Contents
require "remetric/version" require "base64" require "json" require "rest_client" class Remetric def initialize api_key, sandbox = false @rm_api_key = api_key @rm_sandbox = sandbox end def api_key @rm_api_key end def track data = {} begin RestClient.get "#{endpoint}/track/img/#{to_base64 data}"; rescue { errors: "You are unauthorized." } end end def img data = {} src = "#{endpoint}/track/img/#{to_base64 data}"; img = "<img src=\"#{src}\" style=\"display: none; \">"; img end def redirect data = {} "#{endpoint}/track/redirect/#{to_base64 data}"; end def to_base64 data = {} data["events_api_key"] = api_key URI.escape Base64.encode64(JSON.generate(data)) end def endpoint @rm_sandbox ? "http://localhost:3000" : "https://secure.remetric.com" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
remetric-0.0.11 | lib/remetric.rb |