cufinder_rust/
services.rs1use crate::{
2 client::Client,
3 error::{CufinderError, Result},
4 types::*,
5};
6
7pub struct Service {
9 client: Client,
10}
11
12impl Service {
13 pub fn new(client: Client) -> Self {
15 Self { client }
16 }
17
18 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", ¶ms).await?;
28 serde_json::from_value(response).map_err(CufinderError::JsonError)
29 }
30
31 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", ¶ms).await?;
38 serde_json::from_value(response).map_err(CufinderError::JsonError)
39 }
40
41 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", ¶ms).await?;
48 serde_json::from_value(response).map_err(CufinderError::JsonError)
49 }
50
51 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", ¶ms).await?;
58 serde_json::from_value(response).map_err(CufinderError::JsonError)
59 }
60
61 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", ¶ms).await?;
68 serde_json::from_value(response).map_err(CufinderError::JsonError)
69 }
70
71 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", ¶ms).await?;
78 serde_json::from_value(response).map_err(CufinderError::JsonError)
79 }
80
81 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", ¶ms).await?;
88 serde_json::from_value(response).map_err(CufinderError::JsonError)
89 }
90
91 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", ¶ms).await?;
98 serde_json::from_value(response).map_err(CufinderError::JsonError)
99 }
100
101 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", ¶ms).await?;
108 serde_json::from_value(response).map_err(CufinderError::JsonError)
109 }
110
111 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", ¶ms).await?;
118 serde_json::from_value(response).map_err(CufinderError::JsonError)
119 }
120
121 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", ¶ms).await?;
128 serde_json::from_value(response).map_err(CufinderError::JsonError)
129 }
130
131 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", ¶ms).await?;
138 serde_json::from_value(response).map_err(CufinderError::JsonError)
139 }
140
141 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", ¶ms).await?;
148 serde_json::from_value(response).map_err(CufinderError::JsonError)
149 }
150
151 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", ¶ms).await?;
161 serde_json::from_value(response).map_err(CufinderError::JsonError)
162 }
163
164 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", ¶ms).await?;
171 serde_json::from_value(response).map_err(CufinderError::JsonError)
172 }
173
174 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", ¶ms).await?;
181 serde_json::from_value(response).map_err(CufinderError::JsonError)
182 }
183
184 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", ¶ms).await?;
191 serde_json::from_value(response).map_err(CufinderError::JsonError)
192 }
193
194 pub async fn search_companies(&self, params: CseParams) -> Result<CseResponse> {
196 let response = self.client.post("/cse", ¶ms).await?;
197 serde_json::from_value(response).map_err(CufinderError::JsonError)
198 }
199
200 pub async fn search_people(&self, params: PseParams) -> Result<PseResponse> {
202 let response = self.client.post("/pse", ¶ms).await?;
203 serde_json::from_value(response).map_err(CufinderError::JsonError)
204 }
205
206 pub async fn search_local_businesses(&self, params: LbsParams) -> Result<LbsResponse> {
208 let response = self.client.post("/lbs", ¶ms).await?;
209 serde_json::from_value(response).map_err(CufinderError::JsonError)
210 }
211}