class Rnotifier::Notifier
Public Class Methods
connection()
click to toggle source
# File lib/rnotifier/notifier.rb, line 5 def connection @connection ||= Faraday.new(:url => Config.api_host) do |faraday| faraday.adapter Faraday.default_adapter end end
send(data, path)
click to toggle source
# File lib/rnotifier/notifier.rb, line 11 def send(data, path) response = self.connection.post do |req| req.url(path) req.headers['Content-Type'] = 'application/json' req.headers['Api-Key'] = Config.api_key req.options[:timeout] = Config[:http_open_timeout] req.options[:open_timeout] = Config[:http_read_timeout] req.body = MultiJson.dump(data) end return true if response.status == 200 Rlogger.error("[RNOTIFIER SERVER] Response Status:#{response.status}") false ensure Rnotifier.clear_context end