Sha256: 0b9c693227cf5e88ca5a696e62bceca1ee0998fa53dc5f5c32e65a2bb4f8ac5c
Contents?: true
Size: 899 Bytes
Versions: 1
Compression:
Stored size: 899 Bytes
Contents
require 'excon' require 'base64' require 'json' require 'framed/exceptions' module Framed class Client attr_accessor :config def initialize(config) raise Error.new('No API endpoint specified') unless config[:endpoint] raise Error.new('No api_key specified') unless config[:api_key] @config = config end def track(data) Framed.log_info("Client#track #{data.length} events") creds = Base64.strict_encode64(@config[:api_key] + ':') payload = JSON.generate(data) response = Excon.post( @config[:endpoint], :headers => { 'Authorization' => "Basic #{creds}", 'Content-Type' => 'application/json' }, :body => payload ) if response.status != 200 raise Framed::RequestError.new("Failed Client.track #{response.status} with data #{payload}") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
framed_rails-0.2.0 | lib/framed/client.rb |