feat(pipedrive): add create person action
This commit is contained in:
@@ -5,6 +5,7 @@ import listLeads from './list-leads';
|
||||
import listLeadLabels from './list-lead-labels';
|
||||
import listOrganizations from './list-organizations';
|
||||
import listOrganizationLabelField from './list-organization-label-field';
|
||||
import listPersonLabelField from './list-person-label-field';
|
||||
import listPersons from './list-persons';
|
||||
import listUsers from './list-users';
|
||||
|
||||
@@ -16,6 +17,7 @@ export default [
|
||||
listLeadLabels,
|
||||
listOrganizations,
|
||||
listOrganizationLabelField,
|
||||
listPersonLabelField,
|
||||
listPersons,
|
||||
listUsers,
|
||||
];
|
||||
|
@@ -0,0 +1,42 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List person label field',
|
||||
key: 'listPersonLabelField',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const personFields: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
const params = {
|
||||
start: 0,
|
||||
limit: 100,
|
||||
};
|
||||
|
||||
do {
|
||||
const { data } = await $.http.get(
|
||||
`${$.auth.data.apiDomain}/api/v1/personFields`,
|
||||
{ params }
|
||||
);
|
||||
params.start = data.additional_data?.pagination?.next_start;
|
||||
|
||||
const labelField = data.data?.filter(
|
||||
(personField: IJSONObject) => personField.key === 'label'
|
||||
);
|
||||
const labelOptions = labelField[0].options;
|
||||
|
||||
if (labelOptions?.length) {
|
||||
for (const label of labelOptions) {
|
||||
personFields.data.push({
|
||||
value: label.id,
|
||||
name: label.label,
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.start);
|
||||
return personFields;
|
||||
},
|
||||
};
|
Reference in New Issue
Block a user