Class: Handiv::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/handiv/connection.rb

Constant Summary collapse

USER_AGENT =
"handiv-ruby/#{Handiv::VERSION}".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConnection

Returns a new instance of Connection.



10
11
12
# File 'lib/handiv/connection.rb', line 10

def initialize
  @connection = set_connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



8
9
10
# File 'lib/handiv/connection.rb', line 8

def connection
  @connection
end

Instance Method Details

#send_data(path, data) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/handiv/connection.rb', line 14

def send_data(path, data)
  config.verify!

  response = post_data(path, data)
  response.status
rescue => e
  Handiv.logger.error "Failed to send a message (#{e.class} - #{e.message})"
  500 # Return status
end