RdToSalesforce is a gem to be used as a bridge between RD Station and Salesforce. As of now, it can only be used to transform RD Station’s Pessoas into Salesforce’s Leads. This project was my first contact with Ruby/Ruby on Rails, so I know that there are better ways to do it and I still have lot to learn.
Add this to your Gemfile and run bundle install:
gem 'rd_to_salesforce', :git => "git://github.com/gabrielfnogueira/rd_to_salesforce.git
To run the tests, simply run rake test (note that to run the tests, you must have the file databasedotcom.yaml created. See more details below)
This gem is built using databasedotcom-rails, so for it to properly work you must create a YAML file at RAILS_ROOT/config/databasedotcom.yml file, like so
--- client_id: put-your-client-id-here client_secret: put-your-client-secret-here username: put-your-username-here password: put-your-password-here debugging: true
Just include RdToSalesforce on your controller.
Heres a controller using the class Pessoa from rd_to_salesforce.
class PessoasController < ApplicationController include RdToSalesforce before_action :set_pessoa, only: [:show, :edit, :update, :destroy] # GET /pessoas # GET /pessoas.json def index @pessoas = Pessoa.all end # GET /pessoas/1 # GET /pessoas/1.json def show end # GET /pessoas/new def new @pessoa = Pessoa.new end # GET /pessoas/1/edit def edit end # POST /pessoas # POST /pessoas.json def create @pessoa = Pessoa.new(pessoa_params) respond_to do |format| if @pessoa.create format.html { redirect_to pessoa_url(@pessoa.id), notice: 'Pessoa criada com sucesso.' } format.json { render :show, status: :created, location: pessoa_url(@pessoa.id) } else format.html { render :new } format.json { render json: @pessoa.errors, status: :unprocessable_entity } end end end # PATCH/PUT /pessoas/1 # PATCH/PUT /pessoas/1.json def update respond_to do |format| if @pessoa.update_attributes(pessoa_params) format.html { redirect_to pessoa_url(@pessoa.id), notice: 'Pessoa editada com sucesso.' } format.json { render :show, status: :ok, location: pessoa_url(@pessoa.id) } else format.html { render :edit } format.json { render json: @pessoa.errors, status: :unprocessable_entity } end end end # DELETE /pessoas/1 # DELETE /pessoas/1.json def destroy @pessoa.destroy respond_to do |format| format.html { redirect_to pessoas_url, notice: 'Pessoa excluída com sucesso.' } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. def set_pessoa @pessoa = Pessoa.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def pessoa_params params.require(:rd_to_salesforce_pessoa).permit(:name, :last_name, :email, :company, :job_title, :phone, :website, :conta_id) end end
As you can see, the class Pessoa behaves pretty much like an ActiveRecord would.
I also built a simple rails application using this gem, deployed on heroku.
rd_to_salesforce is released under the MIT License