Module: Apphunkd::Remote
- Includes:
- HTTParty
- Defined in:
- lib/apphunkd/remote.rb,
lib/apphunkd/remote/result.rb
Defined Under Namespace
Classes: Result
Class Method Summary collapse
Class Method Details
.post_message(url, payload = {}, post_timeout = 60) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/apphunkd/remote.rb', line 12 def (url, payload = {}, post_timeout = 60) begin payload.delete(:token) Timeout.timeout(post_timeout) do result = Remote::Result.new(self.post(url, :body => payload)) result.status = :ok return result end rescue SocketError => e return Remote::Result.new(:status => :connection_error, :response => "SocketError: #{e.inspect}") rescue Errno::ECONNREFUSED => e return Remote::Result.new(:status => :connection_error, :response => "ConnRefused: #{e.inspect}") rescue Timeout::Error => e return Remote::Result.new(:status => :timeout, :response => "Timeout: #{e.inspect}") end end |