-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
287 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,6 +120,6 @@ | |
], | ||
"version": "1.0.1", | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,6 @@ | |
], | ||
"version": "1.0.1", | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,6 @@ | |
], | ||
"version": "1.0.1", | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,6 @@ | |
], | ||
"version": "1.0.1", | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,6 @@ | |
} | ||
], | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,6 @@ | |
], | ||
"version": "2.0.0", | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,6 @@ | |
} | ||
], | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,6 @@ | |
"outPorts": [ "out" ], | ||
"version": "1.1.0", | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,6 @@ | |
], | ||
"version": "1.0.1", | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,6 @@ | |
"outPorts": [ "out" ], | ||
"version": "1.0.1", | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,6 @@ | |
], | ||
"version": "2.0.0", | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,6 @@ | |
], | ||
"version": "1.0.1", | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,6 @@ | |
], | ||
"version": "1.0.1", | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ | |
"outPorts": ["out"], | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ | |
"outPorts": ["out"], | ||
"version": "1.0.2", | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,6 @@ | |
], | ||
"version": "1.0.1", | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,6 @@ | |
} | ||
], | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,6 @@ | |
} | ||
], | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,6 @@ | |
} | ||
], | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,6 +124,6 @@ | |
} | ||
], | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,6 @@ | |
} | ||
], | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,6 @@ | |
} | ||
], | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,6 +190,6 @@ | |
], | ||
"version": "2.2.0", | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
83
src/appmixer/hubspot/engagements/CreateNote/component.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,6 @@ | |
], | ||
"version": "2.0.0", | ||
"dependencies": { | ||
"service": "1.0.1" | ||
"service": "2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / build
|
||
'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; | ||
} | ||
} | ||
}; |
Oops, something went wrong.