@@ -110,12 +110,20 @@ class Names(StrEnum):
110
110
quotes = auto ()
111
111
subscriptions = auto ()
112
112
tickets = auto ()
113
+ emails = auto ()
114
+ meetings = auto ()
115
+ notes = auto ()
116
+ tasks = auto ()
117
+ content = auto ()
118
+ orders = auto ()
119
+ carts = auto ()
120
+ partner_clients = auto ()
121
+ marketing_event = auto ()
113
122
114
123
115
124
# A Property is a HubSpot or HubSpot-user defined attribute that's
116
125
# attached to a HubSpot CRM object.
117
126
class Property (BaseDocument , extra = "allow" ):
118
-
119
127
name : str = ""
120
128
calculated : bool = False
121
129
hubspotObject : str = "unknown" # Added by us.
@@ -126,7 +134,6 @@ class Properties(BaseDocument, extra="forbid"):
126
134
127
135
128
136
class DealPipeline (BaseDocument , extra = "allow" ):
129
-
130
137
createdAt : AwareDatetime | None
131
138
updatedAt : AwareDatetime | None
132
139
@@ -136,7 +143,6 @@ class DealPipelines(BaseDocument, extra="forbid"):
136
143
137
144
138
145
class Owner (BaseDocument , extra = "allow" ):
139
-
140
146
createdAt : AwareDatetime | None
141
147
updatedAt : AwareDatetime | None
142
148
@@ -185,7 +191,6 @@ def _post_init(self) -> Self:
185
191
k : v for k , v in self .propertiesWithHistory .items () if len (v )
186
192
}
187
193
188
-
189
194
# If the model has attached inline associations,
190
195
# hoist them to corresponding arrays. Then clear associations.
191
196
for ae in self .ASSOCIATED_ENTITIES :
@@ -222,9 +227,40 @@ class Deal(BaseCRMObject):
222
227
223
228
224
229
class Engagement (BaseCRMObject ):
225
- ASSOCIATED_ENTITIES = [Names .deals ]
230
+ ASSOCIATED_ENTITIES = [
231
+ Names .contacts ,
232
+ Names .companies ,
233
+ Names .deals ,
234
+ Names .tickets ,
235
+ Names .quotes ,
236
+ Names .orders ,
237
+ Names .emails ,
238
+ Names .meetings ,
239
+ Names .notes ,
240
+ Names .tasks ,
241
+ Names .content ,
242
+ Names .orders ,
243
+ Names .carts ,
244
+ Names .partner_clients ,
245
+ Names .marketing_event ,
246
+ ]
226
247
248
+ contacts : list [int ] = []
249
+ companies : list [int ] = []
227
250
deals : list [int ] = []
251
+ tickets : list [int ] = []
252
+ content : list [int ] = []
253
+ quotes : list [int ] = []
254
+ orders : list [int ] = []
255
+ emails : list [int ] = []
256
+ meetings : list [int ] = []
257
+ notes : list [int ] = []
258
+ tasks : list [int ] = []
259
+ content : list [int ] = []
260
+ orders : list [int ] = []
261
+ carts : list [int ] = []
262
+ partner_clients : list [int ] = []
263
+ marketing_event : list [int ] = []
228
264
229
265
230
266
class Ticket (BaseCRMObject ):
@@ -241,7 +277,14 @@ class Product(BaseCRMObject):
241
277
242
278
243
279
class LineItem (BaseCRMObject ):
244
- ASSOCIATED_ENTITIES = [Names .commerce_payments , Names .products , Names .deals , Names .invoices , Names .quotes , Names .subscriptions ]
280
+ ASSOCIATED_ENTITIES = [
281
+ Names .commerce_payments ,
282
+ Names .products ,
283
+ Names .deals ,
284
+ Names .invoices ,
285
+ Names .quotes ,
286
+ Names .subscriptions ,
287
+ ]
245
288
246
289
commerce_payments : list [int ] = []
247
290
products : list [int ] = []
@@ -253,7 +296,6 @@ class LineItem(BaseCRMObject):
253
296
254
297
# An Association, as returned by the v4 associations API.
255
298
class Association (BaseModel , extra = "forbid" ):
256
-
257
299
class Type (BaseModel , extra = "forbid" ):
258
300
category : Literal ["HUBSPOT_DEFINED" , "USER_DEFINED" ]
259
301
# Type IDs are defined here: https://developers.hubspot.com/docs/api/crm/associations
@@ -296,7 +338,6 @@ class Paging(BaseModel, extra="forbid"):
296
338
# Common shape of a v3 API paged listing for a GET request to the objects endpoint for a particular
297
339
# object.
298
340
class PageResult (BaseModel , Generic [Item ], extra = "forbid" ):
299
-
300
341
class Cursor (BaseModel , extra = "forbid" ):
301
342
after : str
302
343
link : str
@@ -311,7 +352,6 @@ class Paging(BaseModel, extra="forbid"):
311
352
# Common shape of a v3 search API listing, which is the same as PageResult but includes a field for
312
353
# the total number of records returned, and doesn't have a "link" in the paging.next object.
313
354
class SearchPageResult (BaseModel , Generic [Item ], extra = "forbid" ):
314
-
315
355
class Cursor (BaseModel , extra = "forbid" ):
316
356
after : str
317
357
@@ -325,7 +365,6 @@ class Paging(BaseModel, extra="forbid"):
325
365
326
366
# Common shape of a v3 API batch read.
327
367
class BatchResult (BaseModel , Generic [Item ], extra = "forbid" ):
328
-
329
368
class Error (BaseModel , extra = "forbid" ):
330
369
status : Literal ["error" ]
331
370
category : Literal ["OBJECT_NOT_FOUND" ]
@@ -349,7 +388,6 @@ class Error(BaseModel, extra="forbid"):
349
388
350
389
351
390
class OldRecentCompanies (BaseModel ):
352
-
353
391
class Item (BaseModel ):
354
392
class Properties (BaseModel ):
355
393
class Timestamp (BaseModel ):
@@ -367,7 +405,6 @@ class Timestamp(BaseModel):
367
405
368
406
369
407
class OldRecentContacts (BaseModel ):
370
-
371
408
class Item (BaseModel ):
372
409
class Properties (BaseModel ):
373
410
class Timestamp (BaseModel ):
@@ -379,13 +416,12 @@ class Timestamp(BaseModel):
379
416
properties : Properties
380
417
381
418
contacts : list [Item ]
382
- has_more : bool = Field (alias = "has-more" ) # type: ignore
383
- time_offset : int = Field (alias = "time-offset" ) # type: ignore
384
- vid_offset : int = Field (alias = "vid-offset" ) # type: ignore
419
+ has_more : bool = Field (alias = "has-more" ) # type: ignore
420
+ time_offset : int = Field (alias = "time-offset" ) # type: ignore
421
+ vid_offset : int = Field (alias = "vid-offset" ) # type: ignore
385
422
386
423
387
424
class OldRecentDeals (BaseModel ):
388
-
389
425
class Item (BaseModel ):
390
426
class Properties (BaseModel ):
391
427
class Timestamp (BaseModel ):
@@ -403,7 +439,6 @@ class Timestamp(BaseModel):
403
439
404
440
405
441
class OldRecentEngagements (BaseModel ):
406
-
407
442
class Item (BaseModel ):
408
443
class Engagement (BaseModel ):
409
444
id : int
@@ -425,6 +460,7 @@ class OldRecentTicket(BaseModel):
425
460
# EmailEvent and EmailEventsResponse represent an email event and the shape of the email events API
426
461
# response, respectively.
427
462
463
+
428
464
class EmailEvent (BaseDocument , extra = "allow" ):
429
465
id : str
430
466
created : AwareDatetime
@@ -442,12 +478,12 @@ class EmailEvent(BaseDocument, extra="allow"):
442
478
"STATUSCHANGE" ,
443
479
"SPAMREPORT" ,
444
480
"SUPPRESSED" ,
445
- "SUPPRESSION" , # "SUPPRESSION" is documented in HubSpot's docs, but "SUPPRESSED" isn't. We've seen "SUPPRESSED" events, so "SUPPRESSION" events might not actually occur.
446
- "UNBOUNCE" , # This is not actually a type reported by HubSpot, but the absence of the "type" field means its an UNBOUNCE type.
481
+ "SUPPRESSION" , # "SUPPRESSION" is documented in HubSpot's docs, but "SUPPRESSED" isn't. We've seen "SUPPRESSED" events, so "SUPPRESSION" events might not actually occur.
482
+ "UNBOUNCE" , # This is not actually a type reported by HubSpot, but the absence of the "type" field means its an UNBOUNCE type.
447
483
] = Field (
448
484
default = "UNBOUNCE" ,
449
- # Don't schematize the default value.
450
- json_schema_extra = lambda x : x .pop (' default' ), # type: ignore
485
+ # Don't schematize the default value.
486
+ json_schema_extra = lambda x : x .pop (" default" ), # type: ignore
451
487
)
452
488
453
489
@@ -478,7 +514,6 @@ class CustomObjectSchema(BaseDocument, extra="allow"):
478
514
# This is the shape of a response from the V3 search API for custom objects. As above, we are
479
515
# modeling only the minimum needed to get the IDs and modification time.
480
516
class CustomObjectSearchResult (BaseModel ):
481
-
482
517
class Properties (BaseModel ):
483
518
hs_lastmodifieddate : AwareDatetime
484
519
@@ -488,10 +523,14 @@ def set_lastmodifieddate(cls, values):
488
523
489
524
# The "Contacts" object uses `lastmodifieddate`, while everything
490
525
# else uses `hs_lastmodifieddate`.
491
- if 'lastmodifieddate' in values :
492
- values ['hs_lastmodifieddate' ] = datetime .fromisoformat (values .pop ('lastmodifieddate' ))
493
- elif 'hs_lastmodifieddate' in values :
494
- values ['hs_lastmodifieddate' ] = datetime .fromisoformat (values .pop ('hs_lastmodifieddate' ))
526
+ if "lastmodifieddate" in values :
527
+ values ["hs_lastmodifieddate" ] = datetime .fromisoformat (
528
+ values .pop ("lastmodifieddate" )
529
+ )
530
+ elif "hs_lastmodifieddate" in values :
531
+ values ["hs_lastmodifieddate" ] = datetime .fromisoformat (
532
+ values .pop ("hs_lastmodifieddate" )
533
+ )
495
534
return values
496
535
497
536
id : int
0 commit comments