Sha256: f52d3cc249b8f6ae12001fc6d09f628125741b4f37dfc9775b8eb1b1fd1bb3cf

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

require 'gooddata'
require 'salesforce_bulk'

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

4 entries across 4 versions & 1 rubygems

Version Path
gooddata-0.6.0.pre10 lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb
gooddata-0.6.0.pre9 lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb
gooddata-0.6.0.pre8 lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb
gooddata-0.6.0.pre7 lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb