cufinder_rust/
sdk.rs

1use crate::{
2    client::{Client, ClientConfig},
3    error::Result,
4    services::Service,
5    types::*,
6};
7use std::time::Duration;
8
9/// Main CUFinder SDK
10pub struct CufinderSDK {
11    client: Client,
12    service: Service,
13}
14
15impl CufinderSDK {
16    /// Create a new SDK instance with just an API key
17    pub fn new(api_key: String) -> Result<Self> {
18        let config = ClientConfig {
19            api_key,
20            base_url: "https://api.cufinder.io/v2".to_string(),
21            timeout: Duration::from_secs(30),
22            max_retries: 3,
23        };
24
25        Self::with_config(config)
26    }
27
28    /// Create a new SDK instance with custom configuration
29    pub fn with_config(config: ClientConfig) -> Result<Self> {
30        let client = Client::new(config)?;
31        let service = Service::new(client.clone());
32
33        Ok(Self { client, service })
34    }
35
36    /// Get the underlying HTTP client for advanced usage
37    pub fn client(&self) -> &Client {
38        &self.client
39    }
40
41    // Company Services
42
43    /// CUF - Get company domain from company name
44    pub async fn cuf(&self, company_name: &str, country_code: &str) -> Result<CufResponse> {
45        self.service.get_domain(CufParams {
46            company_name: company_name.to_string(),
47            country_code: country_code.to_string(),
48        }).await
49    }
50
51    /// LCUF - Get LinkedIn URL from company name
52    pub async fn lcuf(&self, company_name: &str) -> Result<LcufResponse> {
53        self.service.get_linkedin_url(LcufParams {
54            company_name: company_name.to_string(),
55        }).await
56    }
57
58    /// DTC - Get company name from domain
59    pub async fn dtc(&self, company_website: &str) -> Result<DtcResponse> {
60        self.service.get_company_name(DtcParams {
61            company_website: company_website.to_string(),
62        }).await
63    }
64
65    /// DTE - Get company emails from domain
66    pub async fn dte(&self, company_website: &str) -> Result<DteResponse> {
67        self.service.get_emails(DteParams {
68            company_website: company_website.to_string(),
69        }).await
70    }
71
72    /// NTP - Get company phones from company name
73    pub async fn ntp(&self, company_name: &str) -> Result<NtpResponse> {
74        self.service.get_phones(NtpParams {
75            company_name: company_name.to_string(),
76        }).await
77    }
78
79    // Person Services
80
81    /// EPP - Enrich LinkedIn profile
82    pub async fn epp(&self, linkedin_url: &str) -> Result<EppResponse> {
83        self.service.enrich_profile(EppParams {
84            linkedin_url: linkedin_url.to_string(),
85        }).await
86    }
87
88    /// REL - Reverse email lookup
89    pub async fn rel(&self, email: &str) -> Result<RelResponse> {
90        self.service.reverse_email_lookup(RelParams {
91            email: email.to_string(),
92        }).await
93    }
94
95    /// FWE - Get email from profile
96    pub async fn fwe(&self, linkedin_url: &str) -> Result<FweResponse> {
97        self.service.get_email_from_profile(FweParams {
98            linkedin_url: linkedin_url.to_string(),
99        }).await
100    }
101
102    /// TEP - Enrich person information
103    pub async fn tep(&self, full_name: &str, company: &str) -> Result<TepResponse> {
104        self.service.enrich_person(TepParams {
105            full_name: full_name.to_string(),
106            company: company.to_string(),
107        }).await
108    }
109
110    // Company Intelligence Services
111
112    /// FCL - Get company lookalikes
113    pub async fn fcl(&self, query: &str) -> Result<FclResponse> {
114        self.service.get_lookalikes(FclParams {
115            query: query.to_string(),
116        }).await
117    }
118
119    /// ELF - Get company fundraising information
120    pub async fn elf(&self, query: &str) -> Result<ElfResponse> {
121        self.service.get_fundraising(ElfParams {
122            query: query.to_string(),
123        }).await
124    }
125
126    /// CAR - Get company revenue
127    pub async fn car(&self, query: &str) -> Result<CarResponse> {
128        self.service.get_revenue(CarParams {
129            query: query.to_string(),
130        }).await
131    }
132
133    /// FCC - Get company subsidiaries
134    pub async fn fcc(&self, query: &str) -> Result<FccResponse> {
135        self.service.get_subsidiaries(FccParams {
136            query: query.to_string(),
137        }).await
138    }
139
140    /// FTS - Get company tech stack
141    pub async fn fts(&self, query: &str) -> Result<FtsResponse> {
142        self.service.get_tech_stack(FtsParams {
143            query: query.to_string(),
144        }).await
145    }
146
147    /// ENC - Enrich company information
148    pub async fn enc(&self, query: &str) -> Result<EncResponse> {
149        self.service.enrich_company(EncParams {
150            query: query.to_string(),
151        }).await
152    }
153
154    /// CEC - Get company employee countries
155    pub async fn cec(&self, query: &str) -> Result<CecResponse> {
156        self.service.get_employee_countries(CecParams {
157            query: query.to_string(),
158        }).await
159    }
160
161    /// CLO - Get company locations
162    pub async fn clo(&self, query: &str) -> Result<CloResponse> {
163        self.service.get_locations(CloParams {
164            query: query.to_string(),
165        }).await
166    }
167
168    // Search Services
169
170    /// CSE - Search companies
171    pub async fn cse(&self, params: CseParams) -> Result<CseResponse> {
172        self.service.search_companies(params).await
173    }
174
175    /// PSE - Search people
176    pub async fn pse(&self, params: PseParams) -> Result<PseResponse> {
177        self.service.search_people(params).await
178    }
179
180    /// LBS - Search local businesses
181    pub async fn lbs(&self, params: LbsParams) -> Result<LbsResponse> {
182        self.service.search_local_businesses(params).await
183    }
184}