pipedrive 22.3.1-rc.3 → 22.3.1-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -3
- package/README.md +29 -24
- package/base.ts +26 -21
- package/configuration.ts +17 -5
- package/dist/base.d.ts +5 -2
- package/dist/base.js +22 -17
- package/dist/configuration.d.ts +1 -0
- package/dist/configuration.js +14 -4
- package/dist/esm/base.d.ts +5 -2
- package/dist/esm/base.js +19 -17
- package/dist/esm/configuration.d.ts +1 -0
- package/dist/esm/configuration.js +15 -5
- package/docs/ActivityTypeObjectResponse.md +2 -2
- package/docs/AddWebhookRequest.md +1 -1
- package/docs/BaseUser.md +1 -0
- package/docs/BaseUserMe.md +1 -0
- package/docs/BasicDeal.md +3 -0
- package/docs/ChangelogResponse.md +11 -0
- package/docs/ChangelogResponseAllOf.md +10 -0
- package/docs/ChangelogResponseAllOfData.md +16 -0
- package/docs/DealParticipantsChangelog.md +12 -0
- package/docs/DealsApi.md +120 -0
- package/docs/Field.md +3 -2
- package/docs/ListPermittedUsersResponse.md +0 -1
- package/docs/NewDeal.md +3 -0
- package/docs/OrganizationsApi.md +60 -0
- package/docs/ParticipantsChangelog.md +11 -0
- package/docs/ParticipantsChangelogItem.md +12 -0
- package/docs/PaymentItem.md +2 -2
- package/docs/PersonsApi.md +60 -0
- package/docs/ProductField.md +1 -0
- package/docs/ProductFieldAllOf.md +1 -0
- package/docs/SubscriptionItem.md +2 -2
- package/docs/UpdateDealRequest.md +3 -0
- package/migration.md +309 -0
- package/package.json +1 -1
- package/test/functional/authorisation.test.js +22 -31
- package/test/functional/automatic-token-refresh.test.js +7 -6
- package/test/functional/utils.js +0 -1
- package/src/api/MeetingsApi.js +0 -181
- package/src/model/GetDealRelatedObjects.js +0 -101
- package/src/model/PostDealParticipantsRelatedObjects.js +0 -90
- package/src/model/UserProviderLinkCreateRequest.js +0 -120
- package/src/model/UserProviderLinkErrorResponse.js +0 -90
- package/src/model/UserProviderLinkSuccessResponse.js +0 -90
- package/src/model/UserProviderLinkSuccessResponseData.js +0 -79
package/CHANGELOG.md
CHANGED
@@ -8,9 +8,31 @@ For public Changelog covering all changes done to Pipedrive’s API, webhooks an
|
|
8
8
|
|
9
9
|
## [Unreleased]
|
10
10
|
|
11
|
-
## [22.3.1-rc.
|
11
|
+
## [22.3.1-rc.5] - 2024-04-24
|
12
12
|
- Add `lead_id` as an acceptable body parameter for the `POST /v1/callLogs` endpoint
|
13
13
|
|
14
|
+
|
15
|
+
## [22.3.1-rc.5] - 2024-02-12
|
16
|
+
- Add TypeScript Support
|
17
|
+
|
18
|
+
|
19
|
+
## [22.6.1] - 2024-04-18
|
20
|
+
### Added
|
21
|
+
- Added `is_deleted` parameter for `/v1/users/*` responses.
|
22
|
+
|
23
|
+
## [22.6.0] - 2024-04-05
|
24
|
+
### Added
|
25
|
+
- Added documentation for new endpoints `/deals/{id}/changelog`, `/persons/{id}/changelog` and `/organizations/{id}/changelog`.
|
26
|
+
|
27
|
+
|
28
|
+
## [22.5.0] - 2024-02-02
|
29
|
+
### Added
|
30
|
+
- Added documentation for new endpoint `/deals/{id}/participantsChangelog`.
|
31
|
+
|
32
|
+
## [22.4.0] - 2024-01-05
|
33
|
+
### Added
|
34
|
+
- Added documentation for `/meetings/userProviderLinks` endpoints
|
35
|
+
|
14
36
|
## [22.3.1-rc.2] - 2023-12-22
|
15
37
|
|
16
38
|
## [22.3.1-rc.1] - 2023-12-22
|
@@ -595,8 +617,12 @@ structure
|
|
595
617
|
* Fixed `GET /goal/:id/results` error handling in case when there are no existing stages connected to specified goal
|
596
618
|
* Fixed typo in lead example response (`crrency` to `currency`)
|
597
619
|
|
598
|
-
[Unreleased]: https://github.com/pipedrive/api-docs/compare/v22.3.1-rc.
|
599
|
-
[22.3.1-rc.
|
620
|
+
[Unreleased]: https://github.com/pipedrive/api-docs/compare/v22.3.1-rc.5...HEAD
|
621
|
+
[22.3.1-rc.5]: https://github.com/pipedrive/api-docs/compare/v22.3.1-rc.4...v22.3.1-rc.5
|
622
|
+
[22.3.1-rc.4]: https://github.com/pipedrive/api-docs/compare/v22.3.1-rc.3...v22.3.1-rc.4
|
623
|
+
[22.5.0]: https://github.com/pipedrive/api-docs/compare/v22.4.0...v22.5.0
|
624
|
+
[22.6.0]: https://github.com/pipedrive/api-docs/compare/v22.5.0...v22.6.0
|
625
|
+
[22.6.1]: https://github.com/pipedrive/api-docs/compare/v22.6.0...v22.6.1
|
600
626
|
[22.4.0]: https://github.com/pipedrive/api-docs/compare/v22.3.0...v22.4.0
|
601
627
|
[22.3.0]: https://github.com/pipedrive/api-docs/compare/v22.2.0...v22.3.0
|
602
628
|
[22.2.0]: https://github.com/pipedrive/api-docs/compare/v22.1.0...v22.2.0
|
package/README.md
CHANGED
@@ -27,7 +27,7 @@ import { Configuration, DealsApi } from "pipedrive";
|
|
27
27
|
|
28
28
|
const app = express();
|
29
29
|
|
30
|
-
const PORT =
|
30
|
+
const PORT = 3000;
|
31
31
|
|
32
32
|
// Configure Client with API key authorization
|
33
33
|
const apiConfig = new Configuration({
|
@@ -41,7 +41,7 @@ app.listen(PORT, () => {
|
|
41
41
|
app.get("/", async (req, res) => {
|
42
42
|
const dealsApi = new DealsApi(apiConfig);
|
43
43
|
const response = await dealsApi.getDeals();
|
44
|
-
const { data: deals } = response
|
44
|
+
const { data: deals } = response;
|
45
45
|
|
46
46
|
res.send(deals);
|
47
47
|
});
|
@@ -68,7 +68,7 @@ import { OAuth2Configuration, Configuration } from 'pipedrive';
|
|
68
68
|
const oauth2 = new OAuth2Configuration({
|
69
69
|
clientId: "clientId", // OAuth 2 Client ID
|
70
70
|
clientSecret: "clientSecret", // OAuth 2 Client Secret
|
71
|
-
redirectUri: 'redirectUri'
|
71
|
+
redirectUri: 'redirectUri' // OAuth 2 Redirection endpoint or Callback Uri
|
72
72
|
});
|
73
73
|
|
74
74
|
const apiConfig = new Configuration({
|
@@ -183,9 +183,9 @@ It then redirects back to the base endpoint for calling endpoints from the SDK.
|
|
183
183
|
```typescript
|
184
184
|
|
185
185
|
import express from "express";
|
186
|
-
import cookieParse from "cookie-parser";
|
187
|
-
import cookeSession from "cookie-session";
|
188
186
|
import { Configuration, DealsApi, OAuth2Configuration } from "pipedrive";
|
187
|
+
import cookieParser from "cookie-parser";
|
188
|
+
import cookieSession from "cookie-session";
|
189
189
|
|
190
190
|
const app = express();
|
191
191
|
|
@@ -195,26 +195,21 @@ app.use(cookieSession({
|
|
195
195
|
keys: ["key1"]
|
196
196
|
}));
|
197
197
|
|
198
|
-
const PORT =
|
198
|
+
const PORT = 3000;
|
199
199
|
|
200
200
|
|
201
201
|
const oauth2 = new OAuth2Configuration({
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
});
|
206
|
-
|
207
|
-
const apiConfig = new Configuration({
|
208
|
-
accessToken: oauth2.getAccessToken,
|
209
|
-
basePath: oauth2.basePath,
|
202
|
+
clientId: "clientId", // OAuth 2 Client ID
|
203
|
+
clientSecret: "clientSecret", // OAuth 2 Client Secret
|
204
|
+
redirectUri: 'redirectUri' // OAuth 2 Redirection endpoint or Callback Uri
|
210
205
|
});
|
211
206
|
|
212
|
-
|
213
207
|
app.listen(PORT, () => {
|
214
|
-
|
208
|
+
console.log(`Listening on port ${PORT}`);
|
215
209
|
});
|
216
210
|
|
217
211
|
app.get('/', async (req, res) => {
|
212
|
+
try {
|
218
213
|
// method will handle return null if token is not available in the session
|
219
214
|
const token = oauth2.updateToken(req.session?.accessToken);
|
220
215
|
|
@@ -232,19 +227,29 @@ app.get('/', async (req, res) => {
|
|
232
227
|
// token is already set in the session
|
233
228
|
// now make API calls as required
|
234
229
|
// client will automatically refresh the token when it expires and call the token update callback
|
235
|
-
const
|
230
|
+
const dealsApi = new DealsApi(apiConfig)
|
231
|
+
|
236
232
|
const response = await dealsApi.getDeals();
|
237
|
-
const { data: deals } = response
|
233
|
+
const { data: deals } = response;
|
238
234
|
|
239
|
-
res.send(deals);
|
235
|
+
return res.send(deals);
|
236
|
+
} catch (error){
|
237
|
+
console.error(error)
|
238
|
+
return res.status(500).send(error)
|
239
|
+
}
|
240
240
|
});
|
241
241
|
|
242
242
|
app.get('/callback', async (req, res) => {
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
243
|
+
try {
|
244
|
+
const authCode = req.query.code as string;
|
245
|
+
const newAccessToken = await oauth2.authorize(authCode);
|
246
|
+
|
247
|
+
req.session.accessToken = newAccessToken;
|
248
|
+
return res.redirect("/");
|
249
|
+
}catch (error) {
|
250
|
+
console.error(error)
|
251
|
+
return res.status(500).send(error)
|
252
|
+
}
|
248
253
|
});
|
249
254
|
|
250
255
|
```
|
package/base.ts
CHANGED
@@ -16,8 +16,8 @@
|
|
16
16
|
import type { Configuration } from './configuration';
|
17
17
|
// Some imports not used depending on template conditions
|
18
18
|
// @ts-ignore
|
19
|
-
import type {
|
20
|
-
import
|
19
|
+
import type { AxiosError, AxiosResponse, AxiosRequestConfig , InternalAxiosRequestConfig } from 'axios';
|
20
|
+
import axios from 'axios';
|
21
21
|
|
22
22
|
export const BASE_PATH = "https://api.pipedrive.com/v1".replace(/\/+$/, "");
|
23
23
|
|
@@ -41,26 +41,28 @@ export interface RequestArgs {
|
|
41
41
|
url: string;
|
42
42
|
options: AxiosRequestConfig;
|
43
43
|
}
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
|
45
|
+
export const versionInterceptor = (config:InternalAxiosRequestConfig) => {
|
46
|
+
let version:string;
|
47
|
+
try {
|
48
|
+
version = require('../package.json').version;
|
49
|
+
} catch (error) {
|
50
|
+
version = '22.x';
|
51
|
+
}
|
49
52
|
config.headers['User-Agent'] = `Pipedrive-SDK-Javascript-${version}`;
|
50
53
|
return config;
|
51
|
-
}
|
54
|
+
}
|
52
55
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
});
|
56
|
+
export const responseInterceptor = (response: AxiosResponse) => {
|
57
|
+
return response?.data ? response.data: response;
|
58
|
+
};
|
59
|
+
|
60
|
+
export const errorInterceptor = (error: AxiosError) => {
|
61
|
+
if (error.response && error.response.data) {
|
62
|
+
return Promise.reject(error.response.data);
|
63
|
+
}
|
64
|
+
return Promise.reject(error);
|
65
|
+
};
|
64
66
|
|
65
67
|
/**
|
66
68
|
*
|
@@ -70,13 +72,16 @@ globalAxios.interceptors.response.use(function (response) {
|
|
70
72
|
export class BaseAPI {
|
71
73
|
protected configuration: Configuration | undefined;
|
72
74
|
protected basePath: string = BASE_PATH;
|
73
|
-
protected axios =
|
74
|
-
|
75
|
+
protected axios = axios.create();
|
75
76
|
constructor(configuration: Configuration) {
|
76
77
|
if (configuration) {
|
77
78
|
this.configuration = configuration;
|
78
79
|
this.basePath = configuration.basePath || this.basePath;
|
79
80
|
}
|
81
|
+
|
82
|
+
|
83
|
+
this.axios.interceptors.response.use(responseInterceptor, errorInterceptor);
|
84
|
+
this.axios.interceptors.request.use(versionInterceptor);
|
80
85
|
}
|
81
86
|
};
|
82
87
|
|
package/configuration.ts
CHANGED
@@ -13,8 +13,9 @@
|
|
13
13
|
*/
|
14
14
|
|
15
15
|
|
16
|
-
import
|
16
|
+
import axios from "axios";
|
17
17
|
import { stringify } from "qs";
|
18
|
+
import { errorInterceptor, responseInterceptor, versionInterceptor } from './base';
|
18
19
|
|
19
20
|
export type TokenResponse = {
|
20
21
|
access_token: string;
|
@@ -35,6 +36,7 @@ export interface Parameters {
|
|
35
36
|
export type ParamKey = keyof Parameters;
|
36
37
|
|
37
38
|
export class OAuth2Configuration {
|
39
|
+
private axios = axios.create();
|
38
40
|
private host: string;
|
39
41
|
private accessToken: string | null = null;
|
40
42
|
private refreshToken: string | null = null;
|
@@ -53,6 +55,9 @@ export class OAuth2Configuration {
|
|
53
55
|
this.clientSecret = this.validateParam(params, 'clientSecret');
|
54
56
|
this.redirectUri = this.validateParam(params, 'redirectUri');
|
55
57
|
this.host = params.host || "https://oauth.pipedrive.com";
|
58
|
+
|
59
|
+
this.axios.interceptors.response.use(responseInterceptor, errorInterceptor);
|
60
|
+
this.axios.interceptors.request.use(versionInterceptor);
|
56
61
|
}
|
57
62
|
|
58
63
|
public get authorizationUrl() {
|
@@ -88,7 +93,7 @@ export class OAuth2Configuration {
|
|
88
93
|
`${this.clientId}:${this.clientSecret}`
|
89
94
|
).toString("base64");
|
90
95
|
|
91
|
-
const response = await
|
96
|
+
const response = await this.axios.post(
|
92
97
|
authorizationUrl,
|
93
98
|
stringify({
|
94
99
|
code,
|
@@ -115,7 +120,7 @@ export class OAuth2Configuration {
|
|
115
120
|
`${this.clientId}:${this.clientSecret}`
|
116
121
|
).toString("base64");
|
117
122
|
|
118
|
-
const response = await
|
123
|
+
const response = await this.axios.post(
|
119
124
|
refreshUrl,
|
120
125
|
stringify({
|
121
126
|
refresh_token: this.refreshToken,
|
@@ -187,7 +192,7 @@ export class OAuth2Configuration {
|
|
187
192
|
const revokeUrl = `${this.host}/oauth/revoke?`;
|
188
193
|
const clientIdAndSecretInBase64 = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
|
189
194
|
|
190
|
-
const response = await
|
195
|
+
const response = await this.axios.post(
|
191
196
|
revokeUrl,
|
192
197
|
stringify({
|
193
198
|
token,
|
@@ -206,7 +211,14 @@ export class OAuth2Configuration {
|
|
206
211
|
}
|
207
212
|
|
208
213
|
private getUserAgent = () => {
|
209
|
-
|
214
|
+
let version;
|
215
|
+
|
216
|
+
try {
|
217
|
+
version = require('../package.json').version;
|
218
|
+
} catch (error) {
|
219
|
+
version = '22.x';
|
220
|
+
}
|
221
|
+
|
210
222
|
return `Pipedrive-SDK-Javascript-${version}`;
|
211
223
|
};
|
212
224
|
|
package/dist/base.d.ts
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
* Do not edit the class manually.
|
11
11
|
*/
|
12
12
|
import type { Configuration } from './configuration';
|
13
|
-
import type { AxiosRequestConfig } from 'axios';
|
13
|
+
import type { AxiosError, AxiosResponse, AxiosRequestConfig, InternalAxiosRequestConfig } from 'axios';
|
14
14
|
export declare const BASE_PATH: string;
|
15
15
|
/**
|
16
16
|
*
|
@@ -31,6 +31,9 @@ export interface RequestArgs {
|
|
31
31
|
url: string;
|
32
32
|
options: AxiosRequestConfig;
|
33
33
|
}
|
34
|
+
export declare const versionInterceptor: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig<any>;
|
35
|
+
export declare const responseInterceptor: (response: AxiosResponse) => any;
|
36
|
+
export declare const errorInterceptor: (error: AxiosError) => Promise<never>;
|
34
37
|
/**
|
35
38
|
*
|
36
39
|
* @export
|
@@ -39,7 +42,7 @@ export interface RequestArgs {
|
|
39
42
|
export declare class BaseAPI {
|
40
43
|
protected configuration: Configuration | undefined;
|
41
44
|
protected basePath: string;
|
42
|
-
protected axios: import("axios").
|
45
|
+
protected axios: import("axios").AxiosInstance;
|
43
46
|
constructor(configuration: Configuration);
|
44
47
|
}
|
45
48
|
/**
|
package/dist/base.js
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
* Do not edit the class manually.
|
14
14
|
*/
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
16
|
-
exports.RequiredError = exports.BaseAPI = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
|
16
|
+
exports.RequiredError = exports.BaseAPI = exports.errorInterceptor = exports.responseInterceptor = exports.versionInterceptor = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
|
17
17
|
const axios_1 = require("axios");
|
18
18
|
exports.BASE_PATH = "https://api.pipedrive.com/v1".replace(/\/+$/, "");
|
19
19
|
/**
|
@@ -26,26 +26,29 @@ exports.COLLECTION_FORMATS = {
|
|
26
26
|
tsv: "\t",
|
27
27
|
pipes: "|",
|
28
28
|
};
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
const versionInterceptor = (config) => {
|
30
|
+
let version;
|
31
|
+
try {
|
32
|
+
version = require('../package.json').version;
|
33
|
+
}
|
34
|
+
catch (error) {
|
35
|
+
version = '22.x';
|
36
|
+
}
|
34
37
|
config.headers['User-Agent'] = `Pipedrive-SDK-Javascript-${version}`;
|
35
38
|
return config;
|
36
|
-
}
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
if ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) {
|
39
|
+
};
|
40
|
+
exports.versionInterceptor = versionInterceptor;
|
41
|
+
const responseInterceptor = (response) => {
|
42
|
+
return (response === null || response === void 0 ? void 0 : response.data) ? response.data : response;
|
43
|
+
};
|
44
|
+
exports.responseInterceptor = responseInterceptor;
|
45
|
+
const errorInterceptor = (error) => {
|
46
|
+
if (error.response && error.response.data) {
|
45
47
|
return Promise.reject(error.response.data);
|
46
48
|
}
|
47
49
|
return Promise.reject(error);
|
48
|
-
}
|
50
|
+
};
|
51
|
+
exports.errorInterceptor = errorInterceptor;
|
49
52
|
/**
|
50
53
|
*
|
51
54
|
* @export
|
@@ -54,11 +57,13 @@ axios_1.default.interceptors.response.use(function (response) {
|
|
54
57
|
class BaseAPI {
|
55
58
|
constructor(configuration) {
|
56
59
|
this.basePath = exports.BASE_PATH;
|
57
|
-
this.axios = axios_1.default;
|
60
|
+
this.axios = axios_1.default.create();
|
58
61
|
if (configuration) {
|
59
62
|
this.configuration = configuration;
|
60
63
|
this.basePath = configuration.basePath || this.basePath;
|
61
64
|
}
|
65
|
+
this.axios.interceptors.response.use(exports.responseInterceptor, exports.errorInterceptor);
|
66
|
+
this.axios.interceptors.request.use(exports.versionInterceptor);
|
62
67
|
}
|
63
68
|
}
|
64
69
|
exports.BaseAPI = BaseAPI;
|
package/dist/configuration.d.ts
CHANGED
package/dist/configuration.js
CHANGED
@@ -25,9 +25,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.Configuration = exports.OAuth2Configuration = void 0;
|
26
26
|
const axios_1 = require("axios");
|
27
27
|
const qs_1 = require("qs");
|
28
|
+
const base_1 = require("./base");
|
28
29
|
;
|
29
30
|
class OAuth2Configuration {
|
30
31
|
constructor(params) {
|
32
|
+
this.axios = axios_1.default.create();
|
31
33
|
this.accessToken = null;
|
32
34
|
this.refreshToken = null;
|
33
35
|
this.scope = null;
|
@@ -53,7 +55,7 @@ class OAuth2Configuration {
|
|
53
55
|
}
|
54
56
|
const authorizationUrl = `${this.host}/oauth/token`;
|
55
57
|
const clientIdAndSecretInBase64 = Buffer.from(`${this.clientId}:${this.clientSecret}`).toString("base64");
|
56
|
-
const response = yield
|
58
|
+
const response = yield this.axios.post(authorizationUrl, (0, qs_1.stringify)({
|
57
59
|
code,
|
58
60
|
redirect_uri: this.redirectUri,
|
59
61
|
grant_type: "authorization_code",
|
@@ -70,7 +72,7 @@ class OAuth2Configuration {
|
|
70
72
|
this.tokenRefresh = () => __awaiter(this, void 0, void 0, function* () {
|
71
73
|
const refreshUrl = `${this.host}/oauth/token`;
|
72
74
|
const clientIdAndSecretInBase64 = Buffer.from(`${this.clientId}:${this.clientSecret}`).toString("base64");
|
73
|
-
const response = yield
|
75
|
+
const response = yield this.axios.post(refreshUrl, (0, qs_1.stringify)({
|
74
76
|
refresh_token: this.refreshToken,
|
75
77
|
grant_type: "refresh_token",
|
76
78
|
}), {
|
@@ -114,7 +116,13 @@ class OAuth2Configuration {
|
|
114
116
|
return token;
|
115
117
|
};
|
116
118
|
this.getUserAgent = () => {
|
117
|
-
|
119
|
+
let version;
|
120
|
+
try {
|
121
|
+
version = require('../package.json').version;
|
122
|
+
}
|
123
|
+
catch (error) {
|
124
|
+
version = '22.x';
|
125
|
+
}
|
118
126
|
return `Pipedrive-SDK-Javascript-${version}`;
|
119
127
|
};
|
120
128
|
this.validateParam = (params, key) => {
|
@@ -127,6 +135,8 @@ class OAuth2Configuration {
|
|
127
135
|
this.clientSecret = this.validateParam(params, 'clientSecret');
|
128
136
|
this.redirectUri = this.validateParam(params, 'redirectUri');
|
129
137
|
this.host = params.host || "https://oauth.pipedrive.com";
|
138
|
+
this.axios.interceptors.response.use(base_1.responseInterceptor, base_1.errorInterceptor);
|
139
|
+
this.axios.interceptors.request.use(base_1.versionInterceptor);
|
130
140
|
}
|
131
141
|
get authorizationUrl() {
|
132
142
|
return `${this.host}/oauth/authorize?client_id=${this.clientId}&redirect_uri=${encodeURIComponent(this.redirectUri)}`;
|
@@ -143,7 +153,7 @@ class OAuth2Configuration {
|
|
143
153
|
const clientSecret = this.clientSecret;
|
144
154
|
const revokeUrl = `${this.host}/oauth/revoke?`;
|
145
155
|
const clientIdAndSecretInBase64 = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
|
146
|
-
const response = yield
|
156
|
+
const response = yield this.axios.post(revokeUrl, (0, qs_1.stringify)({
|
147
157
|
token,
|
148
158
|
token_type_hint: tokenTypeHint
|
149
159
|
}), {
|
package/dist/esm/base.d.ts
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
* Do not edit the class manually.
|
11
11
|
*/
|
12
12
|
import type { Configuration } from './configuration';
|
13
|
-
import type { AxiosRequestConfig } from 'axios';
|
13
|
+
import type { AxiosError, AxiosResponse, AxiosRequestConfig, InternalAxiosRequestConfig } from 'axios';
|
14
14
|
export declare const BASE_PATH: string;
|
15
15
|
/**
|
16
16
|
*
|
@@ -31,6 +31,9 @@ export interface RequestArgs {
|
|
31
31
|
url: string;
|
32
32
|
options: AxiosRequestConfig;
|
33
33
|
}
|
34
|
+
export declare const versionInterceptor: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig<any>;
|
35
|
+
export declare const responseInterceptor: (response: AxiosResponse) => any;
|
36
|
+
export declare const errorInterceptor: (error: AxiosError) => Promise<never>;
|
34
37
|
/**
|
35
38
|
*
|
36
39
|
* @export
|
@@ -39,7 +42,7 @@ export interface RequestArgs {
|
|
39
42
|
export declare class BaseAPI {
|
40
43
|
protected configuration: Configuration | undefined;
|
41
44
|
protected basePath: string;
|
42
|
-
protected axios: import("axios").
|
45
|
+
protected axios: import("axios").AxiosInstance;
|
43
46
|
constructor(configuration: Configuration);
|
44
47
|
}
|
45
48
|
/**
|
package/dist/esm/base.js
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
* https://openapi-generator.tech
|
12
12
|
* Do not edit the class manually.
|
13
13
|
*/
|
14
|
-
import
|
14
|
+
import axios from 'axios';
|
15
15
|
export const BASE_PATH = "https://api.pipedrive.com/v1".replace(/\/+$/, "");
|
16
16
|
/**
|
17
17
|
*
|
@@ -23,26 +23,26 @@ export const COLLECTION_FORMATS = {
|
|
23
23
|
tsv: "\t",
|
24
24
|
pipes: "|",
|
25
25
|
};
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
export const versionInterceptor = (config) => {
|
27
|
+
let version;
|
28
|
+
try {
|
29
|
+
version = require('../package.json').version;
|
30
|
+
}
|
31
|
+
catch (error) {
|
32
|
+
version = '22.x';
|
33
|
+
}
|
31
34
|
config.headers['User-Agent'] = `Pipedrive-SDK-Javascript-${version}`;
|
32
35
|
return config;
|
33
|
-
}
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
}, function (error) {
|
40
|
-
var _a;
|
41
|
-
if ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) {
|
36
|
+
};
|
37
|
+
export const responseInterceptor = (response) => {
|
38
|
+
return (response === null || response === void 0 ? void 0 : response.data) ? response.data : response;
|
39
|
+
};
|
40
|
+
export const errorInterceptor = (error) => {
|
41
|
+
if (error.response && error.response.data) {
|
42
42
|
return Promise.reject(error.response.data);
|
43
43
|
}
|
44
44
|
return Promise.reject(error);
|
45
|
-
}
|
45
|
+
};
|
46
46
|
/**
|
47
47
|
*
|
48
48
|
* @export
|
@@ -51,11 +51,13 @@ globalAxios.interceptors.response.use(function (response) {
|
|
51
51
|
export class BaseAPI {
|
52
52
|
constructor(configuration) {
|
53
53
|
this.basePath = BASE_PATH;
|
54
|
-
this.axios =
|
54
|
+
this.axios = axios.create();
|
55
55
|
if (configuration) {
|
56
56
|
this.configuration = configuration;
|
57
57
|
this.basePath = configuration.basePath || this.basePath;
|
58
58
|
}
|
59
|
+
this.axios.interceptors.response.use(responseInterceptor, errorInterceptor);
|
60
|
+
this.axios.interceptors.request.use(versionInterceptor);
|
59
61
|
}
|
60
62
|
}
|
61
63
|
;
|
@@ -20,11 +20,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
20
20
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
21
21
|
});
|
22
22
|
};
|
23
|
-
import
|
23
|
+
import axios from "axios";
|
24
24
|
import { stringify } from "qs";
|
25
|
+
import { errorInterceptor, responseInterceptor, versionInterceptor } from './base';
|
25
26
|
;
|
26
27
|
export class OAuth2Configuration {
|
27
28
|
constructor(params) {
|
29
|
+
this.axios = axios.create();
|
28
30
|
this.accessToken = null;
|
29
31
|
this.refreshToken = null;
|
30
32
|
this.scope = null;
|
@@ -50,7 +52,7 @@ export class OAuth2Configuration {
|
|
50
52
|
}
|
51
53
|
const authorizationUrl = `${this.host}/oauth/token`;
|
52
54
|
const clientIdAndSecretInBase64 = Buffer.from(`${this.clientId}:${this.clientSecret}`).toString("base64");
|
53
|
-
const response = yield
|
55
|
+
const response = yield this.axios.post(authorizationUrl, stringify({
|
54
56
|
code,
|
55
57
|
redirect_uri: this.redirectUri,
|
56
58
|
grant_type: "authorization_code",
|
@@ -67,7 +69,7 @@ export class OAuth2Configuration {
|
|
67
69
|
this.tokenRefresh = () => __awaiter(this, void 0, void 0, function* () {
|
68
70
|
const refreshUrl = `${this.host}/oauth/token`;
|
69
71
|
const clientIdAndSecretInBase64 = Buffer.from(`${this.clientId}:${this.clientSecret}`).toString("base64");
|
70
|
-
const response = yield
|
72
|
+
const response = yield this.axios.post(refreshUrl, stringify({
|
71
73
|
refresh_token: this.refreshToken,
|
72
74
|
grant_type: "refresh_token",
|
73
75
|
}), {
|
@@ -111,7 +113,13 @@ export class OAuth2Configuration {
|
|
111
113
|
return token;
|
112
114
|
};
|
113
115
|
this.getUserAgent = () => {
|
114
|
-
|
116
|
+
let version;
|
117
|
+
try {
|
118
|
+
version = require('../package.json').version;
|
119
|
+
}
|
120
|
+
catch (error) {
|
121
|
+
version = '22.x';
|
122
|
+
}
|
115
123
|
return `Pipedrive-SDK-Javascript-${version}`;
|
116
124
|
};
|
117
125
|
this.validateParam = (params, key) => {
|
@@ -124,6 +132,8 @@ export class OAuth2Configuration {
|
|
124
132
|
this.clientSecret = this.validateParam(params, 'clientSecret');
|
125
133
|
this.redirectUri = this.validateParam(params, 'redirectUri');
|
126
134
|
this.host = params.host || "https://oauth.pipedrive.com";
|
135
|
+
this.axios.interceptors.response.use(responseInterceptor, errorInterceptor);
|
136
|
+
this.axios.interceptors.request.use(versionInterceptor);
|
127
137
|
}
|
128
138
|
get authorizationUrl() {
|
129
139
|
return `${this.host}/oauth/authorize?client_id=${this.clientId}&redirect_uri=${encodeURIComponent(this.redirectUri)}`;
|
@@ -140,7 +150,7 @@ export class OAuth2Configuration {
|
|
140
150
|
const clientSecret = this.clientSecret;
|
141
151
|
const revokeUrl = `${this.host}/oauth/revoke?`;
|
142
152
|
const clientIdAndSecretInBase64 = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
|
143
|
-
const response = yield
|
153
|
+
const response = yield this.axios.post(revokeUrl, stringify({
|
144
154
|
token,
|
145
155
|
token_type_hint: tokenTypeHint
|
146
156
|
}), {
|
@@ -12,7 +12,7 @@ Name | Type | Description | Notes
|
|
12
12
|
**keyString** | **String** | A string that is generated by the API based on the given name of the activity type upon creation | [optional]
|
13
13
|
**activeFlag** | **Boolean** | The active flag of the activity type | [optional]
|
14
14
|
**isCustomFlag** | **Boolean** | Whether the activity type is a custom one or not | [optional]
|
15
|
-
**addTime** | **
|
16
|
-
**updateTime** | **
|
15
|
+
**addTime** | **Date** | The creation time of the activity type | [optional]
|
16
|
+
**updateTime** | **Date** | The update time of the activity type | [optional]
|
17
17
|
|
18
18
|
|
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
|
|
7
7
|
**subscriptionUrl** | **String** | A full, valid, publicly accessible URL which determines where to send the notifications. Please note that you cannot use Pipedrive API endpoints as the `subscription_url` and the chosen URL must not redirect to another link. |
|
8
8
|
**eventAction** | **String** | The type of action to receive notifications about. Wildcard will match all supported actions. |
|
9
9
|
**eventObject** | **String** | The type of object to receive notifications about. Wildcard will match all supported objects. |
|
10
|
-
**userId** | **Number** | The ID of the user that this webhook will be authorized with. You have the option to use a different user's `user_id`. If it is not set, the current user's `user_id` will be used. As each webhook event is checked against a user
|
10
|
+
**userId** | **Number** | The ID of the user that this webhook will be authorized with. You have the option to use a different user's `user_id`. If it is not set, the current user's `user_id` will be used. As each webhook event is checked against a user's permissions, the webhook will only be sent if the user has access to the specified object(s). If you want to receive notifications for all events, please use a top-level admin user’s `user_id`. | [optional]
|
11
11
|
**httpAuthUser** | **String** | The HTTP basic auth username of the subscription URL endpoint (if required) | [optional]
|
12
12
|
**httpAuthPassword** | **String** | The HTTP basic auth password of the subscription URL endpoint (if required) | [optional]
|
13
13
|
**version** | **String** | The webhook's version | [optional] [default to '1.0']
|