Class: Listo::Connection
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Listo::Connection
- Defined in:
- lib/listo/connection.rb
Instance Method Summary collapse
-
#initialize(token, debug_mode: false) ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize(token, debug_mode: false) ⇒ Connection
Returns a new instance of Connection.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/listo/connection.rb', line 7 def initialize(token, debug_mode: false) @debug_mode = debug_mode connection = Faraday.new(url: url) do |faraday| faraday.use Listo::Middleware::RaiseError faraday.request :json faraday.response :json, content_type: 'application/json' faraday.adapter Faraday.default_adapter end connection.headers['Authorization'] = "Token #{token}" connection.headers['Content-Type'] = 'application/json' connection.headers['Accept'] = 'application/json' super(connection) end |