cufinder_rust/
services.rs

1use crate::{
2    client::Client,
3    error::{CufinderError, Result},
4    types::*,
5};
6
7/// Service implementation for CUFinder API
8pub struct Service {
9    client: Client,
10}
11
12impl Service {
13    /// Create a new service instance
14    pub fn new(client: Client) -> Self {
15        Self { client }
16    }
17
18    /// CUF Service - Company URL Finder
19    pub async fn get_domain(&self, params: CufParams) -> Result<CufResponse> {
20        if params.company_name.is_empty() {
21            return Err(CufinderError::ValidationError("company_name is required".to_string()));
22        }
23        if params.country_code.is_empty() {
24            return Err(CufinderError::ValidationError("country_code is required".to_string()));
25        }
26
27        let response = self.client.post("/cuf", &params).await?;
28        serde_json::from_value(response).map_err(CufinderError::JsonError)
29    }
30
31    /// LCUF Service - LinkedIn Company URL Finder
32    pub async fn get_linkedin_url(&self, params: LcufParams) -> Result<LcufResponse> {
33        if params.company_name.is_empty() {
34            return Err(CufinderError::ValidationError("company_name is required".to_string()));
35        }
36
37        let response = self.client.post("/lcuf", &params).await?;
38        serde_json::from_value(response).map_err(CufinderError::JsonError)
39    }
40
41    /// DTC Service - Domain to Company
42    pub async fn get_company_name(&self, params: DtcParams) -> Result<DtcResponse> {
43        if params.company_website.is_empty() {
44            return Err(CufinderError::ValidationError("company_website is required".to_string()));
45        }
46
47        let response = self.client.post("/dtc", &params).await?;
48        serde_json::from_value(response).map_err(CufinderError::JsonError)
49    }
50
51    /// DTE Service - Domain to Emails
52    pub async fn get_emails(&self, params: DteParams) -> Result<DteResponse> {
53        if params.company_website.is_empty() {
54            return Err(CufinderError::ValidationError("company_website is required".to_string()));
55        }
56
57        let response = self.client.post("/dte", &params).await?;
58        serde_json::from_value(response).map_err(CufinderError::JsonError)
59    }
60
61    /// NTP Service - Name to Phones
62    pub async fn get_phones(&self, params: NtpParams) -> Result<NtpResponse> {
63        if params.company_name.is_empty() {
64            return Err(CufinderError::ValidationError("company_name is required".to_string()));
65        }
66
67        let response = self.client.post("/ntp", &params).await?;
68        serde_json::from_value(response).map_err(CufinderError::JsonError)
69    }
70
71    /// REL Service - Reverse Email Lookup
72    pub async fn reverse_email_lookup(&self, params: RelParams) -> Result<RelResponse> {
73        if params.email.is_empty() {
74            return Err(CufinderError::ValidationError("email is required".to_string()));
75        }
76
77        let response = self.client.post("/rel", &params).await?;
78        serde_json::from_value(response).map_err(CufinderError::JsonError)
79    }
80
81    /// FCL Service - Find Company Lookalikes
82    pub async fn get_lookalikes(&self, params: FclParams) -> Result<FclResponse> {
83        if params.query.is_empty() {
84            return Err(CufinderError::ValidationError("query is required".to_string()));
85        }
86
87        let response = self.client.post("/fcl", &params).await?;
88        serde_json::from_value(response).map_err(CufinderError::JsonError)
89    }
90
91    /// ELF Service - Enrich LinkedIn Fundraising
92    pub async fn get_fundraising(&self, params: ElfParams) -> Result<ElfResponse> {
93        if params.query.is_empty() {
94            return Err(CufinderError::ValidationError("query is required".to_string()));
95        }
96
97        let response = self.client.post("/elf", &params).await?;
98        serde_json::from_value(response).map_err(CufinderError::JsonError)
99    }
100
101    /// CAR Service - Company Annual Revenue
102    pub async fn get_revenue(&self, params: CarParams) -> Result<CarResponse> {
103        if params.query.is_empty() {
104            return Err(CufinderError::ValidationError("query is required".to_string()));
105        }
106
107        let response = self.client.post("/car", &params).await?;
108        serde_json::from_value(response).map_err(CufinderError::JsonError)
109    }
110
111    /// FCC Service - Find Company Children
112    pub async fn get_subsidiaries(&self, params: FccParams) -> Result<FccResponse> {
113        if params.query.is_empty() {
114            return Err(CufinderError::ValidationError("query is required".to_string()));
115        }
116
117        let response = self.client.post("/fcc", &params).await?;
118        serde_json::from_value(response).map_err(CufinderError::JsonError)
119    }
120
121    /// FTS Service - Find Tech Stack
122    pub async fn get_tech_stack(&self, params: FtsParams) -> Result<FtsResponse> {
123        if params.query.is_empty() {
124            return Err(CufinderError::ValidationError("query is required".to_string()));
125        }
126
127        let response = self.client.post("/fts", &params).await?;
128        serde_json::from_value(response).map_err(CufinderError::JsonError)
129    }
130
131    /// EPP Service - Enrich Profile
132    pub async fn enrich_profile(&self, params: EppParams) -> Result<EppResponse> {
133        if params.linkedin_url.is_empty() {
134            return Err(CufinderError::ValidationError("linkedin_url is required".to_string()));
135        }
136
137        let response = self.client.post("/epp", &params).await?;
138        serde_json::from_value(response).map_err(CufinderError::JsonError)
139    }
140
141    /// FWE Service - Find Work Email
142    pub async fn get_email_from_profile(&self, params: FweParams) -> Result<FweResponse> {
143        if params.linkedin_url.is_empty() {
144            return Err(CufinderError::ValidationError("linkedin_url is required".to_string()));
145        }
146
147        let response = self.client.post("/fwe", &params).await?;
148        serde_json::from_value(response).map_err(CufinderError::JsonError)
149    }
150
151    /// TEP Service - Person Enrichment
152    pub async fn enrich_person(&self, params: TepParams) -> Result<TepResponse> {
153        if params.full_name.is_empty() {
154            return Err(CufinderError::ValidationError("full_name is required".to_string()));
155        }
156        if params.company.is_empty() {
157            return Err(CufinderError::ValidationError("company is required".to_string()));
158        }
159
160        let response = self.client.post("/tep", &params).await?;
161        serde_json::from_value(response).map_err(CufinderError::JsonError)
162    }
163
164    /// ENC Service - Company Enrichment
165    pub async fn enrich_company(&self, params: EncParams) -> Result<EncResponse> {
166        if params.query.is_empty() {
167            return Err(CufinderError::ValidationError("query is required".to_string()));
168        }
169
170        let response = self.client.post("/enc", &params).await?;
171        serde_json::from_value(response).map_err(CufinderError::JsonError)
172    }
173
174    /// CEC Service - Company Employee Countries
175    pub async fn get_employee_countries(&self, params: CecParams) -> Result<CecResponse> {
176        if params.query.is_empty() {
177            return Err(CufinderError::ValidationError("query is required".to_string()));
178        }
179
180        let response = self.client.post("/cec", &params).await?;
181        serde_json::from_value(response).map_err(CufinderError::JsonError)
182    }
183
184    /// CLO Service - Company Locations
185    pub async fn get_locations(&self, params: CloParams) -> Result<CloResponse> {
186        if params.query.is_empty() {
187            return Err(CufinderError::ValidationError("query is required".to_string()));
188        }
189
190        let response = self.client.post("/clo", &params).await?;
191        serde_json::from_value(response).map_err(CufinderError::JsonError)
192    }
193
194    /// CSE Service - Company Search
195    pub async fn search_companies(&self, params: CseParams) -> Result<CseResponse> {
196        let response = self.client.post("/cse", &params).await?;
197        serde_json::from_value(response).map_err(CufinderError::JsonError)
198    }
199
200    /// PSE Service - Person Search
201    pub async fn search_people(&self, params: PseParams) -> Result<PseResponse> {
202        let response = self.client.post("/pse", &params).await?;
203        serde_json::from_value(response).map_err(CufinderError::JsonError)
204    }
205
206    /// LBS Service - Local Business Search
207    pub async fn search_local_businesses(&self, params: LbsParams) -> Result<LbsResponse> {
208        let response = self.client.post("/lbs", &params).await?;
209        serde_json::from_value(response).map_err(CufinderError::JsonError)
210    }
211}