class Cryptid::Client
Attributes
conn[W]
tracker_id[W]
Public Class Methods
new(options={})
click to toggle source
# File lib/cryptid/client.rb, line 8 def initialize(options={}) @conn = options[:conn] if options[:conn] if options[:tracker_id] @tracker_id = options[:tracker_id] else @tracker_id = Cryptid.configuration.tracker_id end end
Public Instance Methods
build_event_payload(event)
click to toggle source
# File lib/cryptid/client.rb, line 41 def build_event_payload(event) { event: Helpers.camelize(event.merge(tracker_id: tracker_id)) }.to_json end
conn()
click to toggle source
# File lib/cryptid/client.rb, line 22 def conn @conn ||= ::Excon.new(url) end
headers()
click to toggle source
# File lib/cryptid/client.rb, line 30 def headers { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } end
send(event)
click to toggle source
# File lib/cryptid/client.rb, line 37 def send(event) conn.post(body: build_event_payload(event), headers: headers) end
tracker_id()
click to toggle source
# File lib/cryptid/client.rb, line 26 def tracker_id @tracker_id or raise 'Missing tracker_id. Set in initializer or Cryptid::Client constructor' end
url()
click to toggle source
# File lib/cryptid/client.rb, line 18 def url Cryptid.configuration.url end