Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
gingr / lib / gingr / connection.rb
Size: Mime:
require 'faraday_middleware'
Dir[File.expand_path('../../faraday/*.rb', __FILE__)].each{|f| require f}

module Gingr
  module Connection
    private

    def generate_endpoint(company_app_name)
      return "https://#{company_app_name}.gingrapp.com/"
    end

    def connection
      company_app_name = self.company_app_name
      options = {
        :url => "#{generate_endpoint(company_app_name)}"
      }

      # TODO: Remove or update the GingrAuth middleware as needed. See the faraday/auth.rb
      # TODO: file for additional information.
      Faraday::Connection.new(options) do |connection|
        connection.use FaradayMiddleware::GingrAuth, api_key, company_app_name
        connection.use FaradayMiddleware::Mashify
        connection.use Faraday::Response::ParseJson
        connection.adapter(adapter)
        # Gingr API requires x-form-www-urlencoded request parameters
        connection.request  :url_encoded
        connection.response :logger if logging
      end
    end
  end
end