Code Monkey home page Code Monkey logo

rd_to_salesforce's Introduction

RdToSalesforce

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.

Installation

Add this to your Gemfile and run bundle install:

gem 'rd_to_salesforce', :git => "git://github.com/gabrielfnogueira/rd_to_salesforce.git

Testing

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)

Usage

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.

Example

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.

License

rd_to_salesforce is released under the MIT License

rd_to_salesforce's People

Contributors

gabrielfnogueira avatar

Watchers

 avatar  avatar

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.