Class: Ribbon::Intercom::Client::SDK::Adapters::HttpAdapter::Connection
- Inherits:
-
Object
- Object
- Ribbon::Intercom::Client::SDK::Adapters::HttpAdapter::Connection
- Defined in:
- lib/ribbon/intercom/client/sdk/adapters/http_adapter/connection.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url, token, secret) ⇒ Connection
constructor
A new instance of Connection.
- #put(params = {}) ⇒ Object
Constructor Details
#initialize(url, token, secret) ⇒ Connection
Returns a new instance of Connection.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ribbon/intercom/client/sdk/adapters/http_adapter/connection.rb', line 10 def initialize(url, token, secret) @url = url.is_a?(String) ? URI(url) : url @_client = Net::HTTP.new(@url.hostname, @url.port) @_client.use_ssl = @url.is_a?(URI::HTTPS) @_client.verify_mode = OpenSSL::SSL::VERIFY_PEER @_client.cert_store = OpenSSL::X509::Store.new.tap { |s| s.set_default_paths } @_headers = { 'Authorization' => "Basic #{Base64.strict_encode64("#{token}:#{secret}")}" } end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/ribbon/intercom/client/sdk/adapters/http_adapter/connection.rb', line 8 def url @url end |
Instance Method Details
#put(params = {}) ⇒ Object
23 24 25 |
# File 'lib/ribbon/intercom/client/sdk/adapters/http_adapter/connection.rb', line 23 def put(params={}) @_client.put(url.request_uri, params[:body], _prepare_headers(params[:headers]).merge(@_headers)) end |