Skip to content

Commit e41859d

Browse files
Merge branch 'master' into GRAL-4650
2 parents 142b51e + 5ac1837 commit e41859d

File tree

4 files changed

+75
-49
lines changed

4 files changed

+75
-49
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ For public Changelog covering all changes done to Pipedrive’s API, webhooks an
88

99
## [Unreleased]
1010

11+
## [23.4.2] - 2024-10-31
12+
### Changed
13+
- Updated the code examples in the README for the JavaScript SDK
14+
### Added
15+
- Add "custom_fields" query paremeter to GET /api/v2/products
16+
1117
## [23.4.1] - 2024-10-09
1218

1319
### Changed
@@ -703,7 +709,8 @@ structure
703709
* Fixed `GET /goal/:id/results` error handling in case when there are no existing stages connected to specified goal
704710
* Fixed typo in lead example response (`crrency` to `currency`)
705711

706-
[Unreleased]: https://github.com/pipedrive/api-docs/compare/v23.4.1...HEAD
712+
[Unreleased]: https://github.com/pipedrive/api-docs/compare/v23.4.2...HEAD
713+
[23.4.2]: https://github.com/pipedrive/api-docs/compare/v23.4.1...v23.4.2
707714
[23.4.1]: https://github.com/pipedrive/api-docs/compare/v23.4.0...v23.4.1
708715
[23.4.0]: https://github.com/pipedrive/api-docs/compare/v23.3.0...v23.4.0
709716
[23.3.0]: https://github.com/pipedrive/api-docs/compare/v23.2.5...v23.3.0

README.md

Lines changed: 64 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ See www.pipedrive.com for details.
66
This is the official Pipedrive API wrapper-client for NodeJS based apps, distributed by Pipedrive Inc freely under the MIT licence.
77
It provides convenient access to the Pipedrive API, allowing you to operate with objects such as Deals, Persons, Organizations, Products and much more.
88

9-
## Table of Contents
9+
## Table of Contents
1010
- [Installation](#installation)
1111

1212
- [API Reference](#api-reference)
@@ -56,23 +56,32 @@ const pipedrive = require('pipedrive');
5656

5757
const PORT = 1800;
5858

59-
const defaultClient = new pipedrive.ApiClient();
60-
61-
// Configure API key authorization: apiToken
62-
let apiToken = defaultClient.authentications.api_key;
63-
apiToken.apiKey = 'YOUR_API_TOKEN_HERE';
64-
6559
app.listen(PORT, () => {
66-
console.log(`Listening on port ${PORT}`);
60+
console.log(`Listening on port ${PORT}`);
6761
});
6862

6963
app.get('/', async (req, res) => {
70-
const api = new pipedrive.DealsApi(defaultClient);
64+
try {
65+
const apiClient = new pipedrive.ApiClient();
66+
67+
// Configure API key authorization: apiToken
68+
let apiToken = apiClient.authentications.api_key;
69+
apiToken.apiKey = 'YOUR_API_TOKEN_HERE';
70+
71+
const api = new pipedrive.DealsApi(apiClient);
7172
const deals = await api.getDeals();
7273

73-
res.send(deals);
74+
return res.send(deals);
75+
} catch (error) {
76+
console.error('Error:', error);
77+
78+
res.status(500).json({
79+
error: error.message,
80+
});
81+
}
7482
});
7583

84+
7685
```
7786

7887
### With OAuth2
@@ -238,53 +247,63 @@ const cookieParser = require('cookie-parser');
238247
const cookieSession = require('cookie-session');
239248

240249
app.use(cookieParser());
241-
app.use(cookieSession({
250+
app.use(
251+
cookieSession({
242252
name: 'session',
243-
keys: ['key1']
244-
}));
253+
keys: ['key1'],
254+
}),
255+
);
245256
const PORT = 1800;
246257

247258
const pipedrive = require('pipedrive');
248259

249-
const apiClient = new pipedrive.ApiClient();
250-
251-
let oauth2 = apiClient.authentications.oauth2;
252-
oauth2.clientId = 'clientId'; // OAuth 2 Client ID
253-
oauth2.clientSecret = 'clientSecret'; // OAuth 2 Client Secret
254-
oauth2.redirectUri = 'http://localhost:1800/callback'; // OAuth 2 Redirection endpoint or Callback Uri
255-
256260
app.listen(PORT, () => {
257-
console.log(`Listening on port ${PORT}`);
261+
console.log(`Listening on port ${PORT}`);
258262
});
259263

260264
app.get('/', async (req, res) => {
261-
if (req.session.accessToken !== null && req.session.accessToken !== undefined) {
262-
// token is already set in the session
263-
// now make API calls as required
264-
// client will automatically refresh the token when it expires and call the token update callback
265-
const api = new pipedrive.DealsApi(apiClient);
266-
const deals = await api.getDeals();
267-
268-
res.send(deals);
269-
} else {
270-
const authUrl = apiClient.buildAuthorizationUrl();;
271-
272-
res.redirect(authUrl);
273-
}
265+
const apiClient = new pipedrive.ApiClient();
266+
267+
let oauth2 = apiClient.authentications.oauth2;
268+
oauth2.clientId = 'clientId'; // OAuth 2 Client ID
269+
oauth2.clientSecret = 'clientSecret'; // OAuth 2 Client Secret
270+
oauth2.redirectUri = 'http://localhost:1800/callback'; // OAuth 2 Redirection endpoint or Callback Uri
271+
272+
if (
273+
req.session.accessToken !== null &&
274+
req.session.accessToken !== undefined
275+
) {
276+
// token is already set in the session
277+
// now make API calls as required
278+
// client will automatically refresh the token when it expires and call the token update callback
279+
const api = new pipedrive.DealsApi(apiClient);
280+
const deals = await api.getDeals();
281+
282+
res.send(deals);
283+
} else {
284+
const authUrl = apiClient.buildAuthorizationUrl();
285+
286+
res.redirect(authUrl);
287+
}
274288
});
275289

276290
app.get('/callback', (req, res) => {
277-
const authCode = req.query.code;
278-
const promise = apiClient.authorize(authCode);
279-
280-
promise.then(() => {
281-
req.session.accessToken = apiClient.authentications.oauth2.accessToken;
282-
res.redirect('/');
283-
}, (exception) => {
284-
// error occurred, exception will be of type src/exceptions/OAuthProviderException
285-
});
291+
const authCode = req.query.code;
292+
const promise = apiClient.authorize(authCode);
293+
294+
promise.then(
295+
() => {
296+
req.session.accessToken = apiClient.authentications.oauth2.accessToken;
297+
res.redirect('/');
298+
},
299+
(exception) => {
300+
// error occurred, exception will be of type src/exceptions/OAuthProviderException
301+
},
302+
);
286303
});
287304

305+
306+
288307
```
289308

290309
## Documentation for Authorization
@@ -312,7 +331,7 @@ app.get('/callback', (req, res) => {
312331
- **Type**: OAuth
313332
- **Flow**: accessCode
314333
- **Authorization URL**: https://oauth.pipedrive.com/oauth/authorize
315-
- **Scopes**:
334+
- **Scopes**:
316335
- base: Read settings of the authorized user and currencies in an account
317336
- deals:read: Read most of the data about deals and related entities - deal fields, products, followers, participants; all notes, files, filters, pipelines, stages, and statistics. Does not include access to activities (except the last and next activity related to a deal)
318337
- deals:full: Create, read, update and delete deals, its participants and followers; all files, notes, and filters. It also includes read access to deal fields, pipelines, stages, and statistics. Does not include access to activities (except the last and next activity related to a deal)
@@ -344,7 +363,7 @@ app.get('/callback', (req, res) => {
344363

345364
All URIs are relative to *https://api.pipedrive.com/v1*
346365

347-
Code examples are available through the links in the list below or on the
366+
Code examples are available through the links in the list below or on the
348367
[Pipedrive Developers Tutorials](https://pipedrive.readme.io/docs/tutorials) page
349368

350369
Class | Method | HTTP request | Description

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pipedrive",
3-
"version": "23.4.1",
3+
"version": "23.4.2",
44
"description": "Pipedrive REST client for NodeJS",
55
"license": "MIT",
66
"main": "dist/index.js",

0 commit comments

Comments
 (0)