0.0
No commit activity in last 3 years
No release in over 3 years
Pipedrive API wrapper
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

Pipedrive API wrapper for Ruby on Rails.

Installation

Add this line to your application's Gemfile:

gem 'pipe_rocket'

And then execute:

bundle

Or install it yourself as:

gem install pipe_rocket

Setup

#config/initializers/pipedrive.rb

ENV['pipedrive_api_token'] = '[YOUR_API_TOKEN]'
CUSTOM_FIELD_NAMES = {
  deal: {
    b6be1824d9...90fea09: 'name'
  }
}

CUSTOM_FIELD_NAMES - hash, which overrides custom field names from server. If you want to have same names as remote, just assign empty hash({}).

Usage

Methods

All api methods returns PipeRocket::Entity heir objects. They have attr_accessor methods for all fields, returned by API. Custom fields can be accessed by their name(not key) or by name specified in CUSTOM_FIELD_NAMES.

Via Pipedrive class you can work with the following models:

  • deals
  • deal_fields
  • notes
  • organizations
  • organization_fields
  • persons
  • person_fields
  • pipelines
  • stages

Get all records

Pipedrive.deals.all

Get record by id

Pipedrive.deals.find([id])

Create record

Pipedrive.deals.create([hash])

Update record

Pipedrive.deals.update([hash])

Get persons by email

Pipedrive.persons.find_by_email([email])

PipeRocket::Deal

deal = Pipedrive.deals.find([id]) #PipeRocket::Deal object

deal.files #File objects, attached to deal, including files from email messages.
deal.files.first.url #S3 url by which you can directly download file from Amazon.

deal.stage #PipeRocket::Stage object
deal.display_stage_name #deal stage (e.g. Sales:Contact Made)

PipeRocket::Stage

stage = Pipedrive.stages.find([id]) #PipeRocket::Stage object

stage.display_name #stage name(e.g. Sales:Contact Made)

stage.pipeline #PipeRocket::Pipeline object

Webhooks

Gem provides way to receive webhooks from Pipedrive. Endpoint url should looks like this:

host/pipedrive/[object]/[action]

For example:

host/pipedrive/deal/updated

If event happens gem send ActiveSupport::Notification like 'deal_updated' with related object.

Handle events

#config/initializers/events.rb

ActiveSupport::Notifications.subscribe '[object]_[action]' do |*args|
  event = ActiveSupport::Notifications::Event.new(*args)
  [object] = event.payload[:[object]] #PipeRocket::[object] object
end

e.g

ActiveSupport::Notifications.subscribe 'deal_updated' do |*args|
  event = ActiveSupport::Notifications::Event.new(*args)
  deal = event.payload[:deal] #PipeRocket::Deal object
end

This will work with deal, note, organization, person, pipeline, stage, user objects and all event actions.

Exceptions

If there is no connection or Pipedrive API returns error code, gem raises PipeRocket::Error. Error object has field code which contains HTTP error code(e.g. 400, 404, 408)

Credits

Sponsored by JetRockets.

enter image description here

License

Please see LICENSE for licensing details.