Sha256: 6f693a96049fd885a1e7a4a42587dc91bd0a840e38f25582b9c02a7684baff49

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'salesforce_bulk'

require File.join(File.dirname(__FILE__), "base_middleware")

module GoodData::Bricks
  class BulkSalesforceMiddleware < GoodData::Bricks::Middleware

    def call(params)

      username      = params[:salesforce_username]
      password      = params[:salesforce_password]
      token         = params[:salesforce_token]
      client_id     = params[:salesforce_client_id]
      client_secret = params[:salesforce_client_secret]
      host          = params[:salesforce_host]

      credentials = {}

      credentials = if (username && password && token)
        {
          :username       => username,
          :password       => password,
          :security_token => token
        }
      end

      client = if credentials
        credentials.merge!({
          :client_id      => client_id,
          :client_secret  => client_secret,
        })
        credentials[:host] = host unless host.nil?
        SalesforceBulk::Api.new(credentials[:username], credentials[:password] + credentials[:security_token])
      end
      @app.call(params.merge(:salesforce_bulk_client => client))
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gooddata-0.6.0.pre11 lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb