Git Product home page Git Product logo

salesforce_http_client's Introduction

SalesforceHttpClient

This gem provides a simple way to download report data from salesforce.com. It works well with any ruby applications, include such as Ruby on Rails.

You can access salesfore.com using only your salesforce login id (=email) and password. A security token is no need.

Data will be saved in CSV format.

Gem Version Build Status Coverage Status

Installation

Add this line to your application's Gemfile:

gem 'salesforce_http_client'

And then execute:

$ bundle

Or install it yourself as:

$ gem install salesforce_http_client

Configuring SalesforceHttpClient

Add configurations to set your salesforce.com login_id/password. You must check your salesforce.com instance to get the right domain for your account. For example: https://na12.salesforce.com/000000000000ABC, where 'http://na12.salesforce.com/' is the salesforce.com instance domain.

require 'fileutils'
require 'httpclient'

SalesforceHttpClient.configure do |config|
  config.salesforce_login_id = 'my_login_id_or_email'
  config.salesforce_password = 'my_password'
  # this parameter must be set if you are not using the default (ap.salesforce.com) instance domain of this gem.
  config.salesforce_instance_domain = 'https://na12.salesforce.com'
end

If you're using Rails, create an initializer for this:

config/initializers/salesforce_http_client.rb

Downloading report from salesforce.com

First, you need find the salesforce ID for your report. For example: http://na1.salesforce.com/000000000000ABC, where '000000000000ABC' is the salesforce ID.

Then, pass the salesforce ID and a file path to SalesforceHttpClient::Client#download_report(salesforce_id, report_save_path) method.

salesforce_id = '000000000000ABC'
report_save_path = "tmp/#{salesforce_id}.csv"

sf_client = SalesforceHttpClient::Client.new
sf_client.download_report(salesforce_id, report_save_path)

After a few seconds, you will find your report data(csv format) at report_save_path.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/salesforce_http_client/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

salesforce_http_client's People

Contributors

apuruni avatar

Stargazers

Juanito Fatas avatar なかにしゆう avatar

Watchers

James Cloos avatar  avatar

salesforce_http_client's Issues

save report to a variable?

Hi

is there any way how I can save the report to a variable only? Not to a file on the disk?

Thank you

R

how to use the gem?

Hi

any chance you can help me to use your gem?

I want to use just simple .rb script to download a report.

I installed the gem successfully by gem install gem salesforce_http_client

But now I am not sure how to use it. Below code doesn't seem to work for me.

It gives me this error

ruby getreport.rb
C:/Ruby193/lib/ruby/gems/1.9.1/gems/salesforce_http_client-0.1.3/lib/salesforce_
http_client/salesforce_http_access.rb:13:in create_http_client': uninitialized constant SalesforceHttpClient::SalesforceHttpAccess::HTTPClient (NameError) from C:/Ruby193/lib/ruby/gems/1.9.1/gems/salesforce_http_client-0.1.3/li b/salesforce_http_client/salesforce_http_access.rb:6:indownload_from_salesforc
e'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/salesforce_http_client-0.1.3/li
b/salesforce_http_client/client.rb:17:in download_report' from getreport.rb:16:in

'

require 'salesforce_http_client'

SalesforceHttpClient.configure do |config|
config.salesforce_login_id = 'my_login_id_or_email'
config.salesforce_password = 'my_password'
end

salesforce_id = '000000000000ABC'
report_save_path = "tmp/#{salesforce_id}.csv"

sf_client = SalesforceHttpClient::Client.new
sf_client.download_report(salesforce_id, report_save_path)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.