Class: Ribbon::Intercom::Client::SDK::Adapters::LocalAdapter
- Defined in:
- lib/ribbon/intercom/client/sdk/adapters/local_adapter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#channel_secret ⇒ Object
Returns the value of attribute channel_secret.
-
#channel_token ⇒ Object
Returns the value of attribute channel_token.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Instance Method Summary collapse
- #connect(service, params = {}) ⇒ Object
- #connected?(*args) ⇒ Boolean
-
#send_packet!(encoded_packet) ⇒ Object
Mimics an HTTP PUT.
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
#channel_secret ⇒ Object
Returns the value of attribute channel_secret.
8 9 10 |
# File 'lib/ribbon/intercom/client/sdk/adapters/local_adapter.rb', line 8 def channel_secret @channel_secret end |
#channel_token ⇒ Object
Returns the value of attribute channel_token.
7 8 9 |
# File 'lib/ribbon/intercom/client/sdk/adapters/local_adapter.rb', line 7 def channel_token @channel_token end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
6 7 8 |
# File 'lib/ribbon/intercom/client/sdk/adapters/local_adapter.rb', line 6 def service @service end |
Instance Method Details
#connect(service, params = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ribbon/intercom/client/sdk/adapters/local_adapter.rb', line 10 def connect(service, params={}) case service when Service @service = service else raise ArgumentError, "Expected a service, got: #{service.inspect}" end @channel_token = params[:channel_token] @channel_secret = params[:channel_secret] end |
#connected?(*args) ⇒ Boolean
22 23 24 |
# File 'lib/ribbon/intercom/client/sdk/adapters/local_adapter.rb', line 22 def connected?(*args) !!service end |
#send_packet!(encoded_packet) ⇒ Object
Mimics an HTTP PUT
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ribbon/intercom/client/sdk/adapters/local_adapter.rb', line 28 def send_packet!(encoded_packet) response = service.call( _http_headers.merge( 'HTTP_AUTHORIZATION' => _http_auth, 'REQUEST_METHOD' => 'PUT', 'rack.input' => StringIO.new(encoded_packet) ) ) Adapter::Response.new(response[2], response[0], response[1]) end |