Module: Legion::Extensions::Nautobot::Helpers::Client

Instance Method Summary collapse

Instance Method Details

#connection(url: nil, token: nil, **_opts) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/legion/extensions/nautobot/helpers/client.rb', line 10

def connection(url: nil, token: nil, **_opts)
  Faraday.new(url: url) do |conn|
    conn.request :json
    conn.response :json, content_type: /\bjson$/
    conn.headers['Authorization'] = "Token #{token}" if token
    conn.headers['Content-Type'] = 'application/json'
    conn.headers['Accept'] = 'application/json'
  end
end