mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 02:51:14 +00:00
⚡ Add search operation to resource person
This commit is contained in:
@@ -48,6 +48,9 @@ export async function pipedriveApiRequest(this: IHookFunctions | IExecuteFunctio
|
||||
query.api_token = credentials.apiToken;
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
},
|
||||
method,
|
||||
qs: query,
|
||||
uri: `https://api.pipedrive.com/v1${endpoint}`,
|
||||
@@ -93,7 +96,7 @@ export async function pipedriveApiRequest(this: IHookFunctions | IExecuteFunctio
|
||||
|
||||
if (error.response && error.response.body && error.response.body.error) {
|
||||
// Try to return the error prettier
|
||||
let errorMessage = `Pipedrive error response [${error.statusCode}]: ${error.response.body.error}`;
|
||||
let errorMessage = `Pipedrive error response [${error.statusCode}]: ${error.response.body.error.message}`;
|
||||
if (error.response.body.error_info) {
|
||||
errorMessage += ` - ${error.response.body.error_info}`;
|
||||
}
|
||||
@@ -124,7 +127,7 @@ export async function pipedriveApiRequestAllItems(this: IHookFunctions | IExecut
|
||||
if (query === undefined) {
|
||||
query = {};
|
||||
}
|
||||
query.limit = 500;
|
||||
query.limit = 100;
|
||||
query.start = 0;
|
||||
|
||||
const returnData: IDataObject[] = [];
|
||||
@@ -133,7 +136,12 @@ export async function pipedriveApiRequestAllItems(this: IHookFunctions | IExecut
|
||||
|
||||
do {
|
||||
responseData = await pipedriveApiRequest.call(this, method, endpoint, body, query);
|
||||
returnData.push.apply(returnData, responseData.data);
|
||||
// the search path returns data diferently
|
||||
if (responseData.data.items) {
|
||||
returnData.push.apply(returnData, responseData.data.items);
|
||||
} else {
|
||||
returnData.push.apply(returnData, responseData.data);
|
||||
}
|
||||
|
||||
query.start = responseData.additionalData.pagination.next_start;
|
||||
} while (
|
||||
|
||||
Reference in New Issue
Block a user