feat(pipedrive): add create person action

This commit is contained in:
Rıdvan Akca
2023-10-18 14:13:53 +03:00
committed by Ali BARIN
parent 0772308bf5
commit 3a638220af
5 changed files with 199 additions and 0 deletions

View File

@@ -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,
];

View File

@@ -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;
},
};