Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build 2356 - version-prerelease #525

Merged
merged 15 commits into from
Apr 24, 2024
Merged
18 changes: 15 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@ 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]
- Add `lead_id` as an acceptable body parameter for the `POST /v1/callLogs` endpoint

## [22.3.1-rc.4] - 2024-02-12

## [22.3.1-rc.3] - 2024-01-08
## [22.3.1-rc.5] - 2024-02-12
- Add TypeScript Support


## [22.6.1] - 2024-04-18
### Added
- Added `is_deleted` parameter for `/v1/users/*` responses.

## [22.6.0] - 2024-04-05
### Added
- Added documentation for new endpoints `/deals/{id}/changelog`, `/persons/{id}/changelog` and `/organizations/{id}/changelog`.


## [22.5.0] - 2024-02-02
### Added
- Added documentation for new endpoint `/deals/{id}/participantsChangelog`.
Expand Down Expand Up @@ -607,7 +617,9 @@ structure

[Unreleased]: https://github.com/pipedrive/api-docs/compare/v22.3.1-rc.4...HEAD
[22.3.1-rc.4]: https://github.com/pipedrive/api-docs/compare/v22.3.1-rc.3...v22.3.1-rc.4
[22.3.1-rc.3]: https://github.com/pipedrive/api-docs/compare/v22.4.0...v22.3.1-rc.3
[22.5.0]: https://github.com/pipedrive/api-docs/compare/v22.4.0...v22.5.0
[22.6.0]: https://github.com/pipedrive/api-docs/compare/v22.5.0...v22.6.0
[22.6.1]: https://github.com/pipedrive/api-docs/compare/v22.6.0...v22.6.1
[22.4.0]: https://github.com/pipedrive/api-docs/compare/v22.3.0...v22.4.0
[22.3.0]: https://github.com/pipedrive/api-docs/compare/v22.2.0...v22.3.0
[22.2.0]: https://github.com/pipedrive/api-docs/compare/v22.1.0...v22.2.0
Expand Down
43 changes: 20 additions & 23 deletions base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import type { Configuration } from './configuration';
// Some imports not used depending on template conditions
// @ts-ignore
import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
import type { AxiosError, AxiosResponse, AxiosRequestConfig , InternalAxiosRequestConfig } from 'axios';
import axios from 'axios';

export const BASE_PATH = "https://api.pipedrive.com/v1".replace(/\/+$/, "");

Expand All @@ -41,34 +41,28 @@ export interface RequestArgs {
url: string;
options: AxiosRequestConfig;
}
/**
* Axios interceptor to add the SDK version as a User-Agent header
* */
globalAxios.interceptors.request.use(function (config) {
let version;

export const versionInterceptor = (config:InternalAxiosRequestConfig) => {
let version:string;
try {
version = require('../package.json').version;
} catch (error) {
version = '22.x';
}

config.headers['User-Agent'] = `Pipedrive-SDK-Javascript-${version}`;

return config;
});
}

/**
* Axios response interceptor to modify response structure
*/
globalAxios.interceptors.response.use(function (response) {
return response ? (response.hasOwnProperty('success') ? response : response.data) : response;
}, function (error) {
if(error?.response?.data) {
return Promise.reject(error.response.data);
}
return Promise.reject(error);
});
export const responseInterceptor = (response: AxiosResponse) => {
return response?.data ? response.data: response;
};

export const errorInterceptor = (error: AxiosError) => {
if (error.response && error.response.data) {
return Promise.reject(error.response.data);
}
return Promise.reject(error);
};

/**
*
Expand All @@ -78,13 +72,16 @@ globalAxios.interceptors.response.use(function (response) {
export class BaseAPI {
protected configuration: Configuration | undefined;
protected basePath: string = BASE_PATH;
protected axios = globalAxios;

protected axios = axios.create();
constructor(configuration: Configuration) {
if (configuration) {
this.configuration = configuration;
this.basePath = configuration.basePath || this.basePath;
}


this.axios.interceptors.response.use(responseInterceptor, errorInterceptor);
this.axios.interceptors.request.use(versionInterceptor);
}
};

Expand Down
13 changes: 9 additions & 4 deletions configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
*/


import globalAxios from "axios";
import axios from "axios";
import { stringify } from "qs";
import { errorInterceptor, responseInterceptor, versionInterceptor } from './base';

export type TokenResponse = {
access_token: string;
Expand All @@ -35,6 +36,7 @@ export interface Parameters {
export type ParamKey = keyof Parameters;

export class OAuth2Configuration {
private axios = axios.create();
private host: string;
private accessToken: string | null = null;
private refreshToken: string | null = null;
Expand All @@ -53,6 +55,9 @@ export class OAuth2Configuration {
this.clientSecret = this.validateParam(params, 'clientSecret');
this.redirectUri = this.validateParam(params, 'redirectUri');
this.host = params.host || "https://oauth.pipedrive.com";

this.axios.interceptors.response.use(responseInterceptor, errorInterceptor);
this.axios.interceptors.request.use(versionInterceptor);
}

public get authorizationUrl() {
Expand Down Expand Up @@ -88,7 +93,7 @@ export class OAuth2Configuration {
`${this.clientId}:${this.clientSecret}`
).toString("base64");

const response = await globalAxios.post(
const response = await this.axios.post(
authorizationUrl,
stringify({
code,
Expand All @@ -115,7 +120,7 @@ export class OAuth2Configuration {
`${this.clientId}:${this.clientSecret}`
).toString("base64");

const response = await globalAxios.post(
const response = await this.axios.post(
refreshUrl,
stringify({
refresh_token: this.refreshToken,
Expand Down Expand Up @@ -187,7 +192,7 @@ export class OAuth2Configuration {
const revokeUrl = `${this.host}/oauth/revoke?`;
const clientIdAndSecretInBase64 = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');

const response = await globalAxios.post(
const response = await this.axios.post(
revokeUrl,
stringify({
token,
Expand Down
4 changes: 2 additions & 2 deletions docs/ActivityTypeObjectResponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Name | Type | Description | Notes
**keyString** | **String** | A string that is generated by the API based on the given name of the activity type upon creation | [optional]
**activeFlag** | **Boolean** | The active flag of the activity type | [optional]
**isCustomFlag** | **Boolean** | Whether the activity type is a custom one or not | [optional]
**addTime** | **String** | The creation time of the activity type | [optional]
**updateTime** | **String** | The update time of the activity type | [optional]
**addTime** | **Date** | The creation time of the activity type | [optional]
**updateTime** | **Date** | The update time of the activity type | [optional]


1 change: 1 addition & 0 deletions docs/BaseUser.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ Name | Type | Description | Notes
**roleId** | **Number** | The ID of the user role | [optional]
**iconUrl** | **String** | The user icon URL | [optional]
**isYou** | **Boolean** | Boolean that indicates if the requested user is the same which is logged in (in this case, always true) | [optional]
**isDeleted** | **Boolean** | Boolean that indicates whether the user is deleted from the company | [optional]


1 change: 1 addition & 0 deletions docs/BaseUserMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Name | Type | Description | Notes
**roleId** | **Number** | The ID of the user role | [optional]
**iconUrl** | **String** | The user icon URL | [optional]
**isYou** | **Boolean** | Boolean that indicates if the requested user is the same which is logged in (in this case, always true) | [optional]
**isDeleted** | **Boolean** | Boolean that indicates whether the user is deleted from the company | [optional]
**companyId** | **Number** | The user company ID | [optional]
**companyName** | **String** | The user company name | [optional]
**companyDomain** | **String** | The user company domain | [optional]
Expand Down
11 changes: 11 additions & 0 deletions docs/ChangelogResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Pipedrive.ChangelogResponse

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**success** | **Boolean** | If the response is successful or not | [optional]
**data** | [**[ChangelogResponseAllOfData]**](ChangelogResponseAllOfData.md) | | [optional]
**additionalData** | [**AdditionalDataWithCursorPagination**](AdditionalDataWithCursorPagination.md) | | [optional]


10 changes: 10 additions & 0 deletions docs/ChangelogResponseAllOf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Pipedrive.ChangelogResponseAllOf

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**data** | [**[ChangelogResponseAllOfData]**](ChangelogResponseAllOfData.md) | | [optional]
**additionalData** | [**AdditionalDataWithCursorPagination**](AdditionalDataWithCursorPagination.md) | | [optional]


16 changes: 16 additions & 0 deletions docs/ChangelogResponseAllOfData.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Pipedrive.ChangelogResponseAllOfData

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**fieldKey** | **String** | The key of the field that was changed | [optional]
**oldValue** | **String** | The value of the field before the change | [optional]
**newValue** | **String** | The value of the field after the change | [optional]
**actorUserId** | **Number** | The ID of the user who made the change | [optional]
**time** | **String** | The date and time of the change | [optional]
**changeSource** | **String** | The source of change, for example 'app', 'mobile', 'api', etc. | [optional]
**changeSourceUserAgent** | **String** | The user agent from which the change was made | [optional]
**isBulkUpdateFlag** | **Boolean** | Whether the change was made as part of a bulk update | [optional]


60 changes: 60 additions & 0 deletions docs/DealsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Method | HTTP request | Description
[**duplicateDeal**](DealsApi.md#duplicateDeal) | **POST** /deals/{id}/duplicate | Duplicate deal
[**getDeal**](DealsApi.md#getDeal) | **GET** /deals/{id} | Get details of a deal
[**getDealActivities**](DealsApi.md#getDealActivities) | **GET** /deals/{id}/activities | List activities associated with a deal
[**getDealChangelog**](DealsApi.md#getDealChangelog) | **GET** /deals/{id}/changelog | List updates about deal field values
[**getDealFiles**](DealsApi.md#getDealFiles) | **GET** /deals/{id}/files | List files attached to a deal
[**getDealFollowers**](DealsApi.md#getDealFollowers) | **GET** /deals/{id}/followers | List followers of a deal
[**getDealMailMessages**](DealsApi.md#getDealMailMessages) | **GET** /deals/{id}/mailMessages | List mail messages associated with a deal
Expand Down Expand Up @@ -702,6 +703,65 @@ Name | Type | Description | Notes
- **Accept**: application/json


## getDealChangelog

> ChangelogResponse getDealChangelog(id, opts)

List updates about deal field values

Lists updates about field values of a deal.

### Example

```javascript
import Pipedrive from 'pipedrive';
let apiClient = new Pipedrive.ApiClient();
// Configure API key authorization: api_key
let api_key = apiClient.authentications['api_key'];
api_key.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.apiKeyPrefix = 'Token';
// Configure OAuth2 access token for authorization: oauth2
let oauth2 = apiClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

let apiInstance = new Pipedrive.DealsApi(apiClient);
let id = 56; // Number | The ID of the deal
let opts = {
'cursor': "cursor_example", // String | For pagination, the marker (an opaque string value) representing the first item on the next page
'limit': 56 // Number | Items shown per page
};
apiInstance.getDealChangelog(id, opts).then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, (error) => {
console.error(error);
});

```

### Parameters


Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**id** | **Number**| The ID of the deal |
**cursor** | **String**| For pagination, the marker (an opaque string value) representing the first item on the next page | [optional]
**limit** | **Number**| Items shown per page | [optional]

### Return type

[**ChangelogResponse**](ChangelogResponse.md)

### Authorization

[api_key](../README.md#api_key), [oauth2](../README.md#oauth2)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json


## getDealFiles

> ListFilesResponse getDealFiles(id, opts)
Expand Down
5 changes: 3 additions & 2 deletions docs/Field.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ Name | Type | Description | Notes
**name** | **String** | The name of the field | [optional]
**orderNr** | **Number** | The order number of the field | [optional]
**fieldType** | [**FieldTypeAsString**](FieldTypeAsString.md) | | [optional]
**addTime** | **String** | The creation time of the field | [optional]
**updateTime** | **String** | The update time of the field | [optional]
**addTime** | **Date** | The creation time of the field | [optional]
**updateTime** | **Date** | The update time of the field | [optional]
**lastUpdatedByUserId** | **Number** | The ID of the user who created or most recently updated the field, only applicable for custom fields | [optional]
**createdByUserId** | **Number** | The ID of the user who created the field | [optional]
**activeFlag** | **Boolean** | The active flag of the field | [optional]
**editFlag** | **Boolean** | The edit flag of the field | [optional]
**indexVisibleFlag** | **Boolean** | Not used | [optional]
Expand Down
1 change: 0 additions & 1 deletion docs/ListPermittedUsersResponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**success** | **Boolean** | If the response is successful or not | [optional]
**data** | [**ListPermittedUsersResponseAllOfData**](ListPermittedUsersResponseAllOfData.md) | | [optional]


Loading