Module: FlexmlsApi::Connection
- Included in:
- Client
- Defined in:
- lib/flexmls_api/connection.rb
Overview
Connection
Mixin module for handling http connection information
Instance Method Summary collapse
-
#connection(force_ssl = false) ⇒ Object
Main connection object for running requests.
-
#headers ⇒ Object
HTTP request headers for client requests.
Instance Method Details
#connection(force_ssl = false) ⇒ Object
Main connection object for running requests. Bootstraps the Faraday abstraction layer with our client configuration.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/flexmls_api/connection.rb', line 12 def connection(force_ssl = false) opts = { :headers => headers } domain = @endpoint if(force_ssl || self.ssl) opts[:ssl] = {:verify => false } opts[:url] = @endpoint.sub /^http:/, "https:" else opts[:url] = @endpoint.sub /^https:/, "http:" end conn = Faraday::Connection.new(opts) do |builder| builder.adapter Faraday.default_adapter builder.use FlexmlsApi::FaradayExt::FlexmlsMiddleware end FlexmlsApi.logger.debug("Connection: #{conn.inspect}") conn end |
#headers ⇒ Object
HTTP request headers for client requests
32 33 34 35 36 37 38 39 |
# File 'lib/flexmls_api/connection.rb', line 32 def headers { :accept => 'application/json', :content_type => 'application/json', :user_agent => Configuration::DEFAULT_USER_AGENT, Configuration::X_FLEXMLS_API_USER_AGENT => user_agent } end |