def connection opts={}
      connection = Faraday.new(opts) do |conn|

        if opts[:force_urlencoded]
          conn.request :url_encoded
        else
          conn.request :json
        end

        conn.request :json
        conn.use FaradayMiddleware::FollowRedirects
        conn.use FaradayMiddleware::Mashify
        conn.use FaradayMiddleware::ParseJson, :content_type => /\bjson$/
        conn.use FaradayMiddleware::ParseXml, :content_type => /\bxml$/
        conn.adapter adapter
      end

      connection.headers[:user_agent] = user_agent
      connection
    end
def connection opts={}
      connection = Faraday.new(opts) do |conn|

        if opts[:force_urlencoded]
          conn.request :url_encoded
        else
          conn.request :json
        end

        conn.request :json
        conn.use FaradayMiddleware::FollowRedirects
        conn.use FaradayMiddleware::Mashify
        conn.use FaradayMiddleware::ParseJson, :content_type => /\bjson$/
        conn.use FaradayMiddleware::ParseXml, :content_type => /\bxml$/
        conn.adapter adapter
      end

      connection.headers[:user_agent] = user_agent
      connection
    end
Create a connection to send request