mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 05:17:28 -08:00
⚡ Fix company:users response
This commit is contained in:
parent
6fcbb2ad45
commit
223f0130f0
|
@ -49,7 +49,6 @@ export const companyFields = [
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* company:users */
|
/* company:users */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
{
|
{
|
||||||
displayName: 'List By',
|
displayName: 'List By',
|
||||||
name: 'listBy',
|
name: 'listBy',
|
||||||
|
@ -97,6 +96,48 @@ export const companyFields = [
|
||||||
},
|
},
|
||||||
description: 'View by value',
|
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 */
|
/* company:getAll */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
|
@ -514,15 +514,32 @@ export class Intercom implements INodeType {
|
||||||
if (operation === 'users') {
|
if (operation === 'users') {
|
||||||
const listBy = this.getNodeParameter('listBy', 0) as string;
|
const listBy = this.getNodeParameter('listBy', 0) as string;
|
||||||
const value = this.getNodeParameter('value', i) as string;
|
const value = this.getNodeParameter('value', i) as string;
|
||||||
|
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||||
|
|
||||||
if (listBy === 'companyId') {
|
if (listBy === 'companyId') {
|
||||||
qs.company_id = value;
|
qs.company_id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (listBy === 'id') {
|
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 {
|
} else {
|
||||||
qs.type = 'users';
|
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) {
|
} catch (error) {
|
||||||
throw new NodeOperationError(this.getNode(), `Intercom Error: ${JSON.stringify(error)}`);
|
throw new NodeOperationError(this.getNode(), `Intercom Error: ${JSON.stringify(error)}`);
|
||||||
|
|
Loading…
Reference in a new issue