Skip to content

Commit

Permalink
update service
Browse files Browse the repository at this point in the history
  • Loading branch information
vtalas committed Jan 23, 2024
1 parent 2acbd84 commit 060d1c9
Show file tree
Hide file tree
Showing 29 changed files with 287 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/CreateContact/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@
],
"version": "1.0.1",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/CreateDeal/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Create a new deal.",
"version": "1.0.3",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
},
"private": false,
"auth": {
Expand Down
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/CreateLineItem/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@
],
"version": "1.0.1",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/DeleteContact/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
],
"version": "1.0.1",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/DeleteDeal/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
],
"version": "1.0.1",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/DeletedContact/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
}
],
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/FindContacts/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@
],
"version": "2.0.0",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/GetContact/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,6 @@
}
],
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"outPorts": [ "out" ],
"version": "1.1.0",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/GetDeal/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@
],
"version": "1.0.1",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/GetDealsProperties/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"outPorts": [ "out" ],
"version": "1.0.1",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/ListContacts/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@
],
"version": "2.0.0",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/ListDeals/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@
],
"version": "1.0.1",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/ListOwners/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
],
"version": "1.0.1",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/ListPipelineStages/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"outPorts": ["out"],
"version": "1.0.0",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}

2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/ListPipelines/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"outPorts": ["out"],
"version": "1.0.2",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}

2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/ListProducts/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
],
"version": "1.0.1",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/NewContact/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
}
],
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/NewDeal/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
}
],
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/UpdateContact/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,6 @@
}
],
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/UpdateDeal/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@
}
],
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/UpdatedContact/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
}
],
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
2 changes: 1 addition & 1 deletion src/appmixer/hubspot/crm/UpdatedDeal/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
}
],
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,6 @@
],
"version": "2.2.0",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
48 changes: 48 additions & 0 deletions src/appmixer/hubspot/engagements/CreateNote/CreateNote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict';
const Hubspot = require('../../Hubspot');

module.exports = {

/**
* This component requires a contact to be associated to the newly created note.
* TODO: Future versions should allow for other objects, like deals, companies etc to be associated with the note
* NOTE: A note can also be without associations, but it seems useless as it cannot be found easily.
*/
async receive(context) {

const {
body,
contactId,
hubSpotOwnerId,
attachmentIds
} = context.messages.in.content;

const { auth } = context;
const hs = new Hubspot(auth.accessToken, context.config);

const payload = {
properties: {
hs_timestamp: (new Date()).toISOString(),
hs_note_body: body,
hubspot_owner_id: hubSpotOwnerId || '', // Optional
hs_attachment_ids: attachmentIds || '' // If multiple the ids must be separated by semi-colons
},
associations: [ //TODO: In the future extend to accept other object types than contacts
{
to: {
id: contactId
},
types: [
{
associationCategory: 'HUBSPOT_DEFINED',
associationTypeId: 202
}]
}
]
};

const { data } = await hs.call('post', 'crm/v3/objects/notes', payload);

return context.sendJson(data, 'out');
}
};
83 changes: 83 additions & 0 deletions src/appmixer/hubspot/engagements/CreateNote/component.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/appmixer/hubspot/engagements/GetEmails/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@
],
"version": "2.0.0",
"dependencies": {
"service": "1.0.1"
"service": "2.0.1"
}
}
64 changes: 64 additions & 0 deletions src/appmixer/hubspot/files/UploadFile/UploadFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
'use strict';
const Hubspot = require('../../Hubspot');
const FormData = require('form-data');

module.exports = {

async receive(context) {

const { fileId, fileName } = context.messages.in.content;

const { auth } = context;
const hs = new Hubspot(auth.accessToken, context.config);

const filestream = await context.getFileReadStream(fileId);

const options = {
access: 'PUBLIC_NOT_INDEXABLE',
overwrite: false,
duplicateValidationStrategy: 'NONE',
duplicateValidationScope: 'EXACT_FOLDER'
};

let form = new FormData();
form.append('file', filestream, fileName);
form.append('options', JSON.stringify(options));
form.append('fileName', fileName);
form.append('folderPath', '/');

// Had to craft an http call instead of hs.call, due to the form data/headers
try {
const {data} = await hs.call('POST',

Check failure on line 31 in src/appmixer/hubspot/files/UploadFile/UploadFile.js

View workflow job for this annotation

GitHub Actions / build

A space is required after '{'

Check failure on line 31 in src/appmixer/hubspot/files/UploadFile/UploadFile.js

View workflow job for this annotation

GitHub Actions / build

A space is required before '}'
'files/v3/files',
{
fileName,
options,
filestream,
folderPath: '/',
file: filestream
});

// context.log({ stage: 'rq', form});
// const { data } = await context.httpRequest({
// url: 'https://api.hubapi.com/files/v3/files',
// method: 'POST',
// headers: {
// Authorization: 'Bearer ' + auth.accessToken
// },
// data: form
// });

context.log({ stage: 'rs', data });
return context.sendJson(data, 'out');

} catch (e) {
if (e.response && e.response.data && e.response.data.message) {
const error = new Error(e.response.data.message);
error.status = e.response.status;
error.data = e.response.data;
throw error;
}
throw e;
}
}
};
Loading

0 comments on commit 060d1c9

Please sign in to comment.