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
9 changed files with 101 additions and 33 deletions

View File

@@ -46,7 +46,6 @@
"graphql-shield": "^7.5.0",
"graphql-tools": "^8.2.0",
"handlebars": "^4.7.7",
"he": "^1.2.0",
"http-errors": "~1.6.3",
"http-proxy-agent": "^7.0.0",
"https-proxy-agent": "^7.0.1",

View File

@@ -2,7 +2,6 @@ import defineAction from '../../../../helpers/define-action.js';
import base64ToString from './transformers/base64-to-string.js';
import capitalize from './transformers/capitalize.js';
import decodeHtmlEntities from './transformers/decode-html-entities.js';
import extractEmailAddress from './transformers/extract-email-address.js';
import extractNumber from './transformers/extract-number.js';
import htmlToMarkdown from './transformers/html-to-markdown.js';
@@ -17,7 +16,6 @@ import useDefaultValue from './transformers/use-default-value.js';
const transformers = {
base64ToString,
capitalize,
decodeHtmlEntities,
extractEmailAddress,
extractNumber,
htmlToMarkdown,
@@ -45,7 +43,6 @@ export default defineAction({
options: [
{ label: 'Base64 to String', value: 'base64ToString' },
{ label: 'Capitalize', value: 'capitalize' },
{ label: 'Decode HTML Entities', value: 'decodeHtmlEntities' },
{ label: 'Convert HTML to Markdown', value: 'htmlToMarkdown' },
{ label: 'Convert Markdown to HTML', value: 'markdownToHtml' },
{ label: 'Extract Email Address', value: 'extractEmailAddress' },

View File

@@ -1,8 +0,0 @@
import he from 'he';
const decodeHtmlEntities = ($) => {
const input = $.step.parameters.input;
return he.decode(input);
};
export default decodeHtmlEntities;

View File

@@ -1,6 +1,5 @@
import base64ToString from './text/base64-to-string.js';
import capitalize from './text/capitalize.js';
import decodeHtmlEntities from './text/decode-html-entities.js';
import extractEmailAddress from './text/extract-email-address.js';
import extractNumber from './text/extract-number.js';
import htmlToMarkdown from './text/html-to-markdown.js';
@@ -20,7 +19,6 @@ import formatDateTime from './date-time/format-date-time.js';
const options = {
base64ToString,
capitalize,
decodeHtmlEntities,
extractEmailAddress,
extractNumber,
htmlToMarkdown,

View File

@@ -1,12 +0,0 @@
const decodeHtmlEntities = [
{
label: 'Input',
key: 'input',
type: 'string',
required: true,
description: 'Text that will be decoded.',
variables: true,
},
];
export default decodeHtmlEntities;

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>

View File

@@ -8973,16 +8973,11 @@ has@^1.0.3:
dependencies:
function-bind "^1.1.1"
he@1.2.0:
he@1.2.0, he@^1.2.0:
version "1.2.0"
resolved "https://registry.npmjs.org/he/-/he-1.2.0.tgz"
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
he@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
hexoid@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/hexoid/-/hexoid-1.0.0.tgz#ad10c6573fb907de23d9ec63a711267d9dc9bc18"