@orchesty/connector-hubspot 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/HubSpotApplication.d.ts +1 -0
- package/dist/HubSpotApplication.js +5 -5
- package/dist/package.json +4 -2
- package/package.json +5 -3
- package/CHANGELOG.md +0 -12
- package/coverage/clover.xml +0 -6
- package/coverage/coverage-final.json +0 -1
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -101
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov.info +0 -0
- package/jest.config.js +0 -13
- package/src/Connector/HubSpotAddEmailToListConnector.ts +0 -38
- package/src/Connector/HubSpotCreateContactConnector.ts +0 -43
- package/src/Connector/HubSpotSendTransactionEmailConnector.ts +0 -43
- package/src/HubSpotApplication.ts +0 -156
- package/src/HubSpotApplicationBasic.ts +0 -65
- package/tsconfig.json +0 -8
- package/tsconfig.prod.json +0 -13
- package/tsconfig.prod.tsbuildinfo +0 -1
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
var addSorting = (function() {
|
|
3
|
-
'use strict';
|
|
4
|
-
var cols,
|
|
5
|
-
currentSort = {
|
|
6
|
-
index: 0,
|
|
7
|
-
desc: false
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// returns the summary table element
|
|
11
|
-
function getTable() {
|
|
12
|
-
return document.querySelector('.coverage-summary');
|
|
13
|
-
}
|
|
14
|
-
// returns the thead element of the summary table
|
|
15
|
-
function getTableHeader() {
|
|
16
|
-
return getTable().querySelector('thead tr');
|
|
17
|
-
}
|
|
18
|
-
// returns the tbody element of the summary table
|
|
19
|
-
function getTableBody() {
|
|
20
|
-
return getTable().querySelector('tbody');
|
|
21
|
-
}
|
|
22
|
-
// returns the th element for nth column
|
|
23
|
-
function getNthColumn(n) {
|
|
24
|
-
return getTableHeader().querySelectorAll('th')[n];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function onFilterInput() {
|
|
28
|
-
const searchValue = document.getElementById('fileSearch').value;
|
|
29
|
-
const rows = document.getElementsByTagName('tbody')[0].children;
|
|
30
|
-
|
|
31
|
-
// Try to create a RegExp from the searchValue. If it fails (invalid regex),
|
|
32
|
-
// it will be treated as a plain text search
|
|
33
|
-
let searchRegex;
|
|
34
|
-
try {
|
|
35
|
-
searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive
|
|
36
|
-
} catch (error) {
|
|
37
|
-
searchRegex = null;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
for (let i = 0; i < rows.length; i++) {
|
|
41
|
-
const row = rows[i];
|
|
42
|
-
let isMatch = false;
|
|
43
|
-
|
|
44
|
-
if (searchRegex) {
|
|
45
|
-
// If a valid regex was created, use it for matching
|
|
46
|
-
isMatch = searchRegex.test(row.textContent);
|
|
47
|
-
} else {
|
|
48
|
-
// Otherwise, fall back to the original plain text search
|
|
49
|
-
isMatch = row.textContent
|
|
50
|
-
.toLowerCase()
|
|
51
|
-
.includes(searchValue.toLowerCase());
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
row.style.display = isMatch ? '' : 'none';
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// loads the search box
|
|
59
|
-
function addSearchBox() {
|
|
60
|
-
var template = document.getElementById('filterTemplate');
|
|
61
|
-
var templateClone = template.content.cloneNode(true);
|
|
62
|
-
templateClone.getElementById('fileSearch').oninput = onFilterInput;
|
|
63
|
-
template.parentElement.appendChild(templateClone);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// loads all columns
|
|
67
|
-
function loadColumns() {
|
|
68
|
-
var colNodes = getTableHeader().querySelectorAll('th'),
|
|
69
|
-
colNode,
|
|
70
|
-
cols = [],
|
|
71
|
-
col,
|
|
72
|
-
i;
|
|
73
|
-
|
|
74
|
-
for (i = 0; i < colNodes.length; i += 1) {
|
|
75
|
-
colNode = colNodes[i];
|
|
76
|
-
col = {
|
|
77
|
-
key: colNode.getAttribute('data-col'),
|
|
78
|
-
sortable: !colNode.getAttribute('data-nosort'),
|
|
79
|
-
type: colNode.getAttribute('data-type') || 'string'
|
|
80
|
-
};
|
|
81
|
-
cols.push(col);
|
|
82
|
-
if (col.sortable) {
|
|
83
|
-
col.defaultDescSort = col.type === 'number';
|
|
84
|
-
colNode.innerHTML =
|
|
85
|
-
colNode.innerHTML + '<span class="sorter"></span>';
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return cols;
|
|
89
|
-
}
|
|
90
|
-
// attaches a data attribute to every tr element with an object
|
|
91
|
-
// of data values keyed by column name
|
|
92
|
-
function loadRowData(tableRow) {
|
|
93
|
-
var tableCols = tableRow.querySelectorAll('td'),
|
|
94
|
-
colNode,
|
|
95
|
-
col,
|
|
96
|
-
data = {},
|
|
97
|
-
i,
|
|
98
|
-
val;
|
|
99
|
-
for (i = 0; i < tableCols.length; i += 1) {
|
|
100
|
-
colNode = tableCols[i];
|
|
101
|
-
col = cols[i];
|
|
102
|
-
val = colNode.getAttribute('data-value');
|
|
103
|
-
if (col.type === 'number') {
|
|
104
|
-
val = Number(val);
|
|
105
|
-
}
|
|
106
|
-
data[col.key] = val;
|
|
107
|
-
}
|
|
108
|
-
return data;
|
|
109
|
-
}
|
|
110
|
-
// loads all row data
|
|
111
|
-
function loadData() {
|
|
112
|
-
var rows = getTableBody().querySelectorAll('tr'),
|
|
113
|
-
i;
|
|
114
|
-
|
|
115
|
-
for (i = 0; i < rows.length; i += 1) {
|
|
116
|
-
rows[i].data = loadRowData(rows[i]);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
// sorts the table using the data for the ith column
|
|
120
|
-
function sortByIndex(index, desc) {
|
|
121
|
-
var key = cols[index].key,
|
|
122
|
-
sorter = function(a, b) {
|
|
123
|
-
a = a.data[key];
|
|
124
|
-
b = b.data[key];
|
|
125
|
-
return a < b ? -1 : a > b ? 1 : 0;
|
|
126
|
-
},
|
|
127
|
-
finalSorter = sorter,
|
|
128
|
-
tableBody = document.querySelector('.coverage-summary tbody'),
|
|
129
|
-
rowNodes = tableBody.querySelectorAll('tr'),
|
|
130
|
-
rows = [],
|
|
131
|
-
i;
|
|
132
|
-
|
|
133
|
-
if (desc) {
|
|
134
|
-
finalSorter = function(a, b) {
|
|
135
|
-
return -1 * sorter(a, b);
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
for (i = 0; i < rowNodes.length; i += 1) {
|
|
140
|
-
rows.push(rowNodes[i]);
|
|
141
|
-
tableBody.removeChild(rowNodes[i]);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
rows.sort(finalSorter);
|
|
145
|
-
|
|
146
|
-
for (i = 0; i < rows.length; i += 1) {
|
|
147
|
-
tableBody.appendChild(rows[i]);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
// removes sort indicators for current column being sorted
|
|
151
|
-
function removeSortIndicators() {
|
|
152
|
-
var col = getNthColumn(currentSort.index),
|
|
153
|
-
cls = col.className;
|
|
154
|
-
|
|
155
|
-
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
|
|
156
|
-
col.className = cls;
|
|
157
|
-
}
|
|
158
|
-
// adds sort indicators for current column being sorted
|
|
159
|
-
function addSortIndicators() {
|
|
160
|
-
getNthColumn(currentSort.index).className += currentSort.desc
|
|
161
|
-
? ' sorted-desc'
|
|
162
|
-
: ' sorted';
|
|
163
|
-
}
|
|
164
|
-
// adds event listeners for all sorter widgets
|
|
165
|
-
function enableUI() {
|
|
166
|
-
var i,
|
|
167
|
-
el,
|
|
168
|
-
ithSorter = function ithSorter(i) {
|
|
169
|
-
var col = cols[i];
|
|
170
|
-
|
|
171
|
-
return function() {
|
|
172
|
-
var desc = col.defaultDescSort;
|
|
173
|
-
|
|
174
|
-
if (currentSort.index === i) {
|
|
175
|
-
desc = !currentSort.desc;
|
|
176
|
-
}
|
|
177
|
-
sortByIndex(i, desc);
|
|
178
|
-
removeSortIndicators();
|
|
179
|
-
currentSort.index = i;
|
|
180
|
-
currentSort.desc = desc;
|
|
181
|
-
addSortIndicators();
|
|
182
|
-
};
|
|
183
|
-
};
|
|
184
|
-
for (i = 0; i < cols.length; i += 1) {
|
|
185
|
-
if (cols[i].sortable) {
|
|
186
|
-
// add the click event handler on the th so users
|
|
187
|
-
// dont have to click on those tiny arrows
|
|
188
|
-
el = getNthColumn(i).querySelector('.sorter').parentElement;
|
|
189
|
-
if (el.addEventListener) {
|
|
190
|
-
el.addEventListener('click', ithSorter(i));
|
|
191
|
-
} else {
|
|
192
|
-
el.attachEvent('onclick', ithSorter(i));
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
// adds sorting functionality to the UI
|
|
198
|
-
return function() {
|
|
199
|
-
if (!getTable()) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
cols = loadColumns();
|
|
203
|
-
loadData();
|
|
204
|
-
addSearchBox();
|
|
205
|
-
addSortIndicators();
|
|
206
|
-
enableUI();
|
|
207
|
-
};
|
|
208
|
-
})();
|
|
209
|
-
|
|
210
|
-
window.addEventListener('load', addSorting);
|
package/coverage/lcov.info
DELETED
|
File without changes
|
package/jest.config.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const baseConfig = require('../../jest.config.js');
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
...baseConfig,
|
|
5
|
-
roots: ["<rootDir>/src"],
|
|
6
|
-
setupFiles: ["<rootDir>/../../.jest/testEnvs.ts"],
|
|
7
|
-
setupFilesAfterEnv: ["<rootDir>/../../.jest/testLifecycle.ts"],
|
|
8
|
-
globalSetup: "<rootDir>/../../.jest/globalSetup.ts",
|
|
9
|
-
moduleNameMapper: {
|
|
10
|
-
"^@orchesty/nodejs-connectors/test/(.*)$": "<rootDir>/../../test/$1",
|
|
11
|
-
"^@orchesty/nodejs-connectors/lib/(.*)$": "<rootDir>/../../lib/$1",
|
|
12
|
-
},
|
|
13
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
|
|
2
|
-
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
3
|
-
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
|
|
4
|
-
import { BASE_URL } from '../HubSpotApplication';
|
|
5
|
-
|
|
6
|
-
export default class HubSpotAddEmailToListConnector extends AConnector {
|
|
7
|
-
|
|
8
|
-
public getName(): string {
|
|
9
|
-
return 'hub-spot-add-email-to-list';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto> {
|
|
13
|
-
const { listId, ...data } = dto.getJsonData();
|
|
14
|
-
|
|
15
|
-
const applicationInstall = await this.getApplicationInstallFromProcess(dto);
|
|
16
|
-
|
|
17
|
-
const request = await this.getApplication().getRequestDto(
|
|
18
|
-
dto,
|
|
19
|
-
applicationInstall,
|
|
20
|
-
HttpMethods.POST,
|
|
21
|
-
`${BASE_URL}/contacts/v1/lists/${listId}/add`,
|
|
22
|
-
JSON.stringify(data),
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const response = await this.getSender().send(request, [200, 409]);
|
|
26
|
-
|
|
27
|
-
dto.setData(response.getBody());
|
|
28
|
-
|
|
29
|
-
return dto;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface IInput {
|
|
35
|
-
listId: number;
|
|
36
|
-
emails?: string[];
|
|
37
|
-
vids?: number[];
|
|
38
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
|
|
2
|
-
import logger from '@orchesty/nodejs-sdk/dist/lib/Logger/Logger';
|
|
3
|
-
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
4
|
-
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
|
|
5
|
-
import { StatusCodes } from 'http-status-codes';
|
|
6
|
-
import { BASE_URL } from '../HubSpotApplication';
|
|
7
|
-
|
|
8
|
-
export default class HubSpotCreateContactConnector extends AConnector {
|
|
9
|
-
|
|
10
|
-
public getName(): string {
|
|
11
|
-
return 'hub-spot-create-contact';
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto> {
|
|
15
|
-
const applicationInstall = await this.getApplicationInstallFromProcess(dto);
|
|
16
|
-
|
|
17
|
-
const request = await this.getApplication().getRequestDto(
|
|
18
|
-
dto,
|
|
19
|
-
applicationInstall,
|
|
20
|
-
HttpMethods.POST,
|
|
21
|
-
`${BASE_URL}/crm/v3/objects/contacts`,
|
|
22
|
-
dto.getData(),
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const response = await this.getSender().send(request, [201, 409]);
|
|
26
|
-
|
|
27
|
-
if (response.getResponseCode() === StatusCodes.CONFLICT) {
|
|
28
|
-
const email = dto.getData();
|
|
29
|
-
logger.error(`Contact "${email}" already exist.`, dto);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
dto.setData(response.getBody());
|
|
33
|
-
|
|
34
|
-
return dto;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface IInput {
|
|
40
|
-
properties: {
|
|
41
|
-
email: string;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
|
|
2
|
-
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
3
|
-
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
|
|
4
|
-
import { BASE_URL } from '../HubSpotApplication';
|
|
5
|
-
|
|
6
|
-
export default class HubSpotSendTransactionEmailConnector extends AConnector {
|
|
7
|
-
|
|
8
|
-
public getName(): string {
|
|
9
|
-
return 'hub-spot-send-transaction-email';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto> {
|
|
13
|
-
const applicationInstall = await this.getApplicationInstallFromProcess(dto);
|
|
14
|
-
|
|
15
|
-
const request = await this.getApplication().getRequestDto(
|
|
16
|
-
dto,
|
|
17
|
-
applicationInstall,
|
|
18
|
-
HttpMethods.POST,
|
|
19
|
-
`${BASE_URL}/marketing/v3/transactional/single-email/send`,
|
|
20
|
-
dto.getData(),
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const response = await this.getSender().send(request, [200]);
|
|
24
|
-
|
|
25
|
-
dto.setData(response.getBody());
|
|
26
|
-
|
|
27
|
-
return dto;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface IInput {
|
|
33
|
-
emailId: number;
|
|
34
|
-
message: {
|
|
35
|
-
to: string;
|
|
36
|
-
from?: string;
|
|
37
|
-
sendId?: string;
|
|
38
|
-
replyTo?: string[];
|
|
39
|
-
};
|
|
40
|
-
cc?: string[];
|
|
41
|
-
bcc?: string[];
|
|
42
|
-
contactProperties?: Record<string, string>;
|
|
43
|
-
}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { NAME } from '@orchesty/connector-git-hub/src/GitHubApplication';
|
|
2
|
-
import ApplicationTypeEnum from '@orchesty/nodejs-sdk/dist/lib/Application/Base/ApplicationTypeEnum';
|
|
3
|
-
import CoreFormsEnum, { getFormName } from '@orchesty/nodejs-sdk/dist/lib/Application/Base/CoreFormsEnum';
|
|
4
|
-
import { IWebhookApplication } from '@orchesty/nodejs-sdk/dist/lib/Application/Base/IWebhookApplication';
|
|
5
|
-
import { ApplicationInstall } from '@orchesty/nodejs-sdk/dist/lib/Application/Database/ApplicationInstall';
|
|
6
|
-
import Webhook from '@orchesty/nodejs-sdk/dist/lib/Application/Database/Webhook';
|
|
7
|
-
import Field from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/Field';
|
|
8
|
-
import FieldType from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FieldType';
|
|
9
|
-
import Form from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/Form';
|
|
10
|
-
import FormStack from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FormStack';
|
|
11
|
-
import WebhookSubscription from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Webhook/WebhookSubscription';
|
|
12
|
-
import ScopeSeparatorEnum from '@orchesty/nodejs-sdk/dist/lib/Authorization/ScopeSeparatorEnum';
|
|
13
|
-
import AOAuth2Application from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/AOAuth2Application';
|
|
14
|
-
import { CLIENT_ID, CLIENT_SECRET } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/IOAuth2Application';
|
|
15
|
-
import RequestDto from '@orchesty/nodejs-sdk/dist/lib/Transport/Curl/RequestDto';
|
|
16
|
-
import ResponseDto from '@orchesty/nodejs-sdk/dist/lib/Transport/Curl/ResponseDto';
|
|
17
|
-
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
18
|
-
import AProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/AProcessDto';
|
|
19
|
-
import { CommonHeaders, JSON_TYPE } from '@orchesty/nodejs-sdk/dist/lib/Utils/Headers';
|
|
20
|
-
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
|
|
21
|
-
import { StatusCodes } from 'http-status-codes';
|
|
22
|
-
|
|
23
|
-
export const APP_ID = 'app_id';
|
|
24
|
-
export const BASE_URL = 'https://api.hubapi.com';
|
|
25
|
-
|
|
26
|
-
export default class HubSpotApplication extends AOAuth2Application implements IWebhookApplication {
|
|
27
|
-
|
|
28
|
-
public getApplicationType(): ApplicationTypeEnum {
|
|
29
|
-
return ApplicationTypeEnum.WEBHOOK;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public getName(): string {
|
|
33
|
-
return 'hub-spot';
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public getPublicName(): string {
|
|
37
|
-
return 'HubSpot';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public getAuthUrl(): string {
|
|
41
|
-
return 'https://app.hubspot.com/oauth/authorize';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public getTokenUrl(): string {
|
|
45
|
-
return 'https://api.hubapi.com/oauth/v1/token';
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public getLogo(): string {
|
|
49
|
-
return 'data:image/svg+xml;base64,PHN2ZyBpZD0iVnJzdHZhXzEiIGRhdGEtbmFtZT0iVnJzdHZhIDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDk1LjE4IDk5LjY0Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmN2E1OTt9PC9zdHlsZT48L2RlZnM+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNzUuNDksMzNWMjEuMDhhOS4xMyw5LjEzLDAsMCwwLDUuMjctOC4yM3YtLjI4YTkuMTQsOS4xNCwwLDAsMC05LjE0LTkuMTNoLS4yN2E5LjE0LDkuMTQsMCwwLDAtOS4xNCw5LjEzdi4yOGE5LjEzLDkuMTMsMCwwLDAsNS4yNyw4LjIzVjMzYTI1LjkxLDI1LjkxLDAsMCwwLTEyLjMsNS40MUwyMi42MywxM0E5LjczLDkuNzMsMCwwLDAsMjMsMTAuNDUsMTAuMywxMC4zLDAsMSwwLDEyLjY5LDIwLjczaDBhMTAuMjYsMTAuMjYsMCwwLDAsNS4wNy0xLjM4TDQ5LjgxLDQ0LjI4YTI2LDI2LDAsMCwwLC4zOSwyOS4yNGwtOS43NCw5Ljc1YTguNTgsOC41OCwwLDEsMCw1LjYzLDUuNjNsOS42NC05LjY1QTI2LDI2LDAsMSwwLDc1LjQ5LDMzbS00LDM5YTEzLjM0LDEzLjM0LDAsMSwxLS43MS0yNi42N2guNzFhMTMuMzQsMTMuMzQsMCwwLDEsMCwyNi42NyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTIuNDEgLTAuMTQpIi8+PC9zdmc+';
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public getDescription(): string {
|
|
53
|
-
return 'Marketing, sales, and customer service, with a completely free CRM at its core';
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public getRequestDto(
|
|
57
|
-
dto: AProcessDto,
|
|
58
|
-
applicationInstall: ApplicationInstall,
|
|
59
|
-
method: HttpMethods,
|
|
60
|
-
url?: string,
|
|
61
|
-
data?: unknown,
|
|
62
|
-
): RequestDto {
|
|
63
|
-
return new RequestDto(
|
|
64
|
-
url ?? BASE_URL,
|
|
65
|
-
method,
|
|
66
|
-
dto,
|
|
67
|
-
data,
|
|
68
|
-
{
|
|
69
|
-
[CommonHeaders.CONTENT_TYPE]: JSON_TYPE,
|
|
70
|
-
[CommonHeaders.ACCEPT]: JSON_TYPE,
|
|
71
|
-
[CommonHeaders.AUTHORIZATION]: `Bearer ${this.getAccessToken(applicationInstall)}`,
|
|
72
|
-
},
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
public getFormStack(): FormStack {
|
|
77
|
-
const form = new Form(CoreFormsEnum.AUTHORIZATION_FORM, getFormName(CoreFormsEnum.AUTHORIZATION_FORM))
|
|
78
|
-
.addField(new Field(FieldType.TEXT, CLIENT_ID, 'Client Id', null, true))
|
|
79
|
-
.addField(new Field(FieldType.TEXT, CLIENT_SECRET, 'Client Secret', null, true))
|
|
80
|
-
.addField(new Field(FieldType.TEXT, APP_ID, 'Application Id', null, true));
|
|
81
|
-
|
|
82
|
-
return new FormStack().addForm(form);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
public isAuthorized(applicationInstall: ApplicationInstall): boolean {
|
|
86
|
-
const authorizationForm = applicationInstall.getSettings()[CoreFormsEnum.AUTHORIZATION_FORM];
|
|
87
|
-
return super.isAuthorized(applicationInstall)
|
|
88
|
-
&& authorizationForm?.[CLIENT_ID]
|
|
89
|
-
&& authorizationForm?.[CLIENT_SECRET]
|
|
90
|
-
&& authorizationForm?.[APP_ID];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
94
|
-
public getScopes(applicationInstall: ApplicationInstall): string[] {
|
|
95
|
-
return ['oauth', 'crm.lists.read', 'crm.objects.contacts.read', 'crm.objects.contacts.write', 'crm.objects.companies.write', 'crm.schemas.contacts.read', 'crm.lists.write', 'crm.objects.companies.read', 'crm.objects.deals.read', 'crm.objects.deals.write', 'crm.schemas.companies.read', 'crm.schemas.companies.write', 'crm.schemas.contacts.write', 'crm.schemas.deals.read', 'crm.schemas.deals.write', 'crm.objects.owners.read'];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
public getWebhookSubscriptions(): WebhookSubscription[] {
|
|
99
|
-
return [
|
|
100
|
-
new WebhookSubscription('Create Contact', 'Webhook', '', { name: 'contact.creation' }),
|
|
101
|
-
new WebhookSubscription('Delete Contact', 'Webhook', '', { name: 'contact.deletion' }),
|
|
102
|
-
];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
public getWebhookSubscribeRequestDto(
|
|
106
|
-
applicationInstall: ApplicationInstall,
|
|
107
|
-
subscription: WebhookSubscription,
|
|
108
|
-
url: string,
|
|
109
|
-
): RequestDto {
|
|
110
|
-
const hubspotUrl = `${BASE_URL}/webhooks/v1/${applicationInstall.getSettings()[CoreFormsEnum.AUTHORIZATION_FORM][APP_ID]}`;
|
|
111
|
-
const body = JSON.stringify({
|
|
112
|
-
webhookUrl: url,
|
|
113
|
-
subscriptionDetails: {
|
|
114
|
-
subscriptionType: subscription.getParameters().name,
|
|
115
|
-
propertyName: 'email',
|
|
116
|
-
},
|
|
117
|
-
enabled: false,
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
return this.getRequestDto(
|
|
121
|
-
ProcessDto.createForFormRequest(NAME, applicationInstall.getUser(), crypto.randomUUID()),
|
|
122
|
-
applicationInstall,
|
|
123
|
-
HttpMethods.POST,
|
|
124
|
-
hubspotUrl,
|
|
125
|
-
body,
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
public getWebhookUnsubscribeRequestDto(applicationInstall: ApplicationInstall, webhook: Webhook): RequestDto {
|
|
130
|
-
const url = `${BASE_URL}/webhooks/v1/${applicationInstall
|
|
131
|
-
.getSettings()[CoreFormsEnum.AUTHORIZATION_FORM][APP_ID]}/subscriptions/${webhook.getWebhookId()}`;
|
|
132
|
-
|
|
133
|
-
return this.getRequestDto(
|
|
134
|
-
ProcessDto.createForFormRequest(NAME, applicationInstall.getUser(), crypto.randomUUID()),
|
|
135
|
-
applicationInstall,
|
|
136
|
-
HttpMethods.DELETE,
|
|
137
|
-
url,
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
142
|
-
public processWebhookSubscribeResponse(dto: ResponseDto, applicationInstall: ApplicationInstall): string {
|
|
143
|
-
const jsonBody = dto.getJsonBody() as { id: string };
|
|
144
|
-
|
|
145
|
-
return jsonBody.id ?? '';
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public processWebhookUnsubscribeResponse(dto: ResponseDto): boolean {
|
|
149
|
-
return dto.getResponseCode() === StatusCodes.NO_CONTENT;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
protected getScopesSeparator(): string {
|
|
153
|
-
return ScopeSeparatorEnum.SPACE;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import CoreFormsEnum, { getFormName } from '@orchesty/nodejs-sdk/dist/lib/Application/Base/CoreFormsEnum';
|
|
2
|
-
import { ApplicationInstall } from '@orchesty/nodejs-sdk/dist/lib/Application/Database/ApplicationInstall';
|
|
3
|
-
import Field from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/Field';
|
|
4
|
-
import FieldType from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FieldType';
|
|
5
|
-
import Form from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/Form';
|
|
6
|
-
import FormStack from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FormStack';
|
|
7
|
-
import { ABasicApplication, TOKEN } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/Basic/ABasicApplication';
|
|
8
|
-
import RequestDto from '@orchesty/nodejs-sdk/dist/lib/Transport/Curl/RequestDto';
|
|
9
|
-
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
10
|
-
import AProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/AProcessDto';
|
|
11
|
-
import { CommonHeaders, JSON_TYPE } from '@orchesty/nodejs-sdk/dist/lib/Utils/Headers';
|
|
12
|
-
import { BASE_URL } from './HubSpotApplication';
|
|
13
|
-
|
|
14
|
-
export default class HubSpotApplicationBasic extends ABasicApplication {
|
|
15
|
-
|
|
16
|
-
public getName(): string {
|
|
17
|
-
return 'hub-spot-basic';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public getPublicName(): string {
|
|
21
|
-
return 'HubSpot - Basic authorization';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public getLogo(): string {
|
|
25
|
-
return 'data:image/svg+xml;base64,PHN2ZyBpZD0iVnJzdHZhXzEiIGRhdGEtbmFtZT0iVnJzdHZhIDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDk1LjE4IDk5LjY0Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmN2E1OTt9PC9zdHlsZT48L2RlZnM+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNzUuNDksMzNWMjEuMDhhOS4xMyw5LjEzLDAsMCwwLDUuMjctOC4yM3YtLjI4YTkuMTQsOS4xNCwwLDAsMC05LjE0LTkuMTNoLS4yN2E5LjE0LDkuMTQsMCwwLDAtOS4xNCw5LjEzdi4yOGE5LjEzLDkuMTMsMCwwLDAsNS4yNyw4LjIzVjMzYTI1LjkxLDI1LjkxLDAsMCwwLTEyLjMsNS40MUwyMi42MywxM0E5LjczLDkuNzMsMCwwLDAsMjMsMTAuNDUsMTAuMywxMC4zLDAsMSwwLDEyLjY5LDIwLjczaDBhMTAuMjYsMTAuMjYsMCwwLDAsNS4wNy0xLjM4TDQ5LjgxLDQ0LjI4YTI2LDI2LDAsMCwwLC4zOSwyOS4yNGwtOS43NCw5Ljc1YTguNTgsOC41OCwwLDEsMCw1LjYzLDUuNjNsOS42NC05LjY1QTI2LDI2LDAsMSwwLDc1LjQ5LDMzbS00LDM5YTEzLjM0LDEzLjM0LDAsMSwxLS43MS0yNi42N2guNzFhMTMuMzQsMTMuMzQsMCwwLDEsMCwyNi42NyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTIuNDEgLTAuMTQpIi8+PC9zdmc+';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public getDescription(): string {
|
|
29
|
-
return 'Marketing, sales, and customer service, with a completely free CRM at its core';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public getRequestDto(
|
|
33
|
-
dto: AProcessDto,
|
|
34
|
-
applicationInstall: ApplicationInstall,
|
|
35
|
-
method: HttpMethods,
|
|
36
|
-
url?: string,
|
|
37
|
-
data?: unknown,
|
|
38
|
-
): RequestDto {
|
|
39
|
-
return new RequestDto(
|
|
40
|
-
url ?? BASE_URL,
|
|
41
|
-
method,
|
|
42
|
-
dto,
|
|
43
|
-
data,
|
|
44
|
-
{
|
|
45
|
-
[CommonHeaders.CONTENT_TYPE]: JSON_TYPE,
|
|
46
|
-
[CommonHeaders.ACCEPT]: JSON_TYPE,
|
|
47
|
-
[CommonHeaders.AUTHORIZATION]: `Bearer ${applicationInstall.getSettings()[CoreFormsEnum.AUTHORIZATION_FORM]?.[TOKEN]}`,
|
|
48
|
-
},
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public getFormStack(): FormStack {
|
|
53
|
-
const form = new Form(CoreFormsEnum.AUTHORIZATION_FORM, getFormName(CoreFormsEnum.AUTHORIZATION_FORM))
|
|
54
|
-
.addField(new Field(FieldType.TEXT, TOKEN, 'Token', null, true));
|
|
55
|
-
|
|
56
|
-
return new FormStack().addForm(form);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public isAuthorized(applicationInstall: ApplicationInstall): boolean {
|
|
60
|
-
const authorizationForm = applicationInstall.getSettings()[CoreFormsEnum.AUTHORIZATION_FORM];
|
|
61
|
-
return super.isAuthorized(applicationInstall)
|
|
62
|
-
&& authorizationForm?.[TOKEN];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
}
|
package/tsconfig.json
DELETED