Sha256: e9f5345a701e16eab1182a558fbf51e1a9d2d38feda703427d02b0061bbf04ba
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
require "httparty" module Pushkin class Client include HTTParty def initialize(api_url, api_token) @options = { headers: { "Authorization" => "Bearer #{api_token}", "Accept-Language" => "en", "Accept" => "application/json", "Content-Type" => "application/json", "User-Agent" => "Pushkin v#{Pushkin::VERSION}", "Client-Language" => "ruby", "Client-Language-Version" => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})", "Client-Platform" => RUBY_PLATFORM, "Client-Engine" => defined?(RUBY_ENGINE) ? RUBY_ENGINE : "", "Client-Hostname" => Socket.gethostname, "Client-Pid" => Process.pid.to_s, "Client-Thread" => Thread.current.object_id.to_s } } @api_url = api_url end def push(data) body = prepare_data(data) @options = @options.merge(body: body) self.class.post("#{@api_url}/api/events/", @options) end private def prepare_data(data) data.merge( pushed_at: DateTime.current, service_identifier: Rails.application.class.module_parent_name ).to_json end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pushkin-logger-0.1.0 | lib/pushkin/client.rb |