🔀 Merge branch 'pipe-dealactivity' of https://github.com/rodrigoscdc/n8n into rodrigoscdc-pipe-dealactivity

This commit is contained in:
Jan Oberhauser 2021-10-09 14:05:44 -05:00
commit 6ba7f53449

View file

@ -118,6 +118,10 @@ export class Pipedrive implements INodeType {
name: 'Deal', name: 'Deal',
value: 'deal', value: 'deal',
}, },
{
name: 'Deal Activity',
value: 'dealActivity',
},
{ {
name: 'Deal Product', name: 'Deal Product',
value: 'dealProduct', value: 'dealProduct',
@ -250,6 +254,27 @@ export class Pipedrive implements INodeType {
description: 'The operation to perform.', description: 'The operation to perform.',
}, },
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'dealActivity',
],
},
},
options: [
{
name: 'Get All',
value: 'getAll',
description: 'Get all products in a deal',
},
],
default: 'getAll',
},
{ {
displayName: 'Operation', displayName: 'Operation',
name: 'operation', name: 'operation',
@ -3423,6 +3448,76 @@ export class Pipedrive implements INodeType {
description: 'How many results to return.', description: 'How many results to return.',
}, },
// ----------------------------------
// dealActivities:getAll
// ----------------------------------
{
displayName: 'Deal ID',
name: 'dealId',
type: 'options',
default: '',
typeOptions: {
loadOptionsMethod: 'getDeals',
},
required: true,
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'dealActivity',
],
},
},
description: 'The ID of the deal whose products to retrieve',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'dealActivity',
],
},
},
default: {},
options: [
{
displayName: 'Done',
name: 'done',
type: 'options',
options: [
{
name: 'Not done',
value: '0',
},
{
name: 'Done',
value: '1',
},
],
default: '0',
description: 'Whether the activity is done or not.',
},
{
displayName: 'Exclude Activity Ids',
name: 'exclude',
type: 'string',
typeOptions: {
rows: 3,
},
default: '',
description: 'A comma separated Activity Ids, to exclude from result. Ex. 4, 9, 11, ...',
},
],
},
// ---------------------------------------- // ----------------------------------------
// lead: getAll // lead: getAll
// ---------------------------------------- // ----------------------------------------
@ -4387,6 +4482,35 @@ export class Pipedrive implements INodeType {
} }
} else if (resource === 'dealActivity') {
if (operation === 'getAll') {
// ----------------------------------
// dealActivity: getAll
// ----------------------------------
requestMethod = 'GET';
const dealId = this.getNodeParameter('dealId', i) as string;
returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (returnAll === false) {
qs.limit = this.getNodeParameter('limit', i) as number;
}
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
if (additionalFields.exclude) {
qs.exclude = (additionalFields.exclude as string);
}
if (additionalFields.done) {
qs.done = parseInt(additionalFields.done as string);
}
endpoint = `/deals/${dealId}/activities`;
}
} else if (resource === 'dealProduct') { } else if (resource === 'dealProduct') {
if (operation === 'add') { if (operation === 'add') {
@ -4982,7 +5106,7 @@ export class Pipedrive implements INodeType {
returnData.push(responseData.data as IDataObject); returnData.push(responseData.data as IDataObject);
} }
} }
} catch (error) { } catch (error: any) {
if (this.continueOnFail()) { if (this.continueOnFail()) {
if (resource === 'file' && operation === 'download') { if (resource === 'file' && operation === 'download') {
items[i].json = { error: error.message }; items[i].json = { error: error.message };