@dma-sdk/hubspot 1.0.17 → 1.0.18
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/constants/subscriptions.d.ts +1 -0
- package/dist/constants/subscriptions.js +1 -0
- package/dist/services/hubspot-service.d.ts +13 -3
- package/dist/services/hubspot-service.js +11 -5
- package/lib/constants/subscriptions.ts +1 -0
- package/lib/services/hubspot-service.ts +16 -10
- package/package.json +1 -1
|
@@ -5,4 +5,5 @@ const events_1 = require("./events");
|
|
|
5
5
|
const objects_1 = require("./objects");
|
|
6
6
|
exports.HsSubscriptionTypes = {
|
|
7
7
|
ticketPropChange: `${objects_1.HsObjectTypes.ticket}.${events_1.HsEventTypes.propertyChange}`,
|
|
8
|
+
dealCreation: `${objects_1.HsObjectTypes.deal}.${events_1.HsEventTypes.creation}`,
|
|
8
9
|
};
|
|
@@ -68,9 +68,19 @@ export declare class HubspotService {
|
|
|
68
68
|
createObject(objectType: string, properties: SimplePublicObjectInputForCreate, accessToken: string): Promise<SimplePublicObject | {
|
|
69
69
|
id: string;
|
|
70
70
|
}>;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
getObjectById(params: {
|
|
72
|
+
objectType: string;
|
|
73
|
+
objectId: string;
|
|
74
|
+
accessToken: string;
|
|
75
|
+
}): Promise<SimplePublicObject>;
|
|
76
|
+
getObject(params: {
|
|
77
|
+
objectType: string;
|
|
78
|
+
objectId: string;
|
|
79
|
+
associations?: string[];
|
|
80
|
+
props?: string[];
|
|
81
|
+
propsWithHistory?: string[];
|
|
82
|
+
accessToken: string;
|
|
83
|
+
}): Promise<SimplePublicObject>;
|
|
74
84
|
getObjectWithPropsType(objectType: string, objectId: string, accessToken: string, types?: string[]): Promise<SimplePublicObject & {
|
|
75
85
|
propertiesWithTypes: {
|
|
76
86
|
[key: string]: {
|
|
@@ -82,19 +82,25 @@ class HubspotService {
|
|
|
82
82
|
const response = await this.client.crm.objects.basicApi.create(objectType, properties);
|
|
83
83
|
return response;
|
|
84
84
|
}
|
|
85
|
-
async
|
|
85
|
+
async getObjectById(params) {
|
|
86
|
+
const { objectType, objectId, accessToken } = params;
|
|
86
87
|
this.client.setAccessToken(accessToken);
|
|
87
88
|
return await this.client.crm.objects.basicApi.getById(objectType, objectId);
|
|
88
89
|
}
|
|
89
|
-
async
|
|
90
|
-
|
|
90
|
+
async getObject(params) {
|
|
91
|
+
const { objectType, objectId, associations, props, propsWithHistory, accessToken } = params;
|
|
91
92
|
this.client.setAccessToken(accessToken);
|
|
92
|
-
return await this.client.crm.objects.basicApi.getById(objectType, objectId, props);
|
|
93
|
+
return await this.client.crm.objects.basicApi.getById(objectType, objectId, props, propsWithHistory, associations);
|
|
93
94
|
}
|
|
94
95
|
async getObjectWithPropsType(objectType, objectId, accessToken, types) {
|
|
95
96
|
this.client.setAccessToken(accessToken);
|
|
96
97
|
const props = await this.listObjectProperties({ objectType, types });
|
|
97
|
-
const data = await this.
|
|
98
|
+
const data = await this.getObject({
|
|
99
|
+
objectType,
|
|
100
|
+
objectId,
|
|
101
|
+
props: props.results.map((prop) => prop.name),
|
|
102
|
+
accessToken
|
|
103
|
+
});
|
|
98
104
|
let formattedProp = {};
|
|
99
105
|
props.results.forEach((property) => {
|
|
100
106
|
if (!data.properties[property.name]) {
|
|
@@ -147,11 +147,12 @@ export class HubspotService {
|
|
|
147
147
|
return response
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
async
|
|
150
|
+
async getObjectById(params: {
|
|
151
151
|
objectType: string,
|
|
152
|
-
objectId: string,
|
|
152
|
+
objectId: string,
|
|
153
153
|
accessToken: string
|
|
154
|
-
): Promise<SimplePublicObject> {
|
|
154
|
+
}): Promise<SimplePublicObject> {
|
|
155
|
+
const { objectType, objectId, accessToken } = params
|
|
155
156
|
this.client.setAccessToken(accessToken)
|
|
156
157
|
return await this.client.crm.objects.basicApi.getById(
|
|
157
158
|
objectType,
|
|
@@ -159,17 +160,22 @@ export class HubspotService {
|
|
|
159
160
|
);
|
|
160
161
|
}
|
|
161
162
|
|
|
162
|
-
async
|
|
163
|
+
async getObject(params: {
|
|
163
164
|
objectType: string,
|
|
164
165
|
objectId: string,
|
|
165
|
-
|
|
166
|
+
associations?: string[],
|
|
167
|
+
props?: string[], // nome delle props da restituire
|
|
168
|
+
propsWithHistory?: string[], // nome delle props da restituire
|
|
166
169
|
accessToken: string
|
|
167
|
-
): Promise<SimplePublicObject> {
|
|
170
|
+
}): Promise<SimplePublicObject> {
|
|
171
|
+
const { objectType, objectId, associations, props, propsWithHistory, accessToken } = params
|
|
168
172
|
this.client.setAccessToken(accessToken)
|
|
169
173
|
return await this.client.crm.objects.basicApi.getById(
|
|
170
174
|
objectType,
|
|
171
175
|
objectId,
|
|
172
|
-
props
|
|
176
|
+
props,
|
|
177
|
+
propsWithHistory,
|
|
178
|
+
associations
|
|
173
179
|
);
|
|
174
180
|
}
|
|
175
181
|
|
|
@@ -181,12 +187,12 @@ export class HubspotService {
|
|
|
181
187
|
): Promise<SimplePublicObject & { propertiesWithTypes: { [key: string]: { type: string, label: string, value: string | null } }}> {
|
|
182
188
|
this.client.setAccessToken(accessToken)
|
|
183
189
|
const props = await this.listObjectProperties({ objectType, types })
|
|
184
|
-
const data = await this.
|
|
190
|
+
const data = await this.getObject({
|
|
185
191
|
objectType,
|
|
186
192
|
objectId,
|
|
187
|
-
props.results.map((prop) => prop.name),
|
|
193
|
+
props: props.results.map((prop) => prop.name),
|
|
188
194
|
accessToken
|
|
189
|
-
);
|
|
195
|
+
});
|
|
190
196
|
|
|
191
197
|
|
|
192
198
|
let formattedProp: { [key: string]: { type: string, label: string, value: string | null } } = {}
|