mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
⚡ Fix company:users response
This commit is contained in:
parent
6fcbb2ad45
commit
223f0130f0
|
@ -49,7 +49,6 @@ export const companyFields = [
|
|||
/* -------------------------------------------------------------------------- */
|
||||
/* company:users */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
displayName: 'List By',
|
||||
name: 'listBy',
|
||||
|
@ -97,6 +96,48 @@ export const companyFields = [
|
|||
},
|
||||
description: 'View by value',
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'company',
|
||||
],
|
||||
operation: [
|
||||
'users',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'If all results should be returned or only up to a given limit.',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'company',
|
||||
],
|
||||
operation: [
|
||||
'users',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 60,
|
||||
},
|
||||
default: 50,
|
||||
description: 'How many results to return.',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* company:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
|
|
@ -514,15 +514,32 @@ export class Intercom implements INodeType {
|
|||
if (operation === 'users') {
|
||||
const listBy = this.getNodeParameter('listBy', 0) as string;
|
||||
const value = this.getNodeParameter('value', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
|
||||
if (listBy === 'companyId') {
|
||||
qs.company_id = value;
|
||||
}
|
||||
|
||||
try {
|
||||
if (listBy === 'id') {
|
||||
responseData = await intercomApiRequest.call(this, `/companies/${value}/users`, 'GET', {}, qs);
|
||||
if (returnAll === true) {
|
||||
responseData = await intercomApiRequestAllItems.call(this, 'users', `/companies/${value}/users`, 'GET', {}, qs);
|
||||
} else {
|
||||
qs.per_page = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await intercomApiRequest.call(this, `/companies/${value}/users`, 'GET', {}, qs);
|
||||
responseData = responseData.users;
|
||||
}
|
||||
|
||||
} else {
|
||||
qs.type = 'users';
|
||||
responseData = await intercomApiRequest.call(this, '/companies', 'GET', {}, qs);
|
||||
|
||||
if (returnAll === true) {
|
||||
responseData = await intercomApiRequestAllItems.call(this, 'users', '/companies', 'GET', {}, qs);
|
||||
} else {
|
||||
qs.per_page = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await intercomApiRequest.call(this, '/companies', 'GET', {}, qs);
|
||||
responseData = responseData.users;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), `Intercom Error: ${JSON.stringify(error)}`);
|
||||
|
|
Loading…
Reference in a new issue