Skip to content

Commit e37148a

Browse files
author
pipedrive-bot
committed
Build 116 - version-patch
1 parent 5e3329c commit e37148a

File tree

2 files changed

+51
-64
lines changed

2 files changed

+51
-64
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ The file format of it is based on [Keep a Changelog](http://keepachangelog.com/e
77
For public Changelog covering all changes done to Pipedrive’s API, webhooks and app extensions platforms, see [public Changelog](https://pipedrive.readme.io/docs/changelog) with discussion area in [Developers Community](https://devcommunity.pipedrive.com/c/documentation/changelog/19).
88

99
## [Unreleased]
10+
### Added
11+
- Add "additionalProperties" to entities with custom fields
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
1016

1117
## [23.4.2] - 2024-10-31
1218
### Changed

README.md

Lines changed: 45 additions & 64 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,32 +56,23 @@ 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+
5965
app.listen(PORT, () => {
60-
console.log(`Listening on port ${PORT}`);
66+
console.log(`Listening on port ${PORT}`);
6167
});
6268

6369
app.get('/', async (req, res) => {
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);
70+
const api = new pipedrive.DealsApi(defaultClient);
7271
const deals = await api.getDeals();
7372

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-
}
73+
res.send(deals);
8274
});
8375

84-
8576
```
8677

8778
### With OAuth2
@@ -247,63 +238,53 @@ const cookieParser = require('cookie-parser');
247238
const cookieSession = require('cookie-session');
248239

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

258247
const pipedrive = require('pipedrive');
259248

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+
260256
app.listen(PORT, () => {
261-
console.log(`Listening on port ${PORT}`);
257+
console.log(`Listening on port ${PORT}`);
262258
});
263259

264260
app.get('/', async (req, res) => {
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-
}
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+
}
288274
});
289275

290276
app.get('/callback', (req, res) => {
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-
);
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+
});
303286
});
304287

305-
306-
307288
```
308289

309290
## Documentation for Authorization
@@ -331,7 +312,7 @@ app.get('/callback', (req, res) => {
331312
- **Type**: OAuth
332313
- **Flow**: accessCode
333314
- **Authorization URL**: https://oauth.pipedrive.com/oauth/authorize
334-
- **Scopes**:
315+
- **Scopes**:
335316
- base: Read settings of the authorized user and currencies in an account
336317
- 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)
337318
- 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)
@@ -363,7 +344,7 @@ app.get('/callback', (req, res) => {
363344

364345
All URIs are relative to *https://api.pipedrive.com/v1*
365346

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

369350
Class | Method | HTTP request | Description

0 commit comments

Comments
 (0)