Skip to content

Commit 615048a

Browse files
committed
Product variations
1 parent 2a40688 commit 615048a

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

examples/product-variations.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*!
2+
* This basic example shows how to update product variations
3+
*
4+
* It starts by fetching the first deal from the
5+
* account, it then fetches 10 updates of this deal.
6+
*
7+
* Usage:
8+
* node product-variations.js APITOKEN
9+
**/
10+
11+
if (!process.argv[2]) {
12+
process.stderr.write('Please provide API token!' + "\n");
13+
process.exit();
14+
}
15+
16+
var Pipedrive = require(__dirname + '/../index');
17+
var pipedrive = new Pipedrive.Client(process.argv[2]);
18+
var _ = require('lodash');
19+
20+
pipedrive.Products.getAll({start: 0, limit: 10}, function (error, data, additionalData, req, res, relatedObjects) {
21+
var product = _.first(data);
22+
product.updateVariation({
23+
id: product.product_variations[0].id,
24+
name: 'argentum',
25+
prices: [
26+
{
27+
price: 444,
28+
cost: 333,
29+
currency: 'USD'
30+
}
31+
]
32+
}, function (err, data) {
33+
console.log(err);
34+
console.log(data);
35+
});
36+
});

lib/blueprint.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ exports.apiRelatedObjects = {
7474
'deals'
7575
],
7676
'products': [
77-
'deals'
77+
'deals',
78+
'variations'
7879
],
7980
'users': [
8081
'activities',
@@ -108,7 +109,8 @@ exports.timelineableObjects = ['deals'];
108109
exports.editableSubItems = {
109110
'deals': ['products', 'followers', 'participants'],
110111
'organizations': ['followers'],
111-
'persons': ['followers']
112+
'persons': ['followers'],
113+
'products': ['variations']
112114
};
113115

114116
// Main object types that support merging action via the API.

0 commit comments

Comments
 (0)