hubspot/
lib.rs

1use std::sync::Arc;
2
3use builder::HubspotBuilder;
4use client::HubspotClient;
5use engagements::EngagementsManager;
6use objects::ObjectsManager;
7
8mod api_configs;
9mod builder;
10mod client;
11mod engagements;
12mod objects;
13mod owners;
14
15pub mod associations {
16    pub use super::api_configs::{AssociationCreationDetails, AssociationTypes};
17}
18
19pub use api_configs::types;
20pub use engagements::notes;
21pub use engagements::EngagementType;
22pub use objects::ObjectType;
23use owners::OwnerApi;
24
25// A Rust implementation of the Hubspot CRM API
26#[derive(Clone, Debug)]
27pub struct Hubspot {
28    pub portal_id: String,
29    /// Objects represent types of relationships or processes.
30    pub objects: ObjectsManager,
31    /// Engagements store data from interactions with records.
32    pub engagements: EngagementsManager,
33    /// Owners are specific users assigned to contacts, companies, deals, tickets, or engagements.
34    pub owners: OwnerApi,
35}
36
37impl Hubspot {
38    /// Create hubspot api
39    pub fn new(client: HubspotClient) -> Self {
40        let portal_id = client.portal_id.clone();
41        let client = Arc::new(client);
42
43        Self {
44            portal_id,
45            objects: ObjectsManager::new(Arc::clone(&client)),
46            engagements: EngagementsManager::new(Arc::clone(&client)),
47            owners: OwnerApi::new(Arc::clone(&client)),
48        }
49    }
50
51    /// Create Hubspot client
52    pub fn builder() -> HubspotBuilder {
53        HubspotBuilder::new()
54    }
55}