
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
pipedrive-client-nodejs-rhases-fork
Advanced tools
Pipedrive REST client for NodeJS - fix error handling related to auth
Pipedrive is a sales pipeline software that gets you organized. It's a powerful sales CRM with effortless sales pipeline management. See www.pipedrive.com for details.
This is the official Pipedrive API wrapper-client for NodeJS based apps, distributed by Pipedrive Inc freely under the MIT licence. It provides you with basic functionality for operating with objects such as Deals, Persons, Organizations, Products and much more, without having to worry about the underlying networking stack and actual HTTPS requests.
npm install pipedrive
With a pre-set API token:
var Pipedrive = require('pipedrive');
var pipedrive = new Pipedrive.Client('YOUR_API_TOKEN_HERE', { strictMode: true });
Here's a quick example that will list some deals from your Pipedrive account:
var Pipedrive = require('pipedrive');
var pipedrive = new Pipedrive.Client('YOUR_API_TOKEN_HERE', { strictMode: true });
pipedrive.Deals.getAll({}, function(err, deals) {
if (err) throw err;
for (var i = 0; i < deals.length; i++) {
console.log(deals[i].title + ' (worth ' + deals[i].value + ' ' + deals[i].currency + ')');
}
});
Fetches the possible API tokens for the given user against email and password, passing error, data, additionalData
to the callback function. You can use the API tokens returned by this method to instantiate the API client by issuing var pipedrive = new Pipedrive.Client('API_TOKEN_HERE', { strictMode: true })
.
Add an object. Returns error, data
to the callback where data contains the id
property of the newly created item.
Get specific object. Returns error, object
Update an object. Returns error
in case of an error to the callback.
Get all objects, optionally passing additional parameters (such as filter_id
in case of deals, persons and organizations). Returns error, objects
to the callback function where objects is a collection (array) of objects.
Delete an object with a specifc ID. Returns error
in case of an error to the callback.
Delete multiple objects using an array of IDs. Returns error
in case of an error to the callback.
Merge two objects of the same kind. Returns error
in case of an error to the callback. Merge is only supported for the following objects:
Find objects of certain kind by their name/title, using term
property supplied inside params object. Supported for:
Returns the value of [fieldName] of the object.
Sets a new value of [fieldName] of the object. Returns {object}.
Updates the state of the {object} in Pipedrive via the API. Returns {object}.
Deletes the {object} in Pipedrive via the API. Returns error
in case of an error to the callback.
Merges the {object} with another object of the same kind with the ID given as withId
. Returns error
in case of error to the callback. Merge is only supported for the following objects:
To add a product to a deal, simply invoke the addProduct
method on a deal object.
pipedrive.Deals.get(1, function(err, deal) {
if (err) throw err;
deal.addProduct({ product_id: 1, quantity: 5, discount: 20 }, function(addErr, addData) {
if (addErr) throw addErr;
console.log('Product 1 was added to deal 1', addData);
});
})
To add multiple products with a single request, make the first argument of deal's addProduct
method (as shown above) an array, e.g. [{ product_id: 1, quantity: 5, discount: 0 }, { product_id: 1, quantity: 2, discount: 20 }]
. This will add two product rows to a deal — one with a quantity of 5 and with no discount, the latter will add a separate row for the same product but with a quantity of 2 and no discount.
pipedrive.Deals.get(deal_id, function(err, deal) {
if (err) throw err;
deal.getProducts(function(productsErr, attachedProducts) {
if (productsErr) throw productsErr;
attachedProducts.forEach(function(attachedProduct) {
deal.updateProduct({ id: attachedProduct.id, quantity: 5, discount: 20 }, function(updateErr, updateData) {
if (updateErr) throw updateErr;
console.log('Product was updated', updateData);
});
});
});
})
Updating multiple deal products in one request is not supported yet.
pipedrive.Deals.get(deal_id, function(err, deal) {
if (err) throw err;
deal.getProducts(function(productsErr, attachedProducts) {
if (productsErr) throw productsErr;
attachedProducts.forEach(function(attachedProduct) {
deal.deleteProduct({ id: attachedProduct.id }, function(removeErr, removeSuccess) {
if (!removeErr) console.log('Removed product ' + attachedProduct.product_id + ' from deal 1');
});
});
});
})
There is an additional method to perform the SearchResults/field
search. This can be used for field-value searches.
The following example searches for deals that match the condition where org_id=123
pipedrive.SearchResults.field({
term: "123",
exact_match: true,
field_key: "org_id",
field_type: "dealField",
return_item_ids: true
}), callback);
You can request all entries for an valid object using getAll(object, callback)
pipedrive.getAll('Organizatons', function (err, collection) {
// collection contains all Organizations
});
pipedrive.getAll('Persons', function (err, collection) {
// collection contains all Persons
});
var Pipedrive = require('pipedrive');
var pipedrive = new Pipedrive.Client('PUT_YOUR_API_TOKEN_HERE', { strictMode: true });
pipedrive.Filters.getAll({ type: 'deals' }, function(filtersListErr, filtersList) {
if (filtersList.length > 0) {
pipedrive.Deals.getAll({ filter_id: filtersList[0].get('id'), start: 0, limit: 15 }, function(dealsListErr, dealsList) {
dealsList.forEach(function(deal) {
console.log(deal.get('title') + ' (worth ' + deal.get('value') + ' ' + deal.get('currency') + ')');
});
})
}
});
The API client lets you create event listeners to specific data changes in your Pipedrive account. This is very similar to Webhooks, except the listeners are bound on an ad hoc basis and will only be executed during the lifecycle of your application. For example (see below) you may want to execute a callback every time a new deal is added to Pipedrive. Note that this callback will execute not only when you create the deal through this API client but regardless of where the deal was added from — a mobile app, the web app or through the Pipedrive API by some other integration.
var Pipedrive = require('pipedrive');
var pipedrive = new Pipedrive.Client('PUT_YOUR_API_TOKEN_HERE', { strictMode: true });
pipedrive.on('deal.added', function(event, data) {
console.log('A deal was added! ' + data.current.title + ' (' + data.current.value + ' ' + data.current.currency + ')');
});
Supported event names consist of object type (deal, person, organization, ...) and type of change (added
, deleted
, updated
or merged
), joined by a dot. The list of supported object types are listed in the Pipedrive Webhooks documentation.
To read more about ad hoc data change event listeners, check out examples/live-updates.js.
The Pipedrive REST API documentation can be found at https://developers.pipedrive.com/v1
#Testing
To run unit tests, execute npm run tests
This Pipedrive API client is distributed under the MIT licence.
FAQs
Pipedrive REST client for NodeJS - fix error handling related to auth
We found that pipedrive-client-nodejs-rhases-fork demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.