def setup(opts = {}, &blk)
      opts[:url] = opts.delete(:base_uri) if opts.include?(:base_uri) # Support legacy :base_uri option
      @options = opts

      faraday_options = @options.select { |key, _| FARADAY_OPTIONS.include?(key.to_sym) }
      @connection = Faraday.new(faraday_options) do |connection|
        yield connection if block_given?
      end
      self
    end
def setup(opts = {}, &blk)
      opts[:url] = opts.delete(:base_uri) if opts.include?(:base_uri) # Support legacy :base_uri option
      @options = opts

      faraday_options = @options.select { |key, _| FARADAY_OPTIONS.include?(key.to_sym) }
      @connection = Faraday.new(faraday_options) do |connection|
        yield connection if block_given?
      end
      self
    end
Create a new API object. This is useful to create multiple APIs and use them with the `uses_api` method.
 If your application uses only one API, you should use Her::API.setup to configure the default API

 @example Setting up a new API
   api = Her::API.new :url => "https://api.example" do |connection|
     connection.use Faraday::Request::UrlEncoded
     connection.use Her::Middleware::DefaultParseJSON
   end

   class User
     uses_api api
   end
 Setup the API connection.

 @param [Hash] opts the Faraday options
 @option opts [String] :url The main HTTP API root (eg. `https://api.example.com`)
 @option opts [String] :ssl A hash containing [SSL options](https://github.com/lostisland/faraday/wiki/Setting-up-SSL-certificates)

 @return Faraday::Connection

 @example Setting up the default API connection
   Her::API.setup :url => "https://api.example"

 @example A custom middleware added to the default list
   class MyAuthentication < Faraday::Middleware
     def call(env)
       env[:request_headers]["X-API-Token"] = "bb2b2dd75413d32c1ac421d39e95b978d1819ff611f68fc2fdd5c8b9c7331192"
       @app.call(env)
     end
   end
   Her::API.setup :url => "https://api.example.com" do |connection|
     connection.use Faraday::Request::UrlEncoded
     connection.use Her::Middleware::DefaultParseJSON
     connection.use MyAuthentication
     connection.use Faraday::Adapter::NetHttp
   end

 @example A custom parse middleware
   class MyCustomParser < Faraday::Response::Middleware
     def on_complete(env)
       json = JSON.parse(env[:body], :symbolize_names => true)
       errors = json.delete(:errors) || {}
       metadata = json.delete(:metadata) || []
       env[:body] = { :data => json, :errors => errors, :metadata => metadata }
     end
   end
   Her::API.setup :url => "https://api.example.com" do |connection|
     connection.use Faraday::Request::UrlEncoded
     connection.use MyCustomParser
     connection.use Faraday::Adapter::NetHttp
   end