@dma-sdk/hubspot 1.0.20 → 1.0.22
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.
|
@@ -2,7 +2,7 @@ import { HubspotUser } from '../interfaces/user';
|
|
|
2
2
|
import { Configuration } from '@hubspot/api-client/lib/codegen/crm/objects';
|
|
3
3
|
import { SimplePublicObjectInputForCreate } from '@hubspot/api-client/lib/codegen/crm/objects/taxes/models/all';
|
|
4
4
|
import { SimplePublicObject } from '@hubspot/api-client/lib/codegen/crm/objects/tasks/models/all';
|
|
5
|
-
import { LabelsBetweenObjectPair } from '@hubspot/api-client/lib/codegen/crm/associations/v4';
|
|
5
|
+
import { CollectionResponseMultiAssociatedObjectWithLabelForwardPaging, LabelsBetweenObjectPair } from '@hubspot/api-client/lib/codegen/crm/associations/v4';
|
|
6
6
|
import { TokenResponseIF } from '@hubspot/api-client/lib/codegen/oauth';
|
|
7
7
|
import { TokenResponse } from '../interfaces/token';
|
|
8
8
|
import { CollectionResponsePropertyNoPaging, PropertyCreate, PropertyGroup, PropertyGroupCreate } from '@hubspot/api-client/lib/codegen/crm/properties';
|
|
@@ -10,7 +10,7 @@ import { HubspotSignatureData } from '../types/auth/hs-signature-data';
|
|
|
10
10
|
import { CreateSubscriptionInput } from '../interfaces/input/subscriptions';
|
|
11
11
|
import { CreateSubscriptionOutput } from '../interfaces/output/subscriptions';
|
|
12
12
|
import { PublicObjectSearchRequest, SimplePublicObjectWithAssociations } from '@hubspot/api-client/lib/codegen/crm/companies';
|
|
13
|
-
import { AssociateObjectInput, BatchAssociateObjectInput } from '../interfaces/input/associations';
|
|
13
|
+
import { AssociateObjectInput, BatchAssociateObjectInput, BatchListAssociationsInput } from '../interfaces/input/associations';
|
|
14
14
|
export declare class HubspotService {
|
|
15
15
|
static HS_BASE_URL: string;
|
|
16
16
|
static readonly hubspotObjectType: {
|
|
@@ -93,10 +93,11 @@ export declare class HubspotService {
|
|
|
93
93
|
updateObject(objectType: string, objectId: string, properties: {
|
|
94
94
|
[key: string]: string;
|
|
95
95
|
}, accessToken: string, options?: Configuration): Promise<SimplePublicObject>;
|
|
96
|
+
listAssociations(commandInput: BatchListAssociationsInput, accessToken: string): Promise<CollectionResponseMultiAssociatedObjectWithLabelForwardPaging>;
|
|
96
97
|
associateObjects(commandInput: AssociateObjectInput, accessToken: string): Promise<LabelsBetweenObjectPair>;
|
|
97
|
-
associateObjectsBatch(commandInput: BatchAssociateObjectInput, accessToken: string): Promise<
|
|
98
|
-
errors: string;
|
|
99
|
-
}
|
|
98
|
+
associateObjectsBatch(commandInput: BatchAssociateObjectInput, accessToken: string): Promise<{
|
|
99
|
+
errors: string[];
|
|
100
|
+
}>;
|
|
100
101
|
createObjectProperties(objectType: string, properties: PropertyCreate[], accessToken: string): Promise<any>;
|
|
101
102
|
createPropertyGroup(objectType: string, group: PropertyGroupCreate, accessToken: string): Promise<PropertyGroup>;
|
|
102
103
|
convertPropertyValues(properties: {
|
|
@@ -127,6 +127,11 @@ class HubspotService {
|
|
|
127
127
|
});
|
|
128
128
|
return response;
|
|
129
129
|
}
|
|
130
|
+
async listAssociations(commandInput, accessToken) {
|
|
131
|
+
this.client.setAccessToken(accessToken);
|
|
132
|
+
const response = await this.client.crm.associations.v4.basicApi.getPage(commandInput.firstObjectType, commandInput.firstObjectId, commandInput.secondObjectType);
|
|
133
|
+
return response;
|
|
134
|
+
}
|
|
130
135
|
async associateObjects(commandInput, accessToken) {
|
|
131
136
|
this.client.setAccessToken(accessToken);
|
|
132
137
|
const { objectTypeFirst, objectTypeSecond, objectIdFirst, objectIdSecond, options } = commandInput;
|
|
@@ -152,12 +157,10 @@ class HubspotService {
|
|
|
152
157
|
await this.fetchApi(api_1.ApiMethods.associateObjectBatch(commandInput.objectTypeFirst, commandInput.objectTypeSecond), options);
|
|
153
158
|
}
|
|
154
159
|
catch (error) {
|
|
155
|
-
errors.push(
|
|
156
|
-
errors: error instanceof Error ? error.message : String(error)
|
|
157
|
-
});
|
|
160
|
+
errors.push(error instanceof Error ? error.message : String(error));
|
|
158
161
|
}
|
|
159
162
|
}
|
|
160
|
-
return errors;
|
|
163
|
+
return { errors };
|
|
161
164
|
}
|
|
162
165
|
async createObjectProperties(objectType, properties, accessToken) {
|
|
163
166
|
const options = {
|
|
@@ -3,7 +3,7 @@ import { HubspotUser } from '../interfaces/user'
|
|
|
3
3
|
import { Configuration, Filter } from '@hubspot/api-client/lib/codegen/crm/objects'
|
|
4
4
|
import { SimplePublicObjectInputForCreate } from '@hubspot/api-client/lib/codegen/crm/objects/taxes/models/all'
|
|
5
5
|
import { SimplePublicObject } from '@hubspot/api-client/lib/codegen/crm/objects/tasks/models/all'
|
|
6
|
-
import { LabelsBetweenObjectPair } from '@hubspot/api-client/lib/codegen/crm/associations/v4'
|
|
6
|
+
import { CollectionResponseMultiAssociatedObjectWithLabelForwardPaging, LabelsBetweenObjectPair } from '@hubspot/api-client/lib/codegen/crm/associations/v4'
|
|
7
7
|
import { PromiseConfigurationOptions, TokenResponseIF } from '@hubspot/api-client/lib/codegen/oauth'
|
|
8
8
|
import { typeConverter } from '../utils/type-converter'
|
|
9
9
|
import { HubspotTypeConverter } from '../interfaces/hubspot-type-converter'
|
|
@@ -17,7 +17,7 @@ import { ApiMethods } from '../constants/api'
|
|
|
17
17
|
import { CreateSubscriptionInput } from '../interfaces/input/subscriptions'
|
|
18
18
|
import { CreateSubscriptionOutput } from '../interfaces/output/subscriptions'
|
|
19
19
|
import { PublicObjectSearchRequest, SimplePublicObjectWithAssociations } from '@hubspot/api-client/lib/codegen/crm/companies'
|
|
20
|
-
import { AssociateObjectInput, AssociationsObject, BatchAssociateObjectInput } from '../interfaces/input/associations'
|
|
20
|
+
import { AssociateObjectInput, AssociationsObject, BatchAssociateObjectInput, BatchListAssociationsInput } from '../interfaces/input/associations'
|
|
21
21
|
import { SystemError } from '../exceptions/system-error'
|
|
22
22
|
|
|
23
23
|
// Per ogni metodo che viene creato, è fondamentale che
|
|
@@ -234,6 +234,20 @@ export class HubspotService {
|
|
|
234
234
|
return response
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
+
async listAssociations(
|
|
238
|
+
commandInput: BatchListAssociationsInput,
|
|
239
|
+
accessToken: string
|
|
240
|
+
): Promise<CollectionResponseMultiAssociatedObjectWithLabelForwardPaging> {
|
|
241
|
+
this.client.setAccessToken(accessToken)
|
|
242
|
+
const response = await this.client.crm.associations.v4.basicApi.getPage(
|
|
243
|
+
commandInput.firstObjectType,
|
|
244
|
+
commandInput.firstObjectId,
|
|
245
|
+
commandInput.secondObjectType
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
return response
|
|
249
|
+
}
|
|
250
|
+
|
|
237
251
|
async associateObjects(
|
|
238
252
|
commandInput: AssociateObjectInput,
|
|
239
253
|
accessToken: string
|
|
@@ -254,8 +268,8 @@ export class HubspotService {
|
|
|
254
268
|
async associateObjectsBatch(
|
|
255
269
|
commandInput: BatchAssociateObjectInput,
|
|
256
270
|
accessToken: string
|
|
257
|
-
): Promise<
|
|
258
|
-
const errors
|
|
271
|
+
): Promise<{ errors: string[] }> {
|
|
272
|
+
const errors = []
|
|
259
273
|
const chunkSize = 20
|
|
260
274
|
|
|
261
275
|
for (let i = 0; i < commandInput.associations.length; i += chunkSize) {
|
|
@@ -278,13 +292,11 @@ export class HubspotService {
|
|
|
278
292
|
options
|
|
279
293
|
)
|
|
280
294
|
} catch (error) {
|
|
281
|
-
errors.push(
|
|
282
|
-
errors: error instanceof Error ? error.message : String(error)
|
|
283
|
-
})
|
|
295
|
+
errors.push(error instanceof Error ? error.message : String(error))
|
|
284
296
|
}
|
|
285
297
|
}
|
|
286
298
|
|
|
287
|
-
return errors
|
|
299
|
+
return { errors }
|
|
288
300
|
}
|
|
289
301
|
|
|
290
302
|
async createObjectProperties(
|