Class: Ribbon::Intercom::Client::SDK::Adapters::HttpAdapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/ribbon/intercom/client/sdk/adapters/http_adapter.rb

Defined Under Namespace

Classes: Connection

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Adapter

#call, #dup, #headers, #initialize, #send_packet

Constructor Details

This class inherits a constructor from Ribbon::Intercom::Client::SDK::Adapters::Adapter

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



6
7
8
# File 'lib/ribbon/intercom/client/sdk/adapters/http_adapter.rb', line 6

def connection
  @connection
end

Instance Method Details

#connect(*args) ⇒ Object



8
9
10
# File 'lib/ribbon/intercom/client/sdk/adapters/http_adapter.rb', line 8

def connect(*args)
  @_connection_args = args.dup
end

#connected?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/ribbon/intercom/client/sdk/adapters/http_adapter.rb', line 12

def connected?
  !!connection
end

#send_packet!(encoded_packet) ⇒ Object

Send the encoded packet up to the service via an HTTP PUT.



22
23
24
25
26
27
28
29
# File 'lib/ribbon/intercom/client/sdk/adapters/http_adapter.rb', line 22

def send_packet!(encoded_packet)
  response = connection.put(
    headers: headers,
    body:    encoded_packet
  )

  Adapter::Response.new(response.body, response.code.to_i, response)
end