Skip to content

Commit

Permalink
Build 116 - version-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
pipedrive-bot committed Nov 22, 2024
1 parent 5e3329c commit e37148a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 64 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ The file format of it is based on [Keep a Changelog](http://keepachangelog.com/e
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).

## [Unreleased]
### Added
- Add "additionalProperties" to entities with custom fields
### Changed
- Updated the code examples in the README for the JavaScript SDK
### Added
- Add "custom_fields" query paremeter to GET /api/v2/products

## [23.4.2] - 2024-10-31
### Changed
Expand Down
109 changes: 45 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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 convenient access to the Pipedrive API, allowing you to operate with objects such as Deals, Persons, Organizations, Products and much more.

## Table of Contents
## Table of Contents
- [Installation](#installation)

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

const PORT = 1800;

const defaultClient = new pipedrive.ApiClient();

// Configure API key authorization: apiToken
let apiToken = defaultClient.authentications.api_key;
apiToken.apiKey = 'YOUR_API_TOKEN_HERE';

app.listen(PORT, () => {
console.log(`Listening on port ${PORT}`);
console.log(`Listening on port ${PORT}`);
});

app.get('/', async (req, res) => {
try {
const apiClient = new pipedrive.ApiClient();

// Configure API key authorization: apiToken
let apiToken = apiClient.authentications.api_key;
apiToken.apiKey = 'YOUR_API_TOKEN_HERE';

const api = new pipedrive.DealsApi(apiClient);
const api = new pipedrive.DealsApi(defaultClient);
const deals = await api.getDeals();

return res.send(deals);
} catch (error) {
console.error('Error:', error);

res.status(500).json({
error: error.message,
});
}
res.send(deals);
});


```

### With OAuth2
Expand Down Expand Up @@ -247,63 +238,53 @@ const cookieParser = require('cookie-parser');
const cookieSession = require('cookie-session');

app.use(cookieParser());
app.use(
cookieSession({
app.use(cookieSession({
name: 'session',
keys: ['key1'],
}),
);
keys: ['key1']
}));
const PORT = 1800;

const pipedrive = require('pipedrive');

const apiClient = new pipedrive.ApiClient();

let oauth2 = apiClient.authentications.oauth2;
oauth2.clientId = 'clientId'; // OAuth 2 Client ID
oauth2.clientSecret = 'clientSecret'; // OAuth 2 Client Secret
oauth2.redirectUri = 'http://localhost:1800/callback'; // OAuth 2 Redirection endpoint or Callback Uri

app.listen(PORT, () => {
console.log(`Listening on port ${PORT}`);
console.log(`Listening on port ${PORT}`);
});

app.get('/', async (req, res) => {
const apiClient = new pipedrive.ApiClient();

let oauth2 = apiClient.authentications.oauth2;
oauth2.clientId = 'clientId'; // OAuth 2 Client ID
oauth2.clientSecret = 'clientSecret'; // OAuth 2 Client Secret
oauth2.redirectUri = 'http://localhost:1800/callback'; // OAuth 2 Redirection endpoint or Callback Uri

if (
req.session.accessToken !== null &&
req.session.accessToken !== undefined
) {
// token is already set in the session
// now make API calls as required
// client will automatically refresh the token when it expires and call the token update callback
const api = new pipedrive.DealsApi(apiClient);
const deals = await api.getDeals();

res.send(deals);
} else {
const authUrl = apiClient.buildAuthorizationUrl();

res.redirect(authUrl);
}
if (req.session.accessToken !== null && req.session.accessToken !== undefined) {
// token is already set in the session
// now make API calls as required
// client will automatically refresh the token when it expires and call the token update callback
const api = new pipedrive.DealsApi(apiClient);
const deals = await api.getDeals();

res.send(deals);
} else {
const authUrl = apiClient.buildAuthorizationUrl();;

res.redirect(authUrl);
}
});

app.get('/callback', (req, res) => {
const authCode = req.query.code;
const promise = apiClient.authorize(authCode);

promise.then(
() => {
req.session.accessToken = apiClient.authentications.oauth2.accessToken;
res.redirect('/');
},
(exception) => {
// error occurred, exception will be of type src/exceptions/OAuthProviderException
},
);
const authCode = req.query.code;
const promise = apiClient.authorize(authCode);

promise.then(() => {
req.session.accessToken = apiClient.authentications.oauth2.accessToken;
res.redirect('/');
}, (exception) => {
// error occurred, exception will be of type src/exceptions/OAuthProviderException
});
});



```

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

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

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

Class | Method | HTTP request | Description
Expand Down

0 comments on commit e37148a

Please sign in to comment.