Pipedrive::Connect provides a convenient access to the Pipedrive API from applications written in the Ruby language.
It abstracts the developer from having to deal with API requests by mapping the list of the core resources like Organization, Person or Deal to ruby classes and objects.
Key features:
- Easy to setup.
- Map core concepts in Pipedrive to ruby classes.
- Allow access to relationships among these concepts like accessing all the persons within an organization or its deals.
- Abstract the developer from having to deal with custom fields by doing it internally.
Check the original API doc at: https://pipedrive.readme.io/
Add this line to your application's Gemfile:
gem "pipedrive-connect", github: "getonbrd/pipedrive-connect"
then execute:
$ bundle install
Or install it yourself as:
$ gem install pipedrive-connect
Configure the library by initializing it with the api key you can find in your setttings page at Pipedrive.
Pipedrive.api_key = "abc123"
In case of using rails, do it via an initalizer:
# file: app/initializers/pipedrive.rb
require 'pipedrive'
Pipedrive.api_key = ENV["PIPEDRIVE_API_KEY"]
Access your data in pipedrive via the models (for the complete list check out the directory lib/pipedrive/resources
). You'll find that most of these classes are documented in the API Reference.
For example to search, retrieve, access, create, update or delete an organization:
# search for organizations with the term "Acme Inc" in any of their fields
# return an array of Pipedrive::Organization instances
orgs = Pipedrive::Organization.search("Acme Inc")
# specify it is an exact match and reduce the scope to name and address
orgs = Pipedrive::Organization.search(
"Acme Inc",
extact_match: true,
fields: [:name, :address]
)
# Want to paginate across all the organizations sorting them by name?
orgs = Pipedrive::Organization.all(
"Acme Inc",
start: 0,
limit: 100,
sort: :name
)
# if you know the id then retrieve the org
acme = Pipedrive::Organization.retrieve(123)
acme.name
# get access to the activities, deals and persons of the org
acme.activities
acme.deals
acme.persons
# create a new one
new_branch = Pipedrive::Organization.create(name: "New Acme Inc")
# update the name
new_acme.update(name: "Acme the new Inc")
# ot simply delete it
new_acme.delete
Pipedrive gives you the chance to add additional data by creating custom fields that are not included by default. Deals, Persons, Organizations and Products can all contain custom fields.
The issue with accessing a custom field via the API is that you have to know the assigned key, for instance, let's say we added a custom field called domain
of type text to the Organization
in Pipedrive. If we would want to add a new organization using the API, this "would" be the code:
org = Pipedrive::Organization.create(
name: "Acme Inc",
"sab55f505ca47dda0b4811f9ea5df00020540b80": "acme.com"
)
Yeah, we know what you are thinking, not convinient at all. Well, we definitely think the same, so we fixed it by abstracting us (the devs) from having to know such key.
So, using Pipedrive::Connect it is as it should always be:
org = Pipedrive::Organization.create(
name: "Acme Inc",
domain: "acme.com"
)
# By the way, in case you are curious and want to know what all the fields
# within an Organization are, just call:
org.fields
# or, this works too
Pipedrive::Organization.fields
Show basic debugging info:
Pipedrive.debug = true
show extended HTTP traffic information:
Pipedrive.debug_http = true
# and to also show the body payloads
Pipedrive.debug_http_body = true
Run the set up:
$ bundle
Run the specs:
$ bundle exec rspec
Run the linter:
$ bundle exec rubocop
- Fork it.
- Create your feature branch (git checkout -b my-new-feature).
- Commit your changes (git commit -am 'Add some feature').
- Push to the branch (git push origin my-new-feature).
- Create a new Pull Request.
Bug reports and pull requests are welcome on GitHub at https://github.com/getonbrd/pipedrive-connect. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
Everyone interacting in the Pipedrive::Connect project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.