Compare commits

...

1 Commits

Author SHA1 Message Date
Rıdvan Akca
a171623d4e feat(hubspot): add update contact action 2024-04-21 12:24:57 +02:00
3 changed files with 100 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
import createContact from './create-contact/index.js';
import updateContact from './update-contact/index.js';
export default [createContact];
export default [createContact, updateContact];

View File

@@ -0,0 +1,96 @@
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Update contact',
key: 'updateContact',
description: `Updates an existing contact on user's account.`,
arguments: [
{
label: 'Contact ID',
key: 'contactId',
type: 'string',
required: true,
variables: true,
},
{
label: 'Company name',
key: 'company',
type: 'string',
required: false,
variables: true,
},
{
label: 'Email',
key: 'email',
type: 'string',
required: false,
variables: true,
},
{
label: 'First name',
key: 'firstName',
type: 'string',
required: false,
variables: true,
},
{
label: 'Last name',
key: 'lastName',
type: 'string',
required: false,
description: 'Last name',
variables: true,
},
{
label: 'Phone',
key: 'phone',
type: 'string',
required: false,
variables: true,
},
{
label: 'Website URL',
key: 'website',
type: 'string',
required: false,
variables: true,
},
{
label: 'Owner ID',
key: 'hubspotOwnerId',
type: 'string',
required: false,
variables: true,
},
],
async run($) {
const {
contactId,
company,
email,
firstName,
lastName,
phone,
website,
hubspotOwnerId,
} = $.step.parameters;
const response = await $.http.patch(
`crm/v3/objects/contacts/${contactId}`,
{
properties: {
company,
email,
firstname: firstName,
lastname: lastName,
phone,
website,
hubspot_owner_id: hubspotOwnerId,
},
}
);
$.setActionItem({ raw: response.data });
},
});

View File

@@ -3,6 +3,8 @@ favicon: /favicons/hubspot.svg
items:
- name: Create a contact
desc: Create a contact on user's account.
- name: Update contact
desc: Update an existing contact on user's account.
---
<script setup>