Module: Growatt::Connection
- Included in:
- API
- Defined in:
- lib/growatt/connection.rb
Overview
Create connection and use cookies for authentication tokens
Instance Method Summary collapse
Instance Method Details
#connection ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/growatt/connection.rb', line 7 def connection raise ConfigurationError, "Option for endpoint is not defined" unless endpoint = @connection ||= Faraday::Connection.new() do |connection| connection.use :cookie_jar connection.use Faraday::Response::RaiseError connection.adapter Faraday.default_adapter (connection) setup_headers(connection) connection.response :json, content_type: /\bjson$/ connection.use Faraday::Request::UrlEncoded setup_logger_filtering(connection, logger) if logger end end |