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

#initialize(client) ⇒ Connection

Returns a new instance of Connection.



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

def initialize(client)
  @client = client
  @connection = set_connection
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



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

def client
  @client
end

#connectionObject (readonly)

Returns the value of attribute connection.



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

def connection
  @connection
end

Instance Method Details

#send_data(path, data = {}) ⇒ Object



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

def send_data(path, data = {})
  config.verify!

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